<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.darrenduncan.co.uk/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Darren</id>
	<title>Darren&#039;s Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.darrenduncan.co.uk/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Darren"/>
	<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Special:Contributions/Darren"/>
	<updated>2026-04-12T14:31:02Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=EWF_(Enhanced_Write_Filter)&amp;diff=668</id>
		<title>EWF (Enhanced Write Filter)</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=EWF_(Enhanced_Write_Filter)&amp;diff=668"/>
		<updated>2021-09-21T14:58:32Z</updated>

		<summary type="html">&lt;p&gt;Darren: Created page with &amp;quot;The &amp;#039;&amp;#039;&amp;#039;Ehanced Write Filter&amp;#039;&amp;#039;&amp;#039; is a component of the embedded versions of Microsft Windows OS. Where all or selected volume changes are written to ram instead of the HDD. This...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;Ehanced Write Filter&#039;&#039;&#039; is a component of the embedded versions of Microsft Windows OS. Where all or selected volume changes are written to ram instead of the HDD. This has two immediate benefits with the first being increased HDD lifetime. As writes to the HDD are kept to a minimum or possibly none the HDD has less chance of failing and more likely to last longer. With the second benefit being increased security as if the system does get infected with a virus or any other malware. The solution is simply to restart the system and the problem is gone.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Main_Page&amp;diff=666</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Main_Page&amp;diff=666"/>
		<updated>2021-04-26T11:40:33Z</updated>

		<summary type="html">&lt;p&gt;Darren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== &amp;lt;strong&amp;gt;Welcome to Darren&#039;s Wiki&amp;lt;/strong&amp;gt; ==&lt;br /&gt;
In here you will find information that I&#039;ve found useful over time and decided to store here. These are a mixture of self written pages and already written pages taken from the Wikipedia website.&lt;br /&gt;
&lt;br /&gt;
Hopefully you find this as useful as I have done. 😃&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Main_Page&amp;diff=665</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Main_Page&amp;diff=665"/>
		<updated>2021-04-26T11:38:33Z</updated>

		<summary type="html">&lt;p&gt;Darren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== &amp;lt;strong&amp;gt;Welcome to Darren&#039;s Wiki&amp;lt;/strong&amp;gt; ==&lt;br /&gt;
In here you will find information that I&#039;ve found useful over time and decided to store here. These are a mixture of self written pages and already written pages taken from the Wikipedia website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hopefully you find this as useful as I have done. 😃&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Main_Page&amp;diff=664</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Main_Page&amp;diff=664"/>
		<updated>2021-04-26T11:36:48Z</updated>

		<summary type="html">&lt;p&gt;Darren: First Update.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== &amp;lt;strong&amp;gt;Welcome to Darren&#039;s Wiki&amp;lt;/strong&amp;gt; ==&lt;br /&gt;
In here you will find information that I&#039;ve found useful over time and decided to store here. These are a mixture of self written pages and already written pages taken from the Wikipedia website. &lt;br /&gt;
Hopefully you find this as useful as I have done. 😃&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=663</id>
		<title>SREC (file format)</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=663"/>
		<updated>2021-04-26T10:58:19Z</updated>

		<summary type="html">&lt;p&gt;Darren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Motorola S-record&#039;&#039;&#039; is a file format, created by [[Motorola]], that conveys binary information as [[hexadecimal|hex]] values in [[ASCII]] text form. This file format may also be known as &#039;&#039;&#039;SRECORD&#039;&#039;&#039;, &#039;&#039;&#039;SREC&#039;&#039;&#039;, &#039;&#039;&#039;S19&#039;&#039;&#039;, &#039;&#039;&#039;S28&#039;&#039;&#039;, &#039;&#039;&#039;S37&#039;&#039;&#039;. It is commonly used for programming [[flash memory]] in microcontrollers, [[EPROM]]s, [[EEPROM]]s, and other types of programmable logic devices. In a typical application, a compiler or assembler converts a program&#039;s source code (such as C or assembly language) to machine code and outputs it into a HEX file. The HEX file is then imported by a programmer to &amp;quot;burn&amp;quot; the machine code into [[non-volatile memory]], or is transferred to the target system for loading and execution.&lt;br /&gt;
[[File:Motorola SREC Chart.png|thumb|A quick reference chart for the Motorola SREC format. (Note that in the record example image the word &amp;quot;bytes&amp;quot; is alternatively used to specify characters.)&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename extension&lt;br /&gt;
|&amp;lt;code&amp;gt;.s19&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s28&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s37&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.sx&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.srec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.exo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mxt&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Developed by&lt;br /&gt;
|Motorola&lt;br /&gt;
|}&lt;br /&gt;
]]&lt;br /&gt;
==Overview==&lt;br /&gt;
===History===&lt;br /&gt;
The S-record format was created in the mid-1970s for the [[Motorola 6800]] processor. [[Programming tool|Software development tools]] for that and other [[embedded processor]]s would make executable code and data in the S-record format. PROM programmers would then read the S-record format and &amp;quot;burn&amp;quot; the data into the PROMs or EPROMs used in the embedded system.&lt;br /&gt;
===Other hex formats===&lt;br /&gt;
There are other ASCII encoding with a similar purpose. [[BPNF]], [[BHLF]], and [[B10F]] were early binary formats, but they are neither compact nor flexible. Hexadecimal formats are more compact because they represent 4 bits rather than 1 bit per character. Many, such as S-record, are more flexible because they include address information so they can specify just a portion of a PROM. [[Intel HEX]] format was often used with Intel processors. [[TekHex]] is another hex format that can include a symbol table for debugging.&lt;br /&gt;
==Format==&lt;br /&gt;
===Record structure===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | S || style=&#039;background: #FFCCCC&#039; | Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
An SREC format file consists of a series of ASCII text records. The records have the following structure from left to right:&lt;br /&gt;
# &#039;&#039;Record start&#039;&#039; - each record begins with an uppercase letter &amp;quot;S&amp;quot; character (ASCII 0x53) which stands for &amp;quot;Start-of-Record&amp;quot;.&lt;br /&gt;
# &#039;&#039;Record type&#039;&#039; - single numeric digit &amp;quot;0&amp;quot; to &amp;quot;9&amp;quot;, defining the type of record.&lt;br /&gt;
# &#039;&#039;Byte count&#039;&#039; - two hex digits, indicating the number of bytes (hex digit pairs) that follow in the rest of the record (address + data + checksum). This field has a minimum value of 3 for 16-bit address field plus 1 checksum byte, and a maximum value of 255 (0xFF).&lt;br /&gt;
# &#039;&#039;Address&#039;&#039; - four / six / eight hex digits as determined by the record type. The address bytes are arranged in [[Endianness|big endian]] format.&lt;br /&gt;
# &#039;&#039;Data&#039;&#039; - a sequence of 2&#039;&#039;n&#039;&#039; hex digits, for &#039;&#039;n&#039;&#039; bytes of the data. For S1/S2/S3 records, a maximum of 32 bytes per record is typical since it will fit on an 80 character wide terminal screen, though 16 bytes would be easier to visually decode each byte at a specific address.&lt;br /&gt;
# &#039;&#039;Checksum&#039;&#039; - two hex digits, the [[least significant byte]] of [[ones&#039; complement]] of the sum of the values represented by the two hex digit pairs for the byte count, address and data fields. See example section for a detailed checksum example.&lt;br /&gt;
===Text line terminators===&lt;br /&gt;
SREC records are separated by one or more ASCII line termination characters so that each record appears alone on a text line. This enhances legibility by visually [[delimiter|delimiting]] the records and it also provides padding between records that can be used to improve machine [[parsing]] efficiency.&lt;br /&gt;
&lt;br /&gt;
Programs that create HEX records typically use line termination characters that conform to the conventions of their [[operating system]]s. For example, Linux programs use a single LF character ([[Newline|line feed]], 0x0A as ASCII character value) character to terminate lines, whereas Windows programs use a CR character ([[carriage return]], 0x0D as ASCII character value) followed by a LF character.&lt;br /&gt;
===Record types===&lt;br /&gt;
The following table describes 10 possible S-records. S4 is reserved and not currently defined. S6 was originally reserved but was later redefined.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Record&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;purpose&lt;br /&gt;
! Address&amp;lt;br&amp;gt;field&lt;br /&gt;
! Data&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;description&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S0&#039;&#039;&lt;br /&gt;
| Header&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;&amp;quot;0000&amp;quot;&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains vendor specific ASCII text comment represented as a series of hex digit pairs. It is common to see the data for this record in the format of a [[null-terminated string]]. The text data can be anything including a mixture of the following information: file/module name, version/revision number, date/time, product name, vendor name, memory designator on PCB, copyright notice. It is common to see: 48 44 52 which is the ASCII H, D, and R - &amp;quot;HDR&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S1&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at the 16-bit address field. This record is typically used for 8-bit microcontrollers, such as AVR, PIC, 8051, 68xx, 6502, 80xx, Z80. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 3 (that is, 2 bytes for &amp;quot;16-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S2&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 24-bit address. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 4 (that is, 3 bytes for &amp;quot;24-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S3&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 32-bit address. This record is typically used for 32-bit microcontrollers, such as ARM and 680x0. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 5 (that is, 4 bytes for &amp;quot;32-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S4&#039;&#039;&lt;br /&gt;
| Reserved&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| This record is reserved.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S5&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 16-bit count of S1/S2/S3 records. This record is used if the record count is less than or equal to 65,535 (0xFFFF), otherwise S6 record would be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S6&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 24-bit count of S1/S2/S3 records. This record is used if the record count is less than or equal to 16,777,215 (0xFFFFFF). If less than 65,536 (0x10000), then S5 record would be used. &#039;&#039;&#039;NOTE:&#039;&#039;&#039; This newer record is the most recent change (it may not be official).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S7&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 32-bit address. This is used to terminate a series of S3 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S8&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 24-bit address. This is used to terminate a series of S2 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S9&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 16-bit address. This is used to terminate a series of S1 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|}&lt;br /&gt;
===Record order===&lt;br /&gt;
Although some Unix documentation states &amp;quot;the order of S-records within a file is of no significance and no particular order may be assumed&amp;quot;, in practice most software has ordered the SREC records. The typical record order starts with a (sometimes optional) S0 header record, continues with a sequence of one or more S1/S2/S3 data records, may have one optional S5/S6 count record, and ends with one appropriate S7/S8/S9 termination record.&lt;br /&gt;
; S19-style 16-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S1 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S9&lt;br /&gt;
; S28-style 24-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S2 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S8&lt;br /&gt;
; S37-style 32-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S3 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S7&lt;br /&gt;
===Limitations===&lt;br /&gt;
&#039;&#039;Record length&#039;&#039; - Unix manual page documentation states, &amp;quot;An S-record file consists of a sequence of specially formatted ASCII character strings. An S-record will be less than or equal to 78 bytes in length&amp;quot;. The manual page further limits the number of characters in the data field to 64 (or 32 data bytes). A record with an 8-hex-character address and 64 data characters would be 78 (2 + 2 + 8 + 64 + 2) characters long (this count ignores possible end-of-line or string termination characters). The file could be printed on an 80-character wide teleprinter. A note at the bottom of the manual page states, &amp;quot;This [manual page] is the only place that a 78-byte limit on total record length or 64-byte limit on data length is documented. These values shouldn&#039;t be trusted for the general case&amp;quot;. If that limitation is ignored, the maximum length of an S-record is 514 characters: 2 for Record Type field + 2 for Byte Count field (whose value would be 0xFF=255) + 2 * 255 for Address, Data, and Checksum fields. Additional buffer space may be required for the line and string terminators. Using long line lengths has problems: &amp;quot;The Motorola S-record format definition permits up to 255 bytes of payload, or lines of 514 characters, plus the line termination. All EPROM programmers should have sufficiently large line buffers to cope with records this big. Few do.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Data field&#039;&#039; - Some documentation recommends a maximum of 32 bytes of data (64 hex characters) in this field. The minimum amount of data for S0/S1/S2/S3 records is zero. The maximum amount of data varies depending on the size of the address field. Since the Byte Count field can&#039;t be higher than 255 (0xFF), then the maximum number of bytes of data is calculated by 255 minus (1 byte for checksum field) minus (number of bytes in the address field). S0/S1 records support up to 252 bytes of data. S2 record supports up to 251 bytes of data. S3 record supports up to 250 bytes of data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Comments&#039;&#039; - The SREC file format does not support comments. Some software ignores all text lines that do not start with &amp;quot;S&amp;quot; and ignores all text after the checksum field; that extra text is sometimes used (incompatibly) for comments. For example, the CCS PIC compiler supports placing a &amp;quot;;&amp;quot; comment line at the top or bottom of an [[Intel HEX]] file, and its manuals states &amp;quot;some programmers (MPLAB in particular) do not like comments at the top of the hex file&amp;quot;, which is why the compiler has the option of placing the comment at the bottom of the hex file.&lt;br /&gt;
==Examples==&lt;br /&gt;
; Color legend&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | Record Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
===Checksum calculation===&lt;br /&gt;
The following example record:&lt;br /&gt;
 {{SREC HEX|1|13|7AF0|0A0A0D00000000000000000000000000|61}}&lt;br /&gt;
is decoded to show how the checksum value is calculated as follows:&lt;br /&gt;
# Add: Add each byte 0x13 + 0x7A + 0xF0 + 0x0A + 0x0A + 0x0D + 0x00 + ... + 0x00 = 0x19E total.&lt;br /&gt;
# Mask: Keep the least significant byte of the total = 0x9E.&lt;br /&gt;
# Complement: Compute [[ones&#039; complement]] of least significant byte = 0x61.&lt;br /&gt;
===16-bit memory address===&lt;br /&gt;
 {{SREC HEX|0|0F|0000|68656C6C6F20202020200000|3C}}&lt;br /&gt;
 {{SREC HEX|1|1F|0000|7C0802A6900100049421FFF07C6C1B787C8C23783C60000038630000|26}}&lt;br /&gt;
 {{SREC HEX|1|1F|001C|4BFFFFE5398000007D83637880010014382100107C0803A64E800020|E9}}&lt;br /&gt;
 {{SREC HEX|1|11|0038|48656C6C6F20776F726C642E0A00|42}}&lt;br /&gt;
 {{SREC HEX|5|03|0003||F9}}&lt;br /&gt;
 {{SREC HEX|9|03|0000||FC}}&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Binary-to-text encoding]], a survey and comparison of encoding algorithms&lt;br /&gt;
* [[Intel hex format]]&lt;br /&gt;
* [[MOS Technology file format]]&lt;br /&gt;
* [[Tektronix hex format]]&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://srecord.sourceforge.net/ SRecord] is a collection of tools for manipulating SREC format files.&lt;br /&gt;
* [http://www.keil.com/download/docs/4.asp BIN2MOT], BINARY to Motorola S-Record file converter utility.&lt;br /&gt;
* [https://github.com/BigWinston/SRecordizer/wiki SRecordizer] is a tool for viewing, editing, and error checking S19 format files.&lt;br /&gt;
* [https://pypi.python.org/pypi/bincopy bincopy] is a Python package for manipulating SREC format files.&lt;br /&gt;
* [https://github.com/arkku/srec kk_srec] is a C library and program for reading the SREC format.&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=662</id>
		<title>SREC (file format)</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=662"/>
		<updated>2021-04-26T10:56:36Z</updated>

		<summary type="html">&lt;p&gt;Darren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Motorola S-record&#039;&#039;&#039; is a file format, created by [[Motorola]], that conveys binary information as [[hexadecimal|hex]] values in [[ASCII]] text form. This file format may also be known as &#039;&#039;&#039;SRECORD&#039;&#039;&#039;, &#039;&#039;&#039;SREC&#039;&#039;&#039;, &#039;&#039;&#039;S19&#039;&#039;&#039;, &#039;&#039;&#039;S28&#039;&#039;&#039;, &#039;&#039;&#039;S37&#039;&#039;&#039;. It is commonly used for programming [[flash memory]] in microcontrollers, [[EPROM]]s, [[EEPROM]]s, and other types of programmable logic devices. In a typical application, a compiler or assembler converts a program&#039;s source code (such as C or assembly language) to machine code and outputs it into a HEX file. The HEX file is then imported by a programmer to &amp;quot;burn&amp;quot; the machine code into [[non-volatile memory]], or is transferred to the target system for loading and execution.&lt;br /&gt;
[[File:Motorola SREC Chart.png|thumb|A quick reference chart for the Motorola SREC format. (Note that in the record example image the word &amp;quot;bytes&amp;quot; is alternatively used to specify characters.)&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename extension&lt;br /&gt;
|&amp;lt;code&amp;gt;.s19&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s28&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s37&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.sx&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.srec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.exo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mxt&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Developed by&lt;br /&gt;
|Motorola&lt;br /&gt;
|}&lt;br /&gt;
]]&lt;br /&gt;
==Overview==&lt;br /&gt;
===History===&lt;br /&gt;
The S-record format was created in the mid-1970s for the [[Motorola 6800]] processor. [[Programming tool|Software development tools]] for that and other [[embedded processor]]s would make executable code and data in the S-record format. PROM programmers would then read the S-record format and &amp;quot;burn&amp;quot; the data into the PROMs or EPROMs used in the embedded system.&lt;br /&gt;
===Other hex formats===&lt;br /&gt;
There are other ASCII encoding with a similar purpose. [[BPNF]], [[BHLF]], and [[B10F]] were early binary formats, but they are neither compact nor flexible. Hexadecimal formats are more compact because they represent 4 bits rather than 1 bit per character. Many, such as S-record, are more flexible because they include address information so they can specify just a portion of a PROM. [[Intel HEX]] format was often used with Intel processors. [[TekHex]] is another hex format that can include a symbol table for debugging.&lt;br /&gt;
==Format==&lt;br /&gt;
===Record structure===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | S || style=&#039;background: #FFCCCC&#039; | Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
An SREC format file consists of a series of ASCII text records. The records have the following structure from left to right:&lt;br /&gt;
# &#039;&#039;Record start&#039;&#039; - each record begins with an uppercase letter &amp;quot;S&amp;quot; character (ASCII 0x53) which stands for &amp;quot;Start-of-Record&amp;quot;.&lt;br /&gt;
# &#039;&#039;Record type&#039;&#039; - single numeric digit &amp;quot;0&amp;quot; to &amp;quot;9&amp;quot;, defining the type of record.&lt;br /&gt;
# &#039;&#039;Byte count&#039;&#039; - two hex digits, indicating the number of bytes (hex digit pairs) that follow in the rest of the record (address + data + checksum). This field has a minimum value of 3 for 16-bit address field plus 1 checksum byte, and a maximum value of 255 (0xFF).&lt;br /&gt;
# &#039;&#039;Address&#039;&#039; - four / six / eight hex digits as determined by the record type. The address bytes are arranged in [[Endianness|big endian]] format.&lt;br /&gt;
# &#039;&#039;Data&#039;&#039; - a sequence of 2&#039;&#039;n&#039;&#039; hex digits, for &#039;&#039;n&#039;&#039; bytes of the data. For S1/S2/S3 records, a maximum of 32 bytes per record is typical since it will fit on an 80 character wide terminal screen, though 16 bytes would be easier to visually decode each byte at a specific address.&lt;br /&gt;
# &#039;&#039;Checksum&#039;&#039; - two hex digits, the [[least significant byte]] of [[ones&#039; complement]] of the sum of the values represented by the two hex digit pairs for the byte count, address and data fields. See example section for a detailed checksum example.&lt;br /&gt;
===Text line terminators===&lt;br /&gt;
SREC records are separated by one or more ASCII line termination characters so that each record appears alone on a text line. This enhances legibility by visually [[delimiter|delimiting]] the records and it also provides padding between records that can be used to improve machine [[parsing]] efficiency.&lt;br /&gt;
&lt;br /&gt;
Programs that create HEX records typically use line termination characters that conform to the conventions of their [[operating system]]s. For example, Linux programs use a single LF character ([[Newline|line feed]], 0x0A as ASCII character value) character to terminate lines, whereas Windows programs use a CR character ([[carriage return]], 0x0D as ASCII character value) followed by a LF character.&lt;br /&gt;
===Record types===&lt;br /&gt;
The following table describes 10 possible S-records. S4 is reserved and not currently defined. S6 was originally reserved but was later redefined.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Record&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;purpose&lt;br /&gt;
! Address&amp;lt;br&amp;gt;field&lt;br /&gt;
! Data&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;description&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S0&#039;&#039;&lt;br /&gt;
| Header&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;&amp;quot;0000&amp;quot;&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains vendor specific ASCII text comment represented as a series of hex digit pairs. It is common to see the data for this record in the format of a [[null-terminated string]]. The text data can be anything including a mixture of the following information: file/module name, version/revision number, date/time, product name, vendor name, memory designator on PCB, copyright notice. It is common to see: 48 44 52 which is the ASCII H, D, and R - &amp;quot;HDR&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S1&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at the 16-bit address field. This record is typically used for 8-bit microcontrollers, such as AVR, PIC, 8051, 68xx, 6502, 80xx, Z80. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 3 (that is, 2 bytes for &amp;quot;16-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S2&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 24-bit address. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 4 (that is, 3 bytes for &amp;quot;24-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S3&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 32-bit address. This record is typically used for 32-bit microcontrollers, such as ARM and 680x0. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 5 (that is, 4 bytes for &amp;quot;32-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S4&#039;&#039;&lt;br /&gt;
| Reserved&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| This record is reserved.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S5&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 16-bit count of S1/S2/S3 records. This record is used if the record count is less than or equal to 65,535 (0xFFFF), otherwise S6 record would be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S6&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 24-bit count of S1/S2/S3 records. This record is used if the record count is less than or equal to 16,777,215 (0xFFFFFF). If less than 65,536 (0x10000), then S5 record would be used. &#039;&#039;&#039;NOTE:&#039;&#039;&#039; This newer record is the most recent change (it may not be official).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S7&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 32-bit address. This is used to terminate a series of S3 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S8&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 24-bit address. This is used to terminate a series of S2 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S9&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 16-bit address. This is used to terminate a series of S1 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|}&lt;br /&gt;
===Record order===&lt;br /&gt;
Although some Unix documentation states &amp;quot;the order of S-records within a file is of no significance and no particular order may be assumed&amp;quot;,&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; in practice most software has ordered the SREC records. The typical record order starts with a (sometimes optional) S0 header record, continues with a sequence of one or more S1/S2/S3 data records, may have one optional S5/S6 count record, and ends with one appropriate S7/S8/S9 termination record.&lt;br /&gt;
; S19-style 16-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S1 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S9&lt;br /&gt;
; S28-style 24-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S2 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S8&lt;br /&gt;
; S37-style 32-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S3 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S7&lt;br /&gt;
===Limitations===&lt;br /&gt;
&#039;&#039;Record length&#039;&#039; - Unix manual page documentation states, &amp;quot;An S-record file consists of a sequence of specially formatted ASCII character strings. An S-record will be less than or equal to 78 bytes in length&amp;quot;. The manual page further limits the number of characters in the data field to 64 (or 32 data bytes).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; A record with an 8-hex-character address and 64 data characters would be 78 (2 + 2 + 8 + 64 + 2) characters long (this count ignores possible end-of-line or string termination characters). The file could be printed on an 80-character wide teleprinter. A note at the bottom of the manual page states, &amp;quot;This [manual page] is the only place that a 78-byte limit on total record length or 64-byte limit on data length is documented. These values shouldn&#039;t be trusted for the general case&amp;quot;.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; If that limitation is ignored, the maximum length of an S-record is 514 characters: 2 for Record Type field + 2 for Byte Count field (whose value would be 0xFF=255) + 2 * 255 for Address, Data, and Checksum fields. Additional buffer space may be required for the line and string terminators. Using long line lengths has problems: &amp;quot;The Motorola S-record format definition permits up to 255 bytes of payload, or lines of 514 characters, plus the line termination. All EPROM programmers should have sufficiently large line buffers to cope with records this big. Few do.&amp;quot;&amp;lt;ref name=&amp;quot;sf&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Data field&#039;&#039; - Some documentation recommends a maximum of 32 bytes of data (64 hex characters) in this field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The minimum amount of data for S0/S1/S2/S3 records is zero. The maximum amount of data varies depending on the size of the address field. Since the Byte Count field can&#039;t be higher than 255 (0xFF), then the maximum number of bytes of data is calculated by 255 minus (1 byte for checksum field) minus (number of bytes in the address field). S0/S1 records support up to 252 bytes of data. S2 record supports up to 251 bytes of data. S3 record supports up to 250 bytes of data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Comments&#039;&#039; - The SREC file format does not support comments. Some software ignores all text lines that do not start with &amp;quot;S&amp;quot; and ignores all text after the checksum field; that extra text is sometimes used (incompatibly) for comments. For example, the CCS PIC compiler supports placing a &amp;quot;;&amp;quot; comment line at the top or bottom of an [[Intel HEX]] file, and its manuals states &amp;quot;some programmers (MPLAB in particular) do not like comments at the top of the hex file&amp;quot;, which is why the compiler has the option of placing the comment at the bottom of the hex file.&amp;lt;ref name=&amp;quot;CCS_2014&amp;quot;/&amp;gt;&lt;br /&gt;
==Examples==&lt;br /&gt;
; Color legend&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | Record Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
===Checksum calculation===&lt;br /&gt;
The following example record:&lt;br /&gt;
 {{SREC HEX|1|13|7AF0|0A0A0D00000000000000000000000000|61}}&lt;br /&gt;
is decoded to show how the checksum value is calculated as follows:&lt;br /&gt;
# Add: Add each byte 0x13 + 0x7A + 0xF0 + 0x0A + 0x0A + 0x0D + 0x00 + ... + 0x00 = 0x19E total.&lt;br /&gt;
# Mask: Keep the least significant byte of the total = 0x9E.&lt;br /&gt;
# Complement: Compute [[ones&#039; complement]] of least significant byte = 0x61.&lt;br /&gt;
===16-bit memory address===&lt;br /&gt;
 {{SREC HEX|0|0F|0000|68656C6C6F20202020200000|3C}}&lt;br /&gt;
 {{SREC HEX|1|1F|0000|7C0802A6900100049421FFF07C6C1B787C8C23783C60000038630000|26}}&lt;br /&gt;
 {{SREC HEX|1|1F|001C|4BFFFFE5398000007D83637880010014382100107C0803A64E800020|E9}}&lt;br /&gt;
 {{SREC HEX|1|11|0038|48656C6C6F20776F726C642E0A00|42}}&lt;br /&gt;
 {{SREC HEX|5|03|0003||F9}}&lt;br /&gt;
 {{SREC HEX|9|03|0000||FC}}&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Binary-to-text encoding]], a survey and comparison of encoding algorithms&lt;br /&gt;
* [[Intel hex format]]&lt;br /&gt;
* [[MOS Technology file format]]&lt;br /&gt;
* [[Tektronix hex format]]&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://srecord.sourceforge.net/ SRecord] is a collection of tools for manipulating SREC format files.&lt;br /&gt;
* [http://www.keil.com/download/docs/4.asp BIN2MOT], BINARY to Motorola S-Record file converter utility.&lt;br /&gt;
* [https://github.com/BigWinston/SRecordizer/wiki SRecordizer] is a tool for viewing, editing, and error checking S19 format files.&lt;br /&gt;
* [https://pypi.python.org/pypi/bincopy bincopy] is a Python package for manipulating SREC format files.&lt;br /&gt;
* [https://github.com/arkku/srec kk_srec] is a C library and program for reading the SREC format.&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=661</id>
		<title>SREC (file format)</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=661"/>
		<updated>2021-04-26T10:55:20Z</updated>

		<summary type="html">&lt;p&gt;Darren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Motorola S-record&#039;&#039;&#039; is a file format, created by [[Motorola]], that conveys binary information as [[hexadecimal|hex]] values in [[ASCII]] text form. This file format may also be known as &#039;&#039;&#039;SRECORD&#039;&#039;&#039;, &#039;&#039;&#039;SREC&#039;&#039;&#039;, &#039;&#039;&#039;S19&#039;&#039;&#039;, &#039;&#039;&#039;S28&#039;&#039;&#039;, &#039;&#039;&#039;S37&#039;&#039;&#039;. It is commonly used for programming [[flash memory]] in microcontrollers, [[EPROM]]s, [[EEPROM]]s, and other types of programmable logic devices. In a typical application, a compiler or assembler converts a program&#039;s source code (such as C or assembly language) to machine code and outputs it into a HEX file. The HEX file is then imported by a programmer to &amp;quot;burn&amp;quot; the machine code into [[non-volatile memory]], or is transferred to the target system for loading and execution.&lt;br /&gt;
[[File:Motorola SREC Chart.png|thumb|A quick reference chart for the Motorola SREC format. (Note that in the record example image the word &amp;quot;bytes&amp;quot; is alternatively used to specify characters.)&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename extension&lt;br /&gt;
|&amp;lt;code&amp;gt;.s19&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s28&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s37&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.sx&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.srec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.exo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mxt&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Developed by&lt;br /&gt;
|Motorola&lt;br /&gt;
|}&lt;br /&gt;
]]&lt;br /&gt;
==Overview==&lt;br /&gt;
===History===&lt;br /&gt;
The S-record format was created in the mid-1970s for the [[Motorola 6800]] processor. [[Programming tool|Software development tools]] for that and other [[embedded processor]]s would make executable code and data in the S-record format. PROM programmers would then read the S-record format and &amp;quot;burn&amp;quot; the data into the PROMs or EPROMs used in the embedded system.&lt;br /&gt;
===Other hex formats===&lt;br /&gt;
There are other ASCII encoding with a similar purpose. [[BPNF]], [[BHLF]], and [[B10F]] were early binary formats, but they are neither compact nor flexible. Hexadecimal formats are more compact because they represent 4 bits rather than 1 bit per character. Many, such as S-record, are more flexible because they include address information so they can specify just a portion of a PROM. [[Intel HEX]] format was often used with Intel processors. [[TekHex]] is another hex format that can include a symbol table for debugging.&lt;br /&gt;
==Format==&lt;br /&gt;
===Record structure===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | S || style=&#039;background: #FFCCCC&#039; | Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
An SREC format file consists of a series of ASCII text records. The records have the following structure from left to right:&lt;br /&gt;
# &#039;&#039;Record start&#039;&#039; - each record begins with an uppercase letter &amp;quot;S&amp;quot; character (ASCII 0x53) which stands for &amp;quot;Start-of-Record&amp;quot;.&lt;br /&gt;
# &#039;&#039;Record type&#039;&#039; - single numeric digit &amp;quot;0&amp;quot; to &amp;quot;9&amp;quot;, defining the type of record.&lt;br /&gt;
# &#039;&#039;Byte count&#039;&#039; - two hex digits, indicating the number of bytes (hex digit pairs) that follow in the rest of the record (address + data + checksum). This field has a minimum value of 3 for 16-bit address field plus 1 checksum byte, and a maximum value of 255 (0xFF).&lt;br /&gt;
# &#039;&#039;Address&#039;&#039; - four / six / eight hex digits as determined by the record type. The address bytes are arranged in [[Endianness|big endian]] format.&lt;br /&gt;
# &#039;&#039;Data&#039;&#039; - a sequence of 2&#039;&#039;n&#039;&#039; hex digits, for &#039;&#039;n&#039;&#039; bytes of the data. For S1/S2/S3 records, a maximum of 32 bytes per record is typical since it will fit on an 80 character wide terminal screen, though 16 bytes would be easier to visually decode each byte at a specific address.&lt;br /&gt;
# &#039;&#039;Checksum&#039;&#039; - two hex digits, the [[least significant byte]] of [[ones&#039; complement]] of the sum of the values represented by the two hex digit pairs for the byte count, address and data fields. See example section for a detailed checksum example.&lt;br /&gt;
===Text line terminators===&lt;br /&gt;
SREC records are separated by one or more ASCII line termination characters so that each record appears alone on a text line. This enhances legibility by visually [[delimiter|delimiting]] the records and it also provides padding between records that can be used to improve machine [[parsing]] efficiency.&lt;br /&gt;
&lt;br /&gt;
Programs that create HEX records typically use line termination characters that conform to the conventions of their [[operating system]]s. For example, Linux programs use a single LF character ([[Newline|line feed]], 0x0A as ASCII character value) character to terminate lines, whereas Windows programs use a CR character ([[carriage return]], 0x0D as ASCII character value) followed by a LF character.&lt;br /&gt;
===Record types===&lt;br /&gt;
The following table describes 10 possible S-records. S4 is reserved and not currently defined. S6 was originally reserved but was later redefined.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Record&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;purpose&lt;br /&gt;
! Address&amp;lt;br&amp;gt;field&lt;br /&gt;
! Data&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;description&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S0&#039;&#039;&lt;br /&gt;
| Header&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;&amp;quot;0000&amp;quot;&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains vendor specific ASCII text comment represented as a series of hex digit pairs. It is common to see the data for this record in the format of a [[null-terminated string]]. The text data can be anything including a mixture of the following information: file/module name, version/revision number, date/time, product name, vendor name, memory designator on PCB, copyright notice. It is common to see: 48 44 52 which is the ASCII H, D, and R - &amp;quot;HDR&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S1&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at the 16-bit address field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is typically used for 8-bit microcontrollers, such as AVR, PIC, 8051, 68xx, 6502, 80xx, Z80. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 3 (that is, 2 bytes for &amp;quot;16-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S2&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 24-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 4 (that is, 3 bytes for &amp;quot;24-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S3&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 32-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is typically used for 32-bit microcontrollers, such as ARM and 680x0. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 5 (that is, 4 bytes for &amp;quot;32-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S4&#039;&#039;&lt;br /&gt;
| Reserved&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| This record is reserved.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S5&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 16-bit count of S1/S2/S3 records.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is used if the record count is less than or equal to 65,535 (0xFFFF), otherwise S6 record would be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S6&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 24-bit count of S1/S2/S3 records. This record is used if the record count is less than or equal to 16,777,215 (0xFFFFFF). If less than 65,536 (0x10000), then S5 record would be used. &#039;&#039;&#039;NOTE:&#039;&#039;&#039; This newer record is the most recent change (it may not be official).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S7&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 32-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S3 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S8&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 24-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S2 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S9&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 16-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S1 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|}&lt;br /&gt;
===Record order===&lt;br /&gt;
Although some Unix documentation states &amp;quot;the order of S-records within a file is of no significance and no particular order may be assumed&amp;quot;,&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; in practice most software has ordered the SREC records. The typical record order starts with a (sometimes optional) S0 header record, continues with a sequence of one or more S1/S2/S3 data records, may have one optional S5/S6 count record, and ends with one appropriate S7/S8/S9 termination record.&lt;br /&gt;
; S19-style 16-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S1 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S9&lt;br /&gt;
; S28-style 24-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S2 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S8&lt;br /&gt;
; S37-style 32-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S3 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S7&lt;br /&gt;
===Limitations===&lt;br /&gt;
&#039;&#039;Record length&#039;&#039; - Unix manual page documentation states, &amp;quot;An S-record file consists of a sequence of specially formatted ASCII character strings. An S-record will be less than or equal to 78 bytes in length&amp;quot;. The manual page further limits the number of characters in the data field to 64 (or 32 data bytes).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; A record with an 8-hex-character address and 64 data characters would be 78 (2 + 2 + 8 + 64 + 2) characters long (this count ignores possible end-of-line or string termination characters). The file could be printed on an 80-character wide teleprinter. A note at the bottom of the manual page states, &amp;quot;This [manual page] is the only place that a 78-byte limit on total record length or 64-byte limit on data length is documented. These values shouldn&#039;t be trusted for the general case&amp;quot;.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; If that limitation is ignored, the maximum length of an S-record is 514 characters: 2 for Record Type field + 2 for Byte Count field (whose value would be 0xFF=255) + 2 * 255 for Address, Data, and Checksum fields. Additional buffer space may be required for the line and string terminators. Using long line lengths has problems: &amp;quot;The Motorola S-record format definition permits up to 255 bytes of payload, or lines of 514 characters, plus the line termination. All EPROM programmers should have sufficiently large line buffers to cope with records this big. Few do.&amp;quot;&amp;lt;ref name=&amp;quot;sf&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Data field&#039;&#039; - Some documentation recommends a maximum of 32 bytes of data (64 hex characters) in this field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The minimum amount of data for S0/S1/S2/S3 records is zero. The maximum amount of data varies depending on the size of the address field. Since the Byte Count field can&#039;t be higher than 255 (0xFF), then the maximum number of bytes of data is calculated by 255 minus (1 byte for checksum field) minus (number of bytes in the address field). S0/S1 records support up to 252 bytes of data. S2 record supports up to 251 bytes of data. S3 record supports up to 250 bytes of data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Comments&#039;&#039; - The SREC file format does not support comments. Some software ignores all text lines that do not start with &amp;quot;S&amp;quot; and ignores all text after the checksum field; that extra text is sometimes used (incompatibly) for comments. For example, the CCS PIC compiler supports placing a &amp;quot;;&amp;quot; comment line at the top or bottom of an [[Intel HEX]] file, and its manuals states &amp;quot;some programmers (MPLAB in particular) do not like comments at the top of the hex file&amp;quot;, which is why the compiler has the option of placing the comment at the bottom of the hex file.&amp;lt;ref name=&amp;quot;CCS_2014&amp;quot;/&amp;gt;&lt;br /&gt;
==Examples==&lt;br /&gt;
; Color legend&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | Record Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
===Checksum calculation===&lt;br /&gt;
The following example record:&lt;br /&gt;
 {{SREC HEX|1|13|7AF0|0A0A0D00000000000000000000000000|61}}&lt;br /&gt;
is decoded to show how the checksum value is calculated as follows:&lt;br /&gt;
# Add: Add each byte 0x13 + 0x7A + 0xF0 + 0x0A + 0x0A + 0x0D + 0x00 + ... + 0x00 = 0x19E total.&lt;br /&gt;
# Mask: Keep the least significant byte of the total = 0x9E.&lt;br /&gt;
# Complement: Compute [[ones&#039; complement]] of least significant byte = 0x61.&lt;br /&gt;
===16-bit memory address===&lt;br /&gt;
 {{SREC HEX|0|0F|0000|68656C6C6F20202020200000|3C}}&lt;br /&gt;
 {{SREC HEX|1|1F|0000|7C0802A6900100049421FFF07C6C1B787C8C23783C60000038630000|26}}&lt;br /&gt;
 {{SREC HEX|1|1F|001C|4BFFFFE5398000007D83637880010014382100107C0803A64E800020|E9}}&lt;br /&gt;
 {{SREC HEX|1|11|0038|48656C6C6F20776F726C642E0A00|42}}&lt;br /&gt;
 {{SREC HEX|5|03|0003||F9}}&lt;br /&gt;
 {{SREC HEX|9|03|0000||FC}}&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Binary-to-text encoding]], a survey and comparison of encoding algorithms&lt;br /&gt;
* [[Intel hex format]]&lt;br /&gt;
* [[MOS Technology file format]]&lt;br /&gt;
* [[Tektronix hex format]]&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://srecord.sourceforge.net/ SRecord] is a collection of tools for manipulating SREC format files.&lt;br /&gt;
* [http://www.keil.com/download/docs/4.asp BIN2MOT], BINARY to Motorola S-Record file converter utility.&lt;br /&gt;
* [https://github.com/BigWinston/SRecordizer/wiki SRecordizer] is a tool for viewing, editing, and error checking S19 format files.&lt;br /&gt;
* [https://pypi.python.org/pypi/bincopy bincopy] is a Python package for manipulating SREC format files.&lt;br /&gt;
* [https://github.com/arkku/srec kk_srec] is a C library and program for reading the SREC format.&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=660</id>
		<title>SREC (file format)</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=660"/>
		<updated>2021-04-26T10:53:19Z</updated>

		<summary type="html">&lt;p&gt;Darren: /* External links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Motorola S-record&#039;&#039;&#039; is a file format, created by [[Motorola]], that conveys binary information as [[hexadecimal|hex]] values in [[ASCII]] text form. This file format may also be known as &#039;&#039;&#039;SRECORD&#039;&#039;&#039;, &#039;&#039;&#039;SREC&#039;&#039;&#039;, &#039;&#039;&#039;S19&#039;&#039;&#039;, &#039;&#039;&#039;S28&#039;&#039;&#039;, &#039;&#039;&#039;S37&#039;&#039;&#039;. It is commonly used for programming [[flash memory]] in microcontrollers, [[EPROM]]s, [[EEPROM]]s, and other types of programmable logic devices. In a typical application, a compiler or assembler converts a program&#039;s source code (such as C or assembly language) to machine code and outputs it into a HEX file. The HEX file is then imported by a programmer to &amp;quot;burn&amp;quot; the machine code into [[non-volatile memory]], or is transferred to the target system for loading and execution.&lt;br /&gt;
[[File:Motorola SREC Chart.png|thumb|A quick reference chart for the Motorola SREC format. (Note that in the record example image the word &amp;quot;bytes&amp;quot; is alternatively used to specify characters.)&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename extension&lt;br /&gt;
|&amp;lt;code&amp;gt;.s19&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s28&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s37&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.sx&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.srec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.exo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mxt&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Developed by&lt;br /&gt;
|Motorola&lt;br /&gt;
|}&lt;br /&gt;
]]&lt;br /&gt;
==Overview==&lt;br /&gt;
===History===&lt;br /&gt;
The S-record format was created in the mid-1970s for the [[Motorola 6800]] processor. [[Programming tool|Software development tools]] for that and other [[embedded processor]]s would make executable code and data in the S-record format. PROM programmers would then read the S-record format and &amp;quot;burn&amp;quot; the data into the PROMs or EPROMs used in the embedded system.&lt;br /&gt;
===Other hex formats===&lt;br /&gt;
There are other ASCII encoding with a similar purpose. [[BPNF]], [[BHLF]], and [[B10F]] were early binary formats, but they are neither compact nor flexible. Hexadecimal formats are more compact because they represent 4 bits rather than 1 bit per character. Many, such as S-record, are more flexible because they include address information so they can specify just a portion of a PROM. [[Intel HEX]] format was often used with Intel processors. [[TekHex]] is another hex format that can include a symbol table for debugging.&lt;br /&gt;
==Format==&lt;br /&gt;
===Record structure===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | S || style=&#039;background: #FFCCCC&#039; | Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
An SREC format file consists of a series of ASCII text records. The records have the following structure from left to right:&lt;br /&gt;
# &#039;&#039;Record start&#039;&#039; - each record begins with an uppercase letter &amp;quot;S&amp;quot; character (ASCII 0x53) which stands for &amp;quot;Start-of-Record&amp;quot;.&amp;lt;ref&amp;gt;{{cite book |title=MCM6830L7 MIKBUG / MINIBUG ROM |author-first1=Mike |author-last1=Wiles |author-first2=Andre |author-last2=Felix |editor-first=Michael |editor-last=Holley |date=2000-10-21 |orig-year=1975 |type=Engineering note |id=Note 100 |publisher=[[Motorola Semiconductor Products, Inc.]] |url=http://www.swtpc.com/mholley/MP_A/MikbugEn100.pdf |access-date=2019-06-16 |url-status=dead |archive-url=https://web.archive.org/web/20190616115550/http://www.swtpc.com/mholley/MP_A/MikbugEn100.pdf |archive-date=2019-06-16}} (23 pages)&amp;lt;/ref&amp;gt;&lt;br /&gt;
# &#039;&#039;Record type&#039;&#039; - single numeric digit &amp;quot;0&amp;quot; to &amp;quot;9&amp;quot;, defining the type of record.&lt;br /&gt;
# &#039;&#039;Byte count&#039;&#039; - two hex digits, indicating the number of bytes (hex digit pairs) that follow in the rest of the record (address + data + checksum). This field has a minimum value of 3 for 16-bit address field plus 1 checksum byte, and a maximum value of 255 (0xFF).&lt;br /&gt;
# &#039;&#039;Address&#039;&#039; - four / six / eight hex digits as determined by the record type. The address bytes are arranged in [[Endianness|big endian]] format.&lt;br /&gt;
# &#039;&#039;Data&#039;&#039; - a sequence of 2&#039;&#039;n&#039;&#039; hex digits, for &#039;&#039;n&#039;&#039; bytes of the data. For S1/S2/S3 records, a maximum of 32 bytes per record is typical since it will fit on an 80 character wide terminal screen, though 16 bytes would be easier to visually decode each byte at a specific address.&lt;br /&gt;
# &#039;&#039;Checksum&#039;&#039; - two hex digits, the [[least significant byte]] of [[ones&#039; complement]] of the sum of the values represented by the two hex digit pairs for the byte count, address and data fields. See example section for a detailed checksum example.&lt;br /&gt;
===Text line terminators===&lt;br /&gt;
SREC records are separated by one or more ASCII line termination characters so that each record appears alone on a text line. This enhances legibility by visually [[delimiter|delimiting]] the records and it also provides padding between records that can be used to improve machine [[parsing]] efficiency.&lt;br /&gt;
&lt;br /&gt;
Programs that create HEX records typically use line termination characters that conform to the conventions of their [[operating system]]s. For example, Linux programs use a single LF character ([[Newline|line feed]], 0x0A as ASCII character value) character to terminate lines, whereas Windows programs use a CR character ([[carriage return]], 0x0D as ASCII character value) followed by a LF character.&lt;br /&gt;
===Record types===&lt;br /&gt;
The following table describes 10 possible S-records. S4 is reserved and not currently defined. S6 was originally reserved but was later redefined.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Record&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;purpose&lt;br /&gt;
! Address&amp;lt;br&amp;gt;field&lt;br /&gt;
! Data&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;description&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S0&#039;&#039;&lt;br /&gt;
| Header&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;&amp;quot;0000&amp;quot;&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains vendor specific ASCII text comment represented as a series of hex digit pairs. It is common to see the data for this record in the format of a [[null-terminated string]]. The text data can be anything including a mixture of the following information: file/module name, version/revision number, date/time, product name, vendor name, memory designator on PCB, copyright notice. It is common to see: 48 44 52 which is the ASCII H, D, and R - &amp;quot;HDR&amp;quot;.&amp;lt;ref name=&amp;quot;Tareski_2018&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S1&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at the 16-bit address field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is typically used for 8-bit microcontrollers, such as AVR, PIC, 8051, 68xx, 6502, 80xx, Z80. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 3 (that is, 2 bytes for &amp;quot;16-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S2&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 24-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 4 (that is, 3 bytes for &amp;quot;24-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S3&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 32-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is typically used for 32-bit microcontrollers, such as ARM and 680x0. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 5 (that is, 4 bytes for &amp;quot;32-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S4&#039;&#039;&lt;br /&gt;
| Reserved&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| This record is reserved.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S5&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 16-bit count of S1/S2/S3 records.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is used if the record count is less than or equal to 65,535 (0xFFFF), otherwise S6 record would be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S6&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 24-bit count of S1/S2/S3 records. This record is used if the record count is less than or equal to 16,777,215 (0xFFFFFF). If less than 65,536 (0x10000), then S5 record would be used. &#039;&#039;&#039;NOTE:&#039;&#039;&#039; This newer record is the most recent change (it may not be official).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S7&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 32-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S3 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S8&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 24-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S2 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S9&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 16-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S1 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|}&lt;br /&gt;
===Record order===&lt;br /&gt;
Although some Unix documentation states &amp;quot;the order of S-records within a file is of no significance and no particular order may be assumed&amp;quot;,&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; in practice most software has ordered the SREC records. The typical record order starts with a (sometimes optional) S0 header record, continues with a sequence of one or more S1/S2/S3 data records, may have one optional S5/S6 count record, and ends with one appropriate S7/S8/S9 termination record.&lt;br /&gt;
; S19-style 16-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S1 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S9&lt;br /&gt;
; S28-style 24-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S2 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S8&lt;br /&gt;
; S37-style 32-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S3 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S7&lt;br /&gt;
===Limitations===&lt;br /&gt;
&#039;&#039;Record length&#039;&#039; - Unix manual page documentation states, &amp;quot;An S-record file consists of a sequence of specially formatted ASCII character strings. An S-record will be less than or equal to 78 bytes in length&amp;quot;. The manual page further limits the number of characters in the data field to 64 (or 32 data bytes).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; A record with an 8-hex-character address and 64 data characters would be 78 (2 + 2 + 8 + 64 + 2) characters long (this count ignores possible end-of-line or string termination characters). The file could be printed on an 80-character wide teleprinter. A note at the bottom of the manual page states, &amp;quot;This [manual page] is the only place that a 78-byte limit on total record length or 64-byte limit on data length is documented. These values shouldn&#039;t be trusted for the general case&amp;quot;.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; If that limitation is ignored, the maximum length of an S-record is 514 characters: 2 for Record Type field + 2 for Byte Count field (whose value would be 0xFF=255) + 2 * 255 for Address, Data, and Checksum fields. Additional buffer space may be required for the line and string terminators. Using long line lengths has problems: &amp;quot;The Motorola S-record format definition permits up to 255 bytes of payload, or lines of 514 characters, plus the line termination. All EPROM programmers should have sufficiently large line buffers to cope with records this big. Few do.&amp;quot;&amp;lt;ref name=&amp;quot;sf&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Data field&#039;&#039; - Some documentation recommends a maximum of 32 bytes of data (64 hex characters) in this field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The minimum amount of data for S0/S1/S2/S3 records is zero. The maximum amount of data varies depending on the size of the address field. Since the Byte Count field can&#039;t be higher than 255 (0xFF), then the maximum number of bytes of data is calculated by 255 minus (1 byte for checksum field) minus (number of bytes in the address field). S0/S1 records support up to 252 bytes of data. S2 record supports up to 251 bytes of data. S3 record supports up to 250 bytes of data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Comments&#039;&#039; - The SREC file format does not support comments. Some software ignores all text lines that do not start with &amp;quot;S&amp;quot; and ignores all text after the checksum field; that extra text is sometimes used (incompatibly) for comments. For example, the CCS PIC compiler supports placing a &amp;quot;;&amp;quot; comment line at the top or bottom of an [[Intel HEX]] file, and its manuals states &amp;quot;some programmers (MPLAB in particular) do not like comments at the top of the hex file&amp;quot;, which is why the compiler has the option of placing the comment at the bottom of the hex file.&amp;lt;ref name=&amp;quot;CCS_2014&amp;quot;/&amp;gt;&lt;br /&gt;
==Examples==&lt;br /&gt;
; Color legend&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | Record Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
===Checksum calculation===&lt;br /&gt;
The following example record:&lt;br /&gt;
 {{SREC HEX|1|13|7AF0|0A0A0D00000000000000000000000000|61}}&lt;br /&gt;
is decoded to show how the checksum value is calculated as follows:&lt;br /&gt;
# Add: Add each byte 0x13 + 0x7A + 0xF0 + 0x0A + 0x0A + 0x0D + 0x00 + ... + 0x00 = 0x19E total.&lt;br /&gt;
# Mask: Keep the least significant byte of the total = 0x9E.&lt;br /&gt;
# Complement: Compute [[ones&#039; complement]] of least significant byte = 0x61.&lt;br /&gt;
===16-bit memory address===&lt;br /&gt;
 {{SREC HEX|0|0F|0000|68656C6C6F20202020200000|3C}}&lt;br /&gt;
 {{SREC HEX|1|1F|0000|7C0802A6900100049421FFF07C6C1B787C8C23783C60000038630000|26}}&lt;br /&gt;
 {{SREC HEX|1|1F|001C|4BFFFFE5398000007D83637880010014382100107C0803A64E800020|E9}}&lt;br /&gt;
 {{SREC HEX|1|11|0038|48656C6C6F20776F726C642E0A00|42}}&lt;br /&gt;
 {{SREC HEX|5|03|0003||F9}}&lt;br /&gt;
 {{SREC HEX|9|03|0000||FC}}&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Binary-to-text encoding]], a survey and comparison of encoding algorithms&lt;br /&gt;
* [[Intel hex format]]&lt;br /&gt;
* [[MOS Technology file format]]&lt;br /&gt;
* [[Tektronix hex format]]&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://srecord.sourceforge.net/ SRecord] is a collection of tools for manipulating SREC format files.&lt;br /&gt;
* [http://www.keil.com/download/docs/4.asp BIN2MOT], BINARY to Motorola S-Record file converter utility.&lt;br /&gt;
* [https://github.com/BigWinston/SRecordizer/wiki SRecordizer] is a tool for viewing, editing, and error checking S19 format files.&lt;br /&gt;
* [https://pypi.python.org/pypi/bincopy bincopy] is a Python package for manipulating SREC format files.&lt;br /&gt;
* [https://github.com/arkku/srec kk_srec] is a C library and program for reading the SREC format.&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=659</id>
		<title>SREC (file format)</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=659"/>
		<updated>2021-04-26T10:51:52Z</updated>

		<summary type="html">&lt;p&gt;Darren: /* External links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Motorola S-record&#039;&#039;&#039; is a file format, created by [[Motorola]], that conveys binary information as [[hexadecimal|hex]] values in [[ASCII]] text form. This file format may also be known as &#039;&#039;&#039;SRECORD&#039;&#039;&#039;, &#039;&#039;&#039;SREC&#039;&#039;&#039;, &#039;&#039;&#039;S19&#039;&#039;&#039;, &#039;&#039;&#039;S28&#039;&#039;&#039;, &#039;&#039;&#039;S37&#039;&#039;&#039;. It is commonly used for programming [[flash memory]] in microcontrollers, [[EPROM]]s, [[EEPROM]]s, and other types of programmable logic devices. In a typical application, a compiler or assembler converts a program&#039;s source code (such as C or assembly language) to machine code and outputs it into a HEX file. The HEX file is then imported by a programmer to &amp;quot;burn&amp;quot; the machine code into [[non-volatile memory]], or is transferred to the target system for loading and execution.&lt;br /&gt;
[[File:Motorola SREC Chart.png|thumb|A quick reference chart for the Motorola SREC format. (Note that in the record example image the word &amp;quot;bytes&amp;quot; is alternatively used to specify characters.)&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename extension&lt;br /&gt;
|&amp;lt;code&amp;gt;.s19&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s28&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s37&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.sx&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.srec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.exo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mxt&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Developed by&lt;br /&gt;
|Motorola&lt;br /&gt;
|}&lt;br /&gt;
]]&lt;br /&gt;
==Overview==&lt;br /&gt;
===History===&lt;br /&gt;
The S-record format was created in the mid-1970s for the [[Motorola 6800]] processor. [[Programming tool|Software development tools]] for that and other [[embedded processor]]s would make executable code and data in the S-record format. PROM programmers would then read the S-record format and &amp;quot;burn&amp;quot; the data into the PROMs or EPROMs used in the embedded system.&lt;br /&gt;
===Other hex formats===&lt;br /&gt;
There are other ASCII encoding with a similar purpose. [[BPNF]], [[BHLF]], and [[B10F]] were early binary formats, but they are neither compact nor flexible. Hexadecimal formats are more compact because they represent 4 bits rather than 1 bit per character. Many, such as S-record, are more flexible because they include address information so they can specify just a portion of a PROM. [[Intel HEX]] format was often used with Intel processors. [[TekHex]] is another hex format that can include a symbol table for debugging.&lt;br /&gt;
==Format==&lt;br /&gt;
===Record structure===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | S || style=&#039;background: #FFCCCC&#039; | Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
An SREC format file consists of a series of ASCII text records. The records have the following structure from left to right:&lt;br /&gt;
# &#039;&#039;Record start&#039;&#039; - each record begins with an uppercase letter &amp;quot;S&amp;quot; character (ASCII 0x53) which stands for &amp;quot;Start-of-Record&amp;quot;.&amp;lt;ref&amp;gt;{{cite book |title=MCM6830L7 MIKBUG / MINIBUG ROM |author-first1=Mike |author-last1=Wiles |author-first2=Andre |author-last2=Felix |editor-first=Michael |editor-last=Holley |date=2000-10-21 |orig-year=1975 |type=Engineering note |id=Note 100 |publisher=[[Motorola Semiconductor Products, Inc.]] |url=http://www.swtpc.com/mholley/MP_A/MikbugEn100.pdf |access-date=2019-06-16 |url-status=dead |archive-url=https://web.archive.org/web/20190616115550/http://www.swtpc.com/mholley/MP_A/MikbugEn100.pdf |archive-date=2019-06-16}} (23 pages)&amp;lt;/ref&amp;gt;&lt;br /&gt;
# &#039;&#039;Record type&#039;&#039; - single numeric digit &amp;quot;0&amp;quot; to &amp;quot;9&amp;quot;, defining the type of record.&lt;br /&gt;
# &#039;&#039;Byte count&#039;&#039; - two hex digits, indicating the number of bytes (hex digit pairs) that follow in the rest of the record (address + data + checksum). This field has a minimum value of 3 for 16-bit address field plus 1 checksum byte, and a maximum value of 255 (0xFF).&lt;br /&gt;
# &#039;&#039;Address&#039;&#039; - four / six / eight hex digits as determined by the record type. The address bytes are arranged in [[Endianness|big endian]] format.&lt;br /&gt;
# &#039;&#039;Data&#039;&#039; - a sequence of 2&#039;&#039;n&#039;&#039; hex digits, for &#039;&#039;n&#039;&#039; bytes of the data. For S1/S2/S3 records, a maximum of 32 bytes per record is typical since it will fit on an 80 character wide terminal screen, though 16 bytes would be easier to visually decode each byte at a specific address.&lt;br /&gt;
# &#039;&#039;Checksum&#039;&#039; - two hex digits, the [[least significant byte]] of [[ones&#039; complement]] of the sum of the values represented by the two hex digit pairs for the byte count, address and data fields. See example section for a detailed checksum example.&lt;br /&gt;
===Text line terminators===&lt;br /&gt;
SREC records are separated by one or more ASCII line termination characters so that each record appears alone on a text line. This enhances legibility by visually [[delimiter|delimiting]] the records and it also provides padding between records that can be used to improve machine [[parsing]] efficiency.&lt;br /&gt;
&lt;br /&gt;
Programs that create HEX records typically use line termination characters that conform to the conventions of their [[operating system]]s. For example, Linux programs use a single LF character ([[Newline|line feed]], 0x0A as ASCII character value) character to terminate lines, whereas Windows programs use a CR character ([[carriage return]], 0x0D as ASCII character value) followed by a LF character.&lt;br /&gt;
===Record types===&lt;br /&gt;
The following table describes 10 possible S-records. S4 is reserved and not currently defined. S6 was originally reserved but was later redefined.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Record&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;purpose&lt;br /&gt;
! Address&amp;lt;br&amp;gt;field&lt;br /&gt;
! Data&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;description&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S0&#039;&#039;&lt;br /&gt;
| Header&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;&amp;quot;0000&amp;quot;&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains vendor specific ASCII text comment represented as a series of hex digit pairs. It is common to see the data for this record in the format of a [[null-terminated string]]. The text data can be anything including a mixture of the following information: file/module name, version/revision number, date/time, product name, vendor name, memory designator on PCB, copyright notice. It is common to see: 48 44 52 which is the ASCII H, D, and R - &amp;quot;HDR&amp;quot;.&amp;lt;ref name=&amp;quot;Tareski_2018&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S1&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at the 16-bit address field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is typically used for 8-bit microcontrollers, such as AVR, PIC, 8051, 68xx, 6502, 80xx, Z80. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 3 (that is, 2 bytes for &amp;quot;16-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S2&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 24-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 4 (that is, 3 bytes for &amp;quot;24-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S3&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 32-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is typically used for 32-bit microcontrollers, such as ARM and 680x0. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 5 (that is, 4 bytes for &amp;quot;32-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S4&#039;&#039;&lt;br /&gt;
| Reserved&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| This record is reserved.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S5&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 16-bit count of S1/S2/S3 records.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is used if the record count is less than or equal to 65,535 (0xFFFF), otherwise S6 record would be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S6&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 24-bit count of S1/S2/S3 records. This record is used if the record count is less than or equal to 16,777,215 (0xFFFFFF). If less than 65,536 (0x10000), then S5 record would be used. &#039;&#039;&#039;NOTE:&#039;&#039;&#039; This newer record is the most recent change (it may not be official).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S7&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 32-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S3 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S8&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 24-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S2 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S9&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 16-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S1 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|}&lt;br /&gt;
===Record order===&lt;br /&gt;
Although some Unix documentation states &amp;quot;the order of S-records within a file is of no significance and no particular order may be assumed&amp;quot;,&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; in practice most software has ordered the SREC records. The typical record order starts with a (sometimes optional) S0 header record, continues with a sequence of one or more S1/S2/S3 data records, may have one optional S5/S6 count record, and ends with one appropriate S7/S8/S9 termination record.&lt;br /&gt;
; S19-style 16-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S1 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S9&lt;br /&gt;
; S28-style 24-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S2 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S8&lt;br /&gt;
; S37-style 32-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S3 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S7&lt;br /&gt;
===Limitations===&lt;br /&gt;
&#039;&#039;Record length&#039;&#039; - Unix manual page documentation states, &amp;quot;An S-record file consists of a sequence of specially formatted ASCII character strings. An S-record will be less than or equal to 78 bytes in length&amp;quot;. The manual page further limits the number of characters in the data field to 64 (or 32 data bytes).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; A record with an 8-hex-character address and 64 data characters would be 78 (2 + 2 + 8 + 64 + 2) characters long (this count ignores possible end-of-line or string termination characters). The file could be printed on an 80-character wide teleprinter. A note at the bottom of the manual page states, &amp;quot;This [manual page] is the only place that a 78-byte limit on total record length or 64-byte limit on data length is documented. These values shouldn&#039;t be trusted for the general case&amp;quot;.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; If that limitation is ignored, the maximum length of an S-record is 514 characters: 2 for Record Type field + 2 for Byte Count field (whose value would be 0xFF=255) + 2 * 255 for Address, Data, and Checksum fields. Additional buffer space may be required for the line and string terminators. Using long line lengths has problems: &amp;quot;The Motorola S-record format definition permits up to 255 bytes of payload, or lines of 514 characters, plus the line termination. All EPROM programmers should have sufficiently large line buffers to cope with records this big. Few do.&amp;quot;&amp;lt;ref name=&amp;quot;sf&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Data field&#039;&#039; - Some documentation recommends a maximum of 32 bytes of data (64 hex characters) in this field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The minimum amount of data for S0/S1/S2/S3 records is zero. The maximum amount of data varies depending on the size of the address field. Since the Byte Count field can&#039;t be higher than 255 (0xFF), then the maximum number of bytes of data is calculated by 255 minus (1 byte for checksum field) minus (number of bytes in the address field). S0/S1 records support up to 252 bytes of data. S2 record supports up to 251 bytes of data. S3 record supports up to 250 bytes of data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Comments&#039;&#039; - The SREC file format does not support comments. Some software ignores all text lines that do not start with &amp;quot;S&amp;quot; and ignores all text after the checksum field; that extra text is sometimes used (incompatibly) for comments. For example, the CCS PIC compiler supports placing a &amp;quot;;&amp;quot; comment line at the top or bottom of an [[Intel HEX]] file, and its manuals states &amp;quot;some programmers (MPLAB in particular) do not like comments at the top of the hex file&amp;quot;, which is why the compiler has the option of placing the comment at the bottom of the hex file.&amp;lt;ref name=&amp;quot;CCS_2014&amp;quot;/&amp;gt;&lt;br /&gt;
==Examples==&lt;br /&gt;
; Color legend&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | Record Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Checksum calculation===&lt;br /&gt;
The following example record:&lt;br /&gt;
 {{SREC HEX|1|13|7AF0|0A0A0D00000000000000000000000000|61}}&lt;br /&gt;
is decoded to show how the checksum value is calculated as follows:&lt;br /&gt;
# Add: Add each byte 0x13 + 0x7A + 0xF0 + 0x0A + 0x0A + 0x0D + 0x00 + ... + 0x00 = 0x19E total.&lt;br /&gt;
# Mask: Keep the least significant byte of the total = 0x9E.&lt;br /&gt;
# Complement: Compute [[ones&#039; complement]] of least significant byte = 0x61.&lt;br /&gt;
===16-bit memory address===&lt;br /&gt;
 {{SREC HEX|0|0F|0000|68656C6C6F20202020200000|3C}}&lt;br /&gt;
 {{SREC HEX|1|1F|0000|7C0802A6900100049421FFF07C6C1B787C8C23783C60000038630000|26}}&lt;br /&gt;
 {{SREC HEX|1|1F|001C|4BFFFFE5398000007D83637880010014382100107C0803A64E800020|E9}}&lt;br /&gt;
 {{SREC HEX|1|11|0038|48656C6C6F20776F726C642E0A00|42}}&lt;br /&gt;
 {{SREC HEX|5|03|0003||F9}}&lt;br /&gt;
 {{SREC HEX|9|03|0000||FC}}&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Binary-to-text encoding]], a survey and comparison of encoding algorithms&lt;br /&gt;
* [[Intel hex format]]&lt;br /&gt;
* [[MOS Technology file format]]&lt;br /&gt;
* [[Tektronix hex format]]&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://srecord.sourceforge.net/ SRecord] is a collection of tools for manipulating SREC format files.&lt;br /&gt;
* [http://www.keil.com/download/docs/4.asp BIN2MOT], BINARY to Motorola S-Record file converter utility.&lt;br /&gt;
* [https://github.com/BigWinston/SRecordizer/wiki SRecordizer] is a tool for viewing, editing, and error checking S19 format files.&lt;br /&gt;
* [https://pypi.python.org/pypi/bincopy bincopy] is a Python package for manipulating SREC format files.&lt;br /&gt;
* [https://github.com/arkku/srec kk_srec] is a C library and program for reading the SREC format.&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=658</id>
		<title>SREC (file format)</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=658"/>
		<updated>2021-04-26T10:50:52Z</updated>

		<summary type="html">&lt;p&gt;Darren: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Motorola S-record&#039;&#039;&#039; is a file format, created by [[Motorola]], that conveys binary information as [[hexadecimal|hex]] values in [[ASCII]] text form. This file format may also be known as &#039;&#039;&#039;SRECORD&#039;&#039;&#039;, &#039;&#039;&#039;SREC&#039;&#039;&#039;, &#039;&#039;&#039;S19&#039;&#039;&#039;, &#039;&#039;&#039;S28&#039;&#039;&#039;, &#039;&#039;&#039;S37&#039;&#039;&#039;. It is commonly used for programming [[flash memory]] in microcontrollers, [[EPROM]]s, [[EEPROM]]s, and other types of programmable logic devices. In a typical application, a compiler or assembler converts a program&#039;s source code (such as C or assembly language) to machine code and outputs it into a HEX file. The HEX file is then imported by a programmer to &amp;quot;burn&amp;quot; the machine code into [[non-volatile memory]], or is transferred to the target system for loading and execution.&lt;br /&gt;
[[File:Motorola SREC Chart.png|thumb|A quick reference chart for the Motorola SREC format. (Note that in the record example image the word &amp;quot;bytes&amp;quot; is alternatively used to specify characters.)&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename extension&lt;br /&gt;
|&amp;lt;code&amp;gt;.s19&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s28&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s37&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.sx&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.srec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.exo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mxt&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Developed by&lt;br /&gt;
|Motorola&lt;br /&gt;
|}&lt;br /&gt;
]]&lt;br /&gt;
==Overview==&lt;br /&gt;
===History===&lt;br /&gt;
The S-record format was created in the mid-1970s for the [[Motorola 6800]] processor. [[Programming tool|Software development tools]] for that and other [[embedded processor]]s would make executable code and data in the S-record format. PROM programmers would then read the S-record format and &amp;quot;burn&amp;quot; the data into the PROMs or EPROMs used in the embedded system.&lt;br /&gt;
===Other hex formats===&lt;br /&gt;
There are other ASCII encoding with a similar purpose. [[BPNF]], [[BHLF]], and [[B10F]] were early binary formats, but they are neither compact nor flexible. Hexadecimal formats are more compact because they represent 4 bits rather than 1 bit per character. Many, such as S-record, are more flexible because they include address information so they can specify just a portion of a PROM. [[Intel HEX]] format was often used with Intel processors. [[TekHex]] is another hex format that can include a symbol table for debugging.&lt;br /&gt;
==Format==&lt;br /&gt;
===Record structure===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | S || style=&#039;background: #FFCCCC&#039; | Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
An SREC format file consists of a series of ASCII text records. The records have the following structure from left to right:&lt;br /&gt;
# &#039;&#039;Record start&#039;&#039; - each record begins with an uppercase letter &amp;quot;S&amp;quot; character (ASCII 0x53) which stands for &amp;quot;Start-of-Record&amp;quot;.&amp;lt;ref&amp;gt;{{cite book |title=MCM6830L7 MIKBUG / MINIBUG ROM |author-first1=Mike |author-last1=Wiles |author-first2=Andre |author-last2=Felix |editor-first=Michael |editor-last=Holley |date=2000-10-21 |orig-year=1975 |type=Engineering note |id=Note 100 |publisher=[[Motorola Semiconductor Products, Inc.]] |url=http://www.swtpc.com/mholley/MP_A/MikbugEn100.pdf |access-date=2019-06-16 |url-status=dead |archive-url=https://web.archive.org/web/20190616115550/http://www.swtpc.com/mholley/MP_A/MikbugEn100.pdf |archive-date=2019-06-16}} (23 pages)&amp;lt;/ref&amp;gt;&lt;br /&gt;
# &#039;&#039;Record type&#039;&#039; - single numeric digit &amp;quot;0&amp;quot; to &amp;quot;9&amp;quot;, defining the type of record.&lt;br /&gt;
# &#039;&#039;Byte count&#039;&#039; - two hex digits, indicating the number of bytes (hex digit pairs) that follow in the rest of the record (address + data + checksum). This field has a minimum value of 3 for 16-bit address field plus 1 checksum byte, and a maximum value of 255 (0xFF).&lt;br /&gt;
# &#039;&#039;Address&#039;&#039; - four / six / eight hex digits as determined by the record type. The address bytes are arranged in [[Endianness|big endian]] format.&lt;br /&gt;
# &#039;&#039;Data&#039;&#039; - a sequence of 2&#039;&#039;n&#039;&#039; hex digits, for &#039;&#039;n&#039;&#039; bytes of the data. For S1/S2/S3 records, a maximum of 32 bytes per record is typical since it will fit on an 80 character wide terminal screen, though 16 bytes would be easier to visually decode each byte at a specific address.&lt;br /&gt;
# &#039;&#039;Checksum&#039;&#039; - two hex digits, the [[least significant byte]] of [[ones&#039; complement]] of the sum of the values represented by the two hex digit pairs for the byte count, address and data fields. See example section for a detailed checksum example.&lt;br /&gt;
===Text line terminators===&lt;br /&gt;
SREC records are separated by one or more ASCII line termination characters so that each record appears alone on a text line. This enhances legibility by visually [[delimiter|delimiting]] the records and it also provides padding between records that can be used to improve machine [[parsing]] efficiency.&lt;br /&gt;
&lt;br /&gt;
Programs that create HEX records typically use line termination characters that conform to the conventions of their [[operating system]]s. For example, Linux programs use a single LF character ([[Newline|line feed]], 0x0A as ASCII character value) character to terminate lines, whereas Windows programs use a CR character ([[carriage return]], 0x0D as ASCII character value) followed by a LF character.&lt;br /&gt;
===Record types===&lt;br /&gt;
The following table describes 10 possible S-records. S4 is reserved and not currently defined. S6 was originally reserved but was later redefined.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Record&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;purpose&lt;br /&gt;
! Address&amp;lt;br&amp;gt;field&lt;br /&gt;
! Data&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;description&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S0&#039;&#039;&lt;br /&gt;
| Header&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;&amp;quot;0000&amp;quot;&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains vendor specific ASCII text comment represented as a series of hex digit pairs. It is common to see the data for this record in the format of a [[null-terminated string]]. The text data can be anything including a mixture of the following information: file/module name, version/revision number, date/time, product name, vendor name, memory designator on PCB, copyright notice. It is common to see: 48 44 52 which is the ASCII H, D, and R - &amp;quot;HDR&amp;quot;.&amp;lt;ref name=&amp;quot;Tareski_2018&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S1&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at the 16-bit address field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is typically used for 8-bit microcontrollers, such as AVR, PIC, 8051, 68xx, 6502, 80xx, Z80. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 3 (that is, 2 bytes for &amp;quot;16-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S2&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 24-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 4 (that is, 3 bytes for &amp;quot;24-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S3&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 32-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is typically used for 32-bit microcontrollers, such as ARM and 680x0. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 5 (that is, 4 bytes for &amp;quot;32-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S4&#039;&#039;&lt;br /&gt;
| Reserved&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| This record is reserved.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S5&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 16-bit count of S1/S2/S3 records.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is used if the record count is less than or equal to 65,535 (0xFFFF), otherwise S6 record would be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S6&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 24-bit count of S1/S2/S3 records. This record is used if the record count is less than or equal to 16,777,215 (0xFFFFFF). If less than 65,536 (0x10000), then S5 record would be used. &#039;&#039;&#039;NOTE:&#039;&#039;&#039; This newer record is the most recent change (it may not be official).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S7&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 32-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S3 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S8&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 24-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S2 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S9&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 16-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S1 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|}&lt;br /&gt;
===Record order===&lt;br /&gt;
Although some Unix documentation states &amp;quot;the order of S-records within a file is of no significance and no particular order may be assumed&amp;quot;,&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; in practice most software has ordered the SREC records. The typical record order starts with a (sometimes optional) S0 header record, continues with a sequence of one or more S1/S2/S3 data records, may have one optional S5/S6 count record, and ends with one appropriate S7/S8/S9 termination record.&lt;br /&gt;
; S19-style 16-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S1 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S9&lt;br /&gt;
; S28-style 24-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S2 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S8&lt;br /&gt;
; S37-style 32-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S3 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S7&lt;br /&gt;
===Limitations===&lt;br /&gt;
&#039;&#039;Record length&#039;&#039; - Unix manual page documentation states, &amp;quot;An S-record file consists of a sequence of specially formatted ASCII character strings. An S-record will be less than or equal to 78 bytes in length&amp;quot;. The manual page further limits the number of characters in the data field to 64 (or 32 data bytes).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; A record with an 8-hex-character address and 64 data characters would be 78 (2 + 2 + 8 + 64 + 2) characters long (this count ignores possible end-of-line or string termination characters). The file could be printed on an 80-character wide teleprinter. A note at the bottom of the manual page states, &amp;quot;This [manual page] is the only place that a 78-byte limit on total record length or 64-byte limit on data length is documented. These values shouldn&#039;t be trusted for the general case&amp;quot;.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; If that limitation is ignored, the maximum length of an S-record is 514 characters: 2 for Record Type field + 2 for Byte Count field (whose value would be 0xFF=255) + 2 * 255 for Address, Data, and Checksum fields. Additional buffer space may be required for the line and string terminators. Using long line lengths has problems: &amp;quot;The Motorola S-record format definition permits up to 255 bytes of payload, or lines of 514 characters, plus the line termination. All EPROM programmers should have sufficiently large line buffers to cope with records this big. Few do.&amp;quot;&amp;lt;ref name=&amp;quot;sf&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Data field&#039;&#039; - Some documentation recommends a maximum of 32 bytes of data (64 hex characters) in this field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The minimum amount of data for S0/S1/S2/S3 records is zero. The maximum amount of data varies depending on the size of the address field. Since the Byte Count field can&#039;t be higher than 255 (0xFF), then the maximum number of bytes of data is calculated by 255 minus (1 byte for checksum field) minus (number of bytes in the address field). S0/S1 records support up to 252 bytes of data. S2 record supports up to 251 bytes of data. S3 record supports up to 250 bytes of data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Comments&#039;&#039; - The SREC file format does not support comments. Some software ignores all text lines that do not start with &amp;quot;S&amp;quot; and ignores all text after the checksum field; that extra text is sometimes used (incompatibly) for comments. For example, the CCS PIC compiler supports placing a &amp;quot;;&amp;quot; comment line at the top or bottom of an [[Intel HEX]] file, and its manuals states &amp;quot;some programmers (MPLAB in particular) do not like comments at the top of the hex file&amp;quot;, which is why the compiler has the option of placing the comment at the bottom of the hex file.&amp;lt;ref name=&amp;quot;CCS_2014&amp;quot;/&amp;gt;&lt;br /&gt;
==Examples==&lt;br /&gt;
; Color legend&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | Record Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Checksum calculation===&lt;br /&gt;
The following example record:&lt;br /&gt;
 {{SREC HEX|1|13|7AF0|0A0A0D00000000000000000000000000|61}}&lt;br /&gt;
is decoded to show how the checksum value is calculated as follows:&lt;br /&gt;
# Add: Add each byte 0x13 + 0x7A + 0xF0 + 0x0A + 0x0A + 0x0D + 0x00 + ... + 0x00 = 0x19E total.&lt;br /&gt;
# Mask: Keep the least significant byte of the total = 0x9E.&lt;br /&gt;
# Complement: Compute [[ones&#039; complement]] of least significant byte = 0x61.&lt;br /&gt;
===16-bit memory address===&lt;br /&gt;
 {{SREC HEX|0|0F|0000|68656C6C6F20202020200000|3C}}&lt;br /&gt;
 {{SREC HEX|1|1F|0000|7C0802A6900100049421FFF07C6C1B787C8C23783C60000038630000|26}}&lt;br /&gt;
 {{SREC HEX|1|1F|001C|4BFFFFE5398000007D83637880010014382100107C0803A64E800020|E9}}&lt;br /&gt;
 {{SREC HEX|1|11|0038|48656C6C6F20776F726C642E0A00|42}}&lt;br /&gt;
 {{SREC HEX|5|03|0003||F9}}&lt;br /&gt;
 {{SREC HEX|9|03|0000||FC}}&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Binary-to-text encoding]], a survey and comparison of encoding algorithms&lt;br /&gt;
* [[Intel hex format]]&lt;br /&gt;
* [[MOS Technology file format]]&lt;br /&gt;
* [[Tektronix hex format]]&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://srecord.sourceforge.net/ SRecord] is a collection of tools for manipulating SREC format files.&lt;br /&gt;
* [http://www.keil.com/download/docs/4.asp BIN2MOT], BINARY to Motorola S-Record file converter utility.&lt;br /&gt;
* [https://github.com/BigWinston/SRecordizer/wiki SRecordizer] is a tool for viewing, editing, and error checking S19 format files.&lt;br /&gt;
* [https://pypi.python.org/pypi/bincopy bincopy] is a Python package for manipulating SREC format files.&lt;br /&gt;
* [https://github.com/arkku/srec kk_srec] is a C library and program for reading the SREC format.&lt;br /&gt;
{{DEFAULTSORT:Srec (File Format)}}&lt;br /&gt;
[[Category:Binary-to-text encoding formats]]&lt;br /&gt;
[[Category:Embedded systems]]&lt;br /&gt;
[[Category:Computer file formats]]&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Yesno&amp;diff=657</id>
		<title>Module:Yesno</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Yesno&amp;diff=657"/>
		<updated>2021-04-26T10:44:14Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;-- Function allowing for consistent treatment of boolean-like wikitext input.&lt;br /&gt;
-- It works similarly to the template {{yesno}}.&lt;br /&gt;
&lt;br /&gt;
return function (val, default)&lt;br /&gt;
	-- If your wiki uses non-ascii characters for any of &amp;quot;yes&amp;quot;, &amp;quot;no&amp;quot;, etc., you&lt;br /&gt;
	-- should replace &amp;quot;val:lower()&amp;quot; with &amp;quot;mw.ustring.lower(val)&amp;quot; in the&lt;br /&gt;
	-- following line.&lt;br /&gt;
	val = type(val) == &#039;string&#039; and val:lower() or val&lt;br /&gt;
	if val == nil then&lt;br /&gt;
		return nil&lt;br /&gt;
	elseif val == true &lt;br /&gt;
		or val == &#039;yes&#039;&lt;br /&gt;
		or val == &#039;y&#039;&lt;br /&gt;
		or val == &#039;true&#039;&lt;br /&gt;
		or val == &#039;t&#039;&lt;br /&gt;
		or val == &#039;on&#039;&lt;br /&gt;
		or tonumber(val) == 1&lt;br /&gt;
	then&lt;br /&gt;
		return true&lt;br /&gt;
	elseif val == false&lt;br /&gt;
		or val == &#039;no&#039;&lt;br /&gt;
		or val == &#039;n&#039;&lt;br /&gt;
		or val == &#039;false&#039;&lt;br /&gt;
		or val == &#039;f&#039;&lt;br /&gt;
		or val == &#039;off&#039;&lt;br /&gt;
		or tonumber(val) == 0&lt;br /&gt;
	then&lt;br /&gt;
		return false&lt;br /&gt;
	else&lt;br /&gt;
		return default&lt;br /&gt;
	end&lt;br /&gt;
end&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Uses_TemplateStyles/config&amp;diff=655</id>
		<title>Module:Uses TemplateStyles/config</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Uses_TemplateStyles/config&amp;diff=655"/>
		<updated>2021-04-26T10:44:14Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local cfg = {} -- Don’t touch this line.&lt;br /&gt;
&lt;br /&gt;
-- Subpage blacklist: these subpages will not be categorized (except for the&lt;br /&gt;
-- error category, which is always added if there is an error).&lt;br /&gt;
-- For example “Template:Foo/doc” matches the `doc = true` rule, so it will have&lt;br /&gt;
-- no categories. “Template:Foo” and “Template:Foo/documentation” match no rules,&lt;br /&gt;
-- so they *will* have categories. All rules should be in the&lt;br /&gt;
--   [&#039;&amp;lt;subpage name&amp;gt;&#039;] = true,&lt;br /&gt;
-- format.&lt;br /&gt;
cfg[&#039;subpage_blacklist&#039;] = {&lt;br /&gt;
	[&#039;doc&#039;] = true,&lt;br /&gt;
	[&#039;sandbox&#039;] = true,&lt;br /&gt;
	[&#039;sandbox2&#039;] = true,&lt;br /&gt;
	[&#039;testcases&#039;] = true,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- Sandbox title: if the stylesheet’s title is &amp;lt;template&amp;gt;/&amp;lt;stylesheet&amp;gt;.css, the&lt;br /&gt;
-- stylesheet’s sandbox is expected to be at &amp;lt;template&amp;gt;/&amp;lt;sandbox_title&amp;gt;/&amp;lt;stylesheet&amp;gt;.css&lt;br /&gt;
-- Set to nil to disable sandbox links.&lt;br /&gt;
cfg[&#039;sandbox_title&#039;] = &#039;sandbox&#039;&lt;br /&gt;
&lt;br /&gt;
-- Error category: this category is added if the module call contains errors&lt;br /&gt;
-- (e.g. no stylesheet listed). A category name without namespace, or nil&lt;br /&gt;
-- to disable categorization (not recommended).&lt;br /&gt;
cfg[&#039;error_category&#039;] = &#039;Uses TemplateStyles templates with errors&#039;&lt;br /&gt;
&lt;br /&gt;
-- Default category: this category is added if no custom category is specified&lt;br /&gt;
-- in module/template call. A category name without namespace, or nil&lt;br /&gt;
-- to disable categorization.&lt;br /&gt;
cfg[&#039;default_category&#039;] = &#039;Templates using TemplateStyles&#039;&lt;br /&gt;
&lt;br /&gt;
-- Protection conflict category: this category is added if the protection level&lt;br /&gt;
-- of any stylesheet differs from the one of the template. A category name&lt;br /&gt;
-- without namespace, or nil to disable categorization (not recommended).&lt;br /&gt;
cfg[&#039;protection_conflict_category&#039;] = &#039;Templates using TemplateStyles with a different protection level&#039;&lt;br /&gt;
&lt;br /&gt;
-- Padlock pattern: Lua pattern to search on protected stylesheets for, or nil&lt;br /&gt;
-- to disable padlock check.&lt;br /&gt;
cfg[&#039;padlock_pattern&#039;] = &#039;{{pp-&#039;&lt;br /&gt;
&lt;br /&gt;
-- Missing padlock category: this category is added if a protected stylesheet&lt;br /&gt;
-- doesn’t contain any padlock template (specified by the above Lua pattern).&lt;br /&gt;
-- A category name without namespace (no nil allowed) if the pattern is not nil,&lt;br /&gt;
-- unused (and thus may be nil) otherwise.&lt;br /&gt;
cfg[&#039;missing_padlock_category&#039;] = &#039;Templates using TemplateStyles without padlocks&#039;&lt;br /&gt;
&lt;br /&gt;
return cfg -- Don’t touch this line.&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Uses_TemplateStyles&amp;diff=653</id>
		<title>Module:Uses TemplateStyles</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Uses_TemplateStyles&amp;diff=653"/>
		<updated>2021-04-26T10:44:14Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;-- This module implements the {{Uses TemplateStyles}} template.&lt;br /&gt;
local yesno = require(&#039;Module:Yesno&#039;)&lt;br /&gt;
local mList = require(&#039;Module:List&#039;)&lt;br /&gt;
local mTableTools = require(&#039;Module:TableTools&#039;)&lt;br /&gt;
local mMessageBox = require(&#039;Module:Message box&#039;)&lt;br /&gt;
local TNT = require(&#039;Module:TNT&#039;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local function format(msg, ...)&lt;br /&gt;
	return TNT.format(&#039;I18n/Uses TemplateStyles&#039;, msg, ...)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getConfig()&lt;br /&gt;
	return mw.loadData(&#039;Module:Uses TemplateStyles/config&#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local origArgs = frame:getParent().args&lt;br /&gt;
	local args = {}&lt;br /&gt;
	for k, v in pairs(origArgs) do&lt;br /&gt;
		v = v:match(&#039;^%s*(.-)%s*$&#039;)&lt;br /&gt;
		if v ~= &#039;&#039; then&lt;br /&gt;
			args[k] = v&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return p._main(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args, cfg)&lt;br /&gt;
	local tStyles = mTableTools.compressSparseArray(args)&lt;br /&gt;
	local box = p.renderBox(tStyles)&lt;br /&gt;
	local trackingCategories = p.renderTrackingCategories(args, tStyles)&lt;br /&gt;
	return box .. trackingCategories&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.renderBox(tStyles)&lt;br /&gt;
	local boxArgs = {}&lt;br /&gt;
	if #tStyles &amp;lt; 1 then&lt;br /&gt;
		boxArgs.text = string.format(&#039;&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;%s&amp;lt;/strong&amp;gt;&#039;, format(&#039;error-emptylist&#039;))&lt;br /&gt;
	else&lt;br /&gt;
		local cfg = getConfig()&lt;br /&gt;
		local tStylesLinks = {}&lt;br /&gt;
		for i, ts in ipairs(tStyles) do&lt;br /&gt;
			local link = string.format(&#039;[[:%s]]&#039;, ts)&lt;br /&gt;
			local sandboxLink = nil&lt;br /&gt;
			local tsTitle = mw.title.new(ts)&lt;br /&gt;
			if tsTitle and cfg[&#039;sandbox_title&#039;] then&lt;br /&gt;
				local tsSandboxTitle = mw.title.new(string.format(&lt;br /&gt;
					&#039;%s:%s/%s/%s&#039;, tsTitle.nsText, tsTitle.baseText, cfg[&#039;sandbox_title&#039;], tsTitle.subpageText))&lt;br /&gt;
				if tsSandboxTitle and tsSandboxTitle.exists then&lt;br /&gt;
					sandboxLink = format(&#039;sandboxlink&#039;, link, &#039;:&#039; .. tsSandboxTitle.prefixedText)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			tStylesLinks[i] = sandboxLink or link&lt;br /&gt;
		end&lt;br /&gt;
		local tStylesList = mList.makeList(&#039;bulleted&#039;, tStylesLinks)&lt;br /&gt;
		boxArgs.text = format(&lt;br /&gt;
			mw.title.getCurrentTitle():inNamespaces(828,829) and &#039;header-module&#039; or &#039;header-template&#039;) ..&lt;br /&gt;
			&#039;\n&#039; .. tStylesList&lt;br /&gt;
	end&lt;br /&gt;
	boxArgs.type = &#039;notice&#039;&lt;br /&gt;
	boxArgs.small = true&lt;br /&gt;
	boxArgs.image = string.format(&#039;[[File:Farm-Fresh css add.svg|32px|alt=%s]]&#039;, format(&#039;logo-alt&#039;))&lt;br /&gt;
	return mMessageBox.main(&#039;mbox&#039;, boxArgs)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.renderTrackingCategories(args, tStyles, titleObj)&lt;br /&gt;
	if yesno(args.nocat) then&lt;br /&gt;
		return &#039;&#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local cfg = getConfig()&lt;br /&gt;
	&lt;br /&gt;
	local cats = {}&lt;br /&gt;
	&lt;br /&gt;
	-- Error category&lt;br /&gt;
	if #tStyles &amp;lt; 1 and cfg[&#039;error_category&#039;] then&lt;br /&gt;
		cats[#cats + 1] = cfg[&#039;error_category&#039;]&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- TemplateStyles category&lt;br /&gt;
	titleObj = titleObj or mw.title.getCurrentTitle()&lt;br /&gt;
	if (titleObj.namespace == 10 or titleObj.namespace == 828)&lt;br /&gt;
		and not cfg[&#039;subpage_blacklist&#039;][titleObj.subpageText]&lt;br /&gt;
	then&lt;br /&gt;
		local category = args.category or cfg[&#039;default_category&#039;]&lt;br /&gt;
		if category then&lt;br /&gt;
			cats[#cats + 1] = category&lt;br /&gt;
		end&lt;br /&gt;
		if not yesno(args.noprotcat) and (cfg[&#039;protection_conflict_category&#039;] or cfg[&#039;padlock_pattern&#039;]) then&lt;br /&gt;
			local currentProt = titleObj.protectionLevels[&amp;quot;edit&amp;quot;] and titleObj.protectionLevels[&amp;quot;edit&amp;quot;][1] or nil&lt;br /&gt;
			local addedLevelCat = false&lt;br /&gt;
			local addedPadlockCat = false&lt;br /&gt;
			for i, ts in ipairs(tStyles) do&lt;br /&gt;
				local tsTitleObj = mw.title.new(ts)&lt;br /&gt;
				local tsProt = tsTitleObj.protectionLevels[&amp;quot;edit&amp;quot;] and tsTitleObj.protectionLevels[&amp;quot;edit&amp;quot;][1] or nil&lt;br /&gt;
				if cfg[&#039;protection_conflict_category&#039;] and tsProt ~= currentProt and not addedLevelCat then&lt;br /&gt;
					addedLevelCat = true&lt;br /&gt;
					cats[#cats + 1] = cfg[&#039;protection_conflict_category&#039;]&lt;br /&gt;
				end&lt;br /&gt;
				if cfg[&#039;padlock_pattern&#039;] and tsProt and not addedPadlockCat then&lt;br /&gt;
					local content = tsTitleObj:getContent()&lt;br /&gt;
					if not content:find(cfg[&#039;padlock_pattern&#039;]) then&lt;br /&gt;
						cats[#cats + 1] = cfg[&#039;missing_padlock_category&#039;]&lt;br /&gt;
						addedPadlockCat = true&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	for i, cat in ipairs(cats) do&lt;br /&gt;
		cats[i] = string.format(&#039;[[Category:%s]]&#039;, cat)&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(cats)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Transclusion_count/data/C&amp;diff=651</id>
		<title>Module:Transclusion count/data/C</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Transclusion_count/data/C&amp;diff=651"/>
		<updated>2021-04-26T10:44:14Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;return {&lt;br /&gt;
[&amp;quot;C&amp;quot;] = 544000,&lt;br /&gt;
[&amp;quot;C-Class&amp;quot;] = 65000,&lt;br /&gt;
[&amp;quot;C-SPAN&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;C-cmn&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;C-pl&amp;quot;] = 53000,&lt;br /&gt;
[&amp;quot;CAN&amp;quot;] = 19000,&lt;br /&gt;
[&amp;quot;CANelec&amp;quot;] = 9000,&lt;br /&gt;
[&amp;quot;CANelec/hold&amp;quot;] = 3200,&lt;br /&gt;
[&amp;quot;CANelec/source&amp;quot;] = 5200,&lt;br /&gt;
[&amp;quot;CANelec/top&amp;quot;] = 5200,&lt;br /&gt;
[&amp;quot;CANelec/total&amp;quot;] = 5200,&lt;br /&gt;
[&amp;quot;CAS&amp;quot;] = 3800,&lt;br /&gt;
[&amp;quot;CBB_Standings_End&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;CBB_Standings_Entry&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;CBB_Standings_Start&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;CBB_Yearly_Record_End&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;CBB_Yearly_Record_Entry&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;CBB_Yearly_Record_Start&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;CBB_Yearly_Record_Subhead&amp;quot;] = 3500,&lt;br /&gt;
[&amp;quot;CBB_Yearly_Record_Subtotal&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;CBB_roster/Footer&amp;quot;] = 5800,&lt;br /&gt;
[&amp;quot;CBB_roster/Header&amp;quot;] = 5800,&lt;br /&gt;
[&amp;quot;CBB_roster/Player&amp;quot;] = 5800,&lt;br /&gt;
[&amp;quot;CBB_schedule_end&amp;quot;] = 8300,&lt;br /&gt;
[&amp;quot;CBB_schedule_entry&amp;quot;] = 8400,&lt;br /&gt;
[&amp;quot;CBB_schedule_start&amp;quot;] = 8400,&lt;br /&gt;
[&amp;quot;CBB_yearly_record_end&amp;quot;] = 3500,&lt;br /&gt;
[&amp;quot;CBB_yearly_record_end/legend&amp;quot;] = 3100,&lt;br /&gt;
[&amp;quot;CBB_yearly_record_entry&amp;quot;] = 3500,&lt;br /&gt;
[&amp;quot;CBB_yearly_record_start&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;CBB_yearly_record_subhead&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;CBB_yearly_record_subtotal&amp;quot;] = 3300,&lt;br /&gt;
[&amp;quot;CBSB_Standings_End&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;CBSB_Standings_Entry&amp;quot;] = 3500,&lt;br /&gt;
[&amp;quot;CBSB_Standings_Start&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;CBSB_link&amp;quot;] = 2900,&lt;br /&gt;
[&amp;quot;CC0&amp;quot;] = 5800,&lt;br /&gt;
[&amp;quot;CENTURY&amp;quot;] = 16000,&lt;br /&gt;
[&amp;quot;CFB_Standings_End&amp;quot;] = 28000,&lt;br /&gt;
[&amp;quot;CFB_Standings_Entry&amp;quot;] = 28000,&lt;br /&gt;
[&amp;quot;CFB_Standings_Start&amp;quot;] = 28000,&lt;br /&gt;
[&amp;quot;CFB_Yearly_Record_End&amp;quot;] = 6100,&lt;br /&gt;
[&amp;quot;CFB_Yearly_Record_End/legend&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;CFB_Yearly_Record_Entry&amp;quot;] = 6100,&lt;br /&gt;
[&amp;quot;CFB_Yearly_Record_Start&amp;quot;] = 6100,&lt;br /&gt;
[&amp;quot;CFB_Yearly_Record_Subhead&amp;quot;] = 6100,&lt;br /&gt;
[&amp;quot;CFB_Yearly_Record_Subtotal&amp;quot;] = 6000,&lt;br /&gt;
[&amp;quot;CFB_schedule&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;CFB_schedule_entry&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;CFL_Year&amp;quot;] = 5000,&lt;br /&gt;
[&amp;quot;CGF_year&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;CHE&amp;quot;] = 9600,&lt;br /&gt;
[&amp;quot;CHI&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;CHL&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;CHN&amp;quot;] = 10000,&lt;br /&gt;
[&amp;quot;COI&amp;quot;] = 14000,&lt;br /&gt;
[&amp;quot;COIUL&amp;quot;] = 118000,&lt;br /&gt;
[&amp;quot;COI_editnotice&amp;quot;] = 5700,&lt;br /&gt;
[&amp;quot;COL&amp;quot;] = 4400,&lt;br /&gt;
[&amp;quot;COLON&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;CRO&amp;quot;] = 3700,&lt;br /&gt;
[&amp;quot;CSK&amp;quot;] = 2900,&lt;br /&gt;
[&amp;quot;CSS_image_crop&amp;quot;] = 3100,&lt;br /&gt;
[&amp;quot;CUB&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;CURRENTDATE&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;CURRENTMINUTE&amp;quot;] = 2900,&lt;br /&gt;
[&amp;quot;CZE&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Calendar&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;California/color&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Call_sign_disambiguation&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Campaignbox&amp;quot;] = 20000,&lt;br /&gt;
[&amp;quot;CanadaByProvinceCatNav&amp;quot;] = 9300,&lt;br /&gt;
[&amp;quot;CanadaProvinceThe&amp;quot;] = 3900,&lt;br /&gt;
[&amp;quot;Canadian_English&amp;quot;] = 4400,&lt;br /&gt;
[&amp;quot;Canadian_Parliament_links&amp;quot;] = 4900,&lt;br /&gt;
[&amp;quot;Canadian_election_result&amp;quot;] = 9000,&lt;br /&gt;
[&amp;quot;Canadian_election_result/hold&amp;quot;] = 3200,&lt;br /&gt;
[&amp;quot;Canadian_election_result/source&amp;quot;] = 6100,&lt;br /&gt;
[&amp;quot;Canadian_election_result/top&amp;quot;] = 8500,&lt;br /&gt;
[&amp;quot;Canadian_election_result/top/ElectionYearTest&amp;quot;] = 4300,&lt;br /&gt;
[&amp;quot;Canadian_election_result/total&amp;quot;] = 7300,&lt;br /&gt;
[&amp;quot;Canadian_party_colour&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Canadian_party_colour/colour&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Canadian_party_colour/colour/default&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Canadian_party_colour/name&amp;quot;] = 9900,&lt;br /&gt;
[&amp;quot;Canadian_party_colour/name/default&amp;quot;] = 4700,&lt;br /&gt;
[&amp;quot;Canned_search&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Cascite&amp;quot;] = 14000,&lt;br /&gt;
[&amp;quot;Caselaw_source&amp;quot;] = 3800,&lt;br /&gt;
[&amp;quot;Cast_listing&amp;quot;] = 7000,&lt;br /&gt;
[&amp;quot;Cat&amp;quot;] = 246000,&lt;br /&gt;
[&amp;quot;CatAutoTOC&amp;quot;] = 597000,&lt;br /&gt;
[&amp;quot;CatAutoTOC/core&amp;quot;] = 596000,&lt;br /&gt;
[&amp;quot;CatRel&amp;quot;] = 3800,&lt;br /&gt;
[&amp;quot;CatTrack&amp;quot;] = 3100,&lt;br /&gt;
[&amp;quot;Cat_class&amp;quot;] = 7100,&lt;br /&gt;
[&amp;quot;Cat_in_use&amp;quot;] = 56000,&lt;br /&gt;
[&amp;quot;Cat_main&amp;quot;] = 164000,&lt;br /&gt;
[&amp;quot;Cat_more&amp;quot;] = 111000,&lt;br /&gt;
[&amp;quot;Cat_more_if_exists&amp;quot;] = 40000,&lt;br /&gt;
[&amp;quot;Cat_see_also&amp;quot;] = 3100,&lt;br /&gt;
[&amp;quot;Catalog_lookup_link&amp;quot;] = 476000,&lt;br /&gt;
[&amp;quot;Category&amp;quot;] = 153000,&lt;br /&gt;
[&amp;quot;Category-Class&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Category-inline&amp;quot;] = 6700,&lt;br /&gt;
[&amp;quot;Category_TOC&amp;quot;] = 69000,&lt;br /&gt;
[&amp;quot;Category_TOC/tracking&amp;quot;] = 69000,&lt;br /&gt;
[&amp;quot;Category_U.S._State_elections_by_year&amp;quot;] = 7000,&lt;br /&gt;
[&amp;quot;Category_U.S._State_elections_by_year/core&amp;quot;] = 7000,&lt;br /&gt;
[&amp;quot;Category_class&amp;quot;] = 40000,&lt;br /&gt;
[&amp;quot;Category_class/column&amp;quot;] = 40000,&lt;br /&gt;
[&amp;quot;Category_class/second_row_column&amp;quot;] = 40000,&lt;br /&gt;
[&amp;quot;Category_described_in_year&amp;quot;] = 5400,&lt;br /&gt;
[&amp;quot;Category_diffuse&amp;quot;] = 9000,&lt;br /&gt;
[&amp;quot;Category_disambiguation&amp;quot;] = 2200,&lt;br /&gt;
[&amp;quot;Category_disambiguation/category_link&amp;quot;] = 2200,&lt;br /&gt;
[&amp;quot;Category_explanation&amp;quot;] = 68000,&lt;br /&gt;
[&amp;quot;Category_handler&amp;quot;] = 3030000,&lt;br /&gt;
[&amp;quot;Category_ifexist&amp;quot;] = 4700,&lt;br /&gt;
[&amp;quot;Category_importance&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Category_importance/column&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Category_importance/second_row_column&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Category_link&amp;quot;] = 256000,&lt;br /&gt;
[&amp;quot;Category_link_with_count&amp;quot;] = 5200,&lt;br /&gt;
[&amp;quot;Category_ordered_by_date&amp;quot;] = 9100,&lt;br /&gt;
[&amp;quot;Category_other&amp;quot;] = 813000,&lt;br /&gt;
[&amp;quot;Category_pair&amp;quot;] = 4700,&lt;br /&gt;
[&amp;quot;Category_pair/core&amp;quot;] = 4700,&lt;br /&gt;
[&amp;quot;Category_redirect&amp;quot;] = 100000,&lt;br /&gt;
[&amp;quot;Category_see_also&amp;quot;] = 38000,&lt;br /&gt;
[&amp;quot;Category_see_also/Category_pair_check&amp;quot;] = 38000,&lt;br /&gt;
[&amp;quot;Category_see_also_if_exists&amp;quot;] = 46000,&lt;br /&gt;
[&amp;quot;Category_see_also_if_exists_2&amp;quot;] = 80000,&lt;br /&gt;
[&amp;quot;Category_title&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Catexp&amp;quot;] = 5800,&lt;br /&gt;
[&amp;quot;CathEncy&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;Catholic&amp;quot;] = 4200,&lt;br /&gt;
[&amp;quot;Catholic_Encyclopedia&amp;quot;] = 4900,&lt;br /&gt;
[&amp;quot;Catmain&amp;quot;] = 23000,&lt;br /&gt;
[&amp;quot;Catmore&amp;quot;] = 9200,&lt;br /&gt;
[&amp;quot;Caution&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Cbb_link&amp;quot;] = 6500,&lt;br /&gt;
[&amp;quot;Cbignore&amp;quot;] = 24000,&lt;br /&gt;
[&amp;quot;Cc-by-2.5&amp;quot;] = 4900,&lt;br /&gt;
[&amp;quot;Cc-by-3.0&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Cc-by-sa-2.5&amp;quot;] = 3300,&lt;br /&gt;
[&amp;quot;Cc-by-sa-2.5,2.0,1.0&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;Cc-by-sa-3.0&amp;quot;] = 34000,&lt;br /&gt;
[&amp;quot;Cc-by-sa-3.0,2.5,2.0,1.0&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;Cc-by-sa-3.0-migrated&amp;quot;] = 32000,&lt;br /&gt;
[&amp;quot;Cc-by-sa-4.0&amp;quot;] = 14000,&lt;br /&gt;
[&amp;quot;Cc-zero&amp;quot;] = 5700,&lt;br /&gt;
[&amp;quot;CensusAU&amp;quot;] = 10000,&lt;br /&gt;
[&amp;quot;Census_2016_AUS&amp;quot;] = 8500,&lt;br /&gt;
[&amp;quot;Cent&amp;quot;] = 4900,&lt;br /&gt;
[&amp;quot;Center&amp;quot;] = 235000,&lt;br /&gt;
[&amp;quot;Centralized_discussion&amp;quot;] = 5200,&lt;br /&gt;
[&amp;quot;Centralized_discussion/core&amp;quot;] = 5200,&lt;br /&gt;
[&amp;quot;Centralized_discussion/styles.css&amp;quot;] = 5200,&lt;br /&gt;
[&amp;quot;Centre&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;Century&amp;quot;] = 2000,&lt;br /&gt;
[&amp;quot;Century_name_from_decade_or_year&amp;quot;] = 69000,&lt;br /&gt;
[&amp;quot;Century_name_from_title_decade&amp;quot;] = 6600,&lt;br /&gt;
[&amp;quot;Century_name_from_title_year&amp;quot;] = 6100,&lt;br /&gt;
[&amp;quot;Certification_Cite/Title&amp;quot;] = 20000,&lt;br /&gt;
[&amp;quot;Certification_Cite/URL&amp;quot;] = 23000,&lt;br /&gt;
[&amp;quot;Certification_Cite/archivedate&amp;quot;] = 4700,&lt;br /&gt;
[&amp;quot;Certification_Cite/archiveurl&amp;quot;] = 4700,&lt;br /&gt;
[&amp;quot;Certification_Cite_Ref&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;Certification_Table_Bottom&amp;quot;] = 20000,&lt;br /&gt;
[&amp;quot;Certification_Table_Entry&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;Certification_Table_Entry/Foot&amp;quot;] = 20000,&lt;br /&gt;
[&amp;quot;Certification_Table_Entry/Foot/helper&amp;quot;] = 20000,&lt;br /&gt;
[&amp;quot;Certification_Table_Entry/Region&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;Certification_Table_Entry/Sales&amp;quot;] = 19000,&lt;br /&gt;
[&amp;quot;Certification_Table_Entry/Sales/GermanPeriod&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Certification_Table_Entry/Sales/ItalianHelper&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;Certification_Table_Top&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;Cfb_link&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;Cfd_result&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;Cfdend&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;Chart&amp;quot;] = 4500,&lt;br /&gt;
[&amp;quot;Chart/end&amp;quot;] = 4500,&lt;br /&gt;
[&amp;quot;Chart/start&amp;quot;] = 4600,&lt;br /&gt;
[&amp;quot;Check_completeness_of_transclusions&amp;quot;] = 3800,&lt;br /&gt;
[&amp;quot;Check_talk&amp;quot;] = 22000,&lt;br /&gt;
[&amp;quot;Check_talk_wp&amp;quot;] = 1330000,&lt;br /&gt;
[&amp;quot;Check_winner_by_scores&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;CheckedSockpuppet&amp;quot;] = 7100,&lt;br /&gt;
[&amp;quot;Checked_sockpuppet&amp;quot;] = 17000,&lt;br /&gt;
[&amp;quot;Checkedsockpuppet&amp;quot;] = 5300,&lt;br /&gt;
[&amp;quot;Checkip&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Checkuser&amp;quot;] = 64000,&lt;br /&gt;
[&amp;quot;Checkuserblock-account&amp;quot;] = 6900,&lt;br /&gt;
[&amp;quot;Chem&amp;quot;] = 4000,&lt;br /&gt;
[&amp;quot;Chem/atom&amp;quot;] = 3900,&lt;br /&gt;
[&amp;quot;Chem/link&amp;quot;] = 4000,&lt;br /&gt;
[&amp;quot;Chem_molar_mass&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Chem_molar_mass/format&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Chembox&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Chembox_3DMet&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_3DMet/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_AllOtherNames&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Chembox_AllOtherNames/format&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Chembox_Appearance&amp;quot;] = 5300,&lt;br /&gt;
[&amp;quot;Chembox_BoilingPt&amp;quot;] = 3500,&lt;br /&gt;
[&amp;quot;Chembox_CASNo&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_CASNo/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_CalcTemperatures&amp;quot;] = 6200,&lt;br /&gt;
[&amp;quot;Chembox_ChEBI&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_ChEBI/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_ChEMBL&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_ChEMBL/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_ChemSpiderID&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_ChemSpiderID/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_CompTox&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_CompTox/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_Density&amp;quot;] = 4500,&lt;br /&gt;
[&amp;quot;Chembox_DrugBank&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_DrugBank/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_ECHA&amp;quot;] = 7100,&lt;br /&gt;
[&amp;quot;Chembox_ECNumber&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_ECNumber/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_Elements&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_Elements/molecular_formula&amp;quot;] = 16000,&lt;br /&gt;
[&amp;quot;Chembox_Footer&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Chembox_Footer/tracking&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Chembox_GHSPictograms&amp;quot;] = 2200,&lt;br /&gt;
[&amp;quot;Chembox_GHSSignalWord&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Chembox_HPhrases&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Chembox_Hazards&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Chembox_IUPHAR_ligand&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_IUPHAR_ligand/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_Identifiers&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_InChI&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Chembox_InChI/format&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Chembox_Indexlist&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_Jmol&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_Jmol/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_KEGG&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_KEGG/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_MeltingPt&amp;quot;] = 5300,&lt;br /&gt;
[&amp;quot;Chembox_PPhrases&amp;quot;] = 2000,&lt;br /&gt;
[&amp;quot;Chembox_Properties&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_PubChem&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_PubChem/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_RTECS&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_RTECS/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_Related&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Chembox_SMILES&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_SMILES/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_SolubilityInWater&amp;quot;] = 3500,&lt;br /&gt;
[&amp;quot;Chembox_UNII&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_UNII/format&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_headerbar&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Chembox_image&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_image_cell&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Chembox_image_sbs&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_parametercheck&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Chembox_templatePar/formatPreviewMessage&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Chembox_verification&amp;quot;] = 7200,&lt;br /&gt;
[&amp;quot;Chemicals&amp;quot;] = 8400,&lt;br /&gt;
[&amp;quot;Chemistry&amp;quot;] = 2900,&lt;br /&gt;
[&amp;quot;Chemspidercite&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Chessgames_player&amp;quot;] = 3000,&lt;br /&gt;
[&amp;quot;Chinese&amp;quot;] = 7400,&lt;br /&gt;
[&amp;quot;Chr&amp;quot;] = 8700,&lt;br /&gt;
[&amp;quot;ChristianityWikiProject&amp;quot;] = 6200,&lt;br /&gt;
[&amp;quot;Circa&amp;quot;] = 38000,&lt;br /&gt;
[&amp;quot;Circular_reference&amp;quot;] = 4800,&lt;br /&gt;
[&amp;quot;Citation&amp;quot;] = 316000,&lt;br /&gt;
[&amp;quot;Citation/make_link&amp;quot;] = 4900,&lt;br /&gt;
[&amp;quot;Citation_needed&amp;quot;] = 462000,&lt;br /&gt;
[&amp;quot;Citation_needed_span&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Citation_style&amp;quot;] = 4300,&lt;br /&gt;
[&amp;quot;Cite_AV_media&amp;quot;] = 30000,&lt;br /&gt;
[&amp;quot;Cite_AV_media_notes&amp;quot;] = 20000,&lt;br /&gt;
[&amp;quot;Cite_Appletons&#039;&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;Cite_Australian_Dictionary_of_Biography&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;Cite_Catholic_Encyclopedia&amp;quot;] = 7800,&lt;br /&gt;
[&amp;quot;Cite_Colledge2006&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;Cite_DCB&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;Cite_DNB&amp;quot;] = 17000,&lt;br /&gt;
[&amp;quot;Cite_EB1911&amp;quot;] = 22000,&lt;br /&gt;
[&amp;quot;Cite_GNIS&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Cite_Gaia_DR2&amp;quot;] = 2200,&lt;br /&gt;
[&amp;quot;Cite_Jewish_Encyclopedia&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;Cite_NIE&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;Cite_NSW_Parliament&amp;quot;] = 3200,&lt;br /&gt;
[&amp;quot;Cite_NSW_SHR&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;Cite_ODNB&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Cite_Q&amp;quot;] = 45000,&lt;br /&gt;
[&amp;quot;Cite_QHR&amp;quot;] = 2900,&lt;br /&gt;
[&amp;quot;Cite_QPN&amp;quot;] = 3900,&lt;br /&gt;
[&amp;quot;Cite_Russian_law&amp;quot;] = 7000,&lt;br /&gt;
[&amp;quot;Cite_Sports-Reference&amp;quot;] = 53000,&lt;br /&gt;
[&amp;quot;Cite_WoRMS&amp;quot;] = 3800,&lt;br /&gt;
[&amp;quot;Cite_arXiv&amp;quot;] = 3900,&lt;br /&gt;
[&amp;quot;Cite_arxiv&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Cite_av_media&amp;quot;] = 3500,&lt;br /&gt;
[&amp;quot;Cite_bcgnis&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Cite_book&amp;quot;] = 1330000,&lt;br /&gt;
[&amp;quot;Cite_certification&amp;quot;] = 23000,&lt;br /&gt;
[&amp;quot;Cite_cgndb&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;Cite_conference&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Cite_court&amp;quot;] = 4600,&lt;br /&gt;
[&amp;quot;Cite_dictionary&amp;quot;] = 3200,&lt;br /&gt;
[&amp;quot;Cite_document&amp;quot;] = 7600,&lt;br /&gt;
[&amp;quot;Cite_encyclopedia&amp;quot;] = 132000,&lt;br /&gt;
[&amp;quot;Cite_episode&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Cite_gnis&amp;quot;] = 33000,&lt;br /&gt;
[&amp;quot;Cite_interview&amp;quot;] = 5600,&lt;br /&gt;
[&amp;quot;Cite_iucn&amp;quot;] = 32000,&lt;br /&gt;
[&amp;quot;Cite_journal&amp;quot;] = 771000,&lt;br /&gt;
[&amp;quot;Cite_magazine&amp;quot;] = 131000,&lt;br /&gt;
[&amp;quot;Cite_map&amp;quot;] = 30000,&lt;br /&gt;
[&amp;quot;Cite_news&amp;quot;] = 1210000,&lt;br /&gt;
[&amp;quot;Cite_newspaper&amp;quot;] = 8100,&lt;br /&gt;
[&amp;quot;Cite_newspaper_The_Times&amp;quot;] = 5800,&lt;br /&gt;
[&amp;quot;Cite_paper&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Cite_patent&amp;quot;] = 4300,&lt;br /&gt;
[&amp;quot;Cite_patent/authors&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Cite_patent/core&amp;quot;] = 4600,&lt;br /&gt;
[&amp;quot;Cite_peakbagger&amp;quot;] = 3700,&lt;br /&gt;
[&amp;quot;Cite_podcast&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;Cite_press_release&amp;quot;] = 49000,&lt;br /&gt;
[&amp;quot;Cite_report&amp;quot;] = 24000,&lt;br /&gt;
[&amp;quot;Cite_simbad&amp;quot;] = 3900,&lt;br /&gt;
[&amp;quot;Cite_sports-reference&amp;quot;] = 58000,&lt;br /&gt;
[&amp;quot;Cite_thesis&amp;quot;] = 17000,&lt;br /&gt;
[&amp;quot;Cite_tweet&amp;quot;] = 17000,&lt;br /&gt;
[&amp;quot;Cite_video&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Cite_video_game&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Cite_web&amp;quot;] = 3860000,&lt;br /&gt;
[&amp;quot;Cite_wikisource&amp;quot;] = 4300,&lt;br /&gt;
[&amp;quot;Cite_wikisource/make_link&amp;quot;] = 51000,&lt;br /&gt;
[&amp;quot;Civil_navigation&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;Cl&amp;quot;] = 103000,&lt;br /&gt;
[&amp;quot;Clade&amp;quot;] = 5400,&lt;br /&gt;
[&amp;quot;Clade/styles.css&amp;quot;] = 5500,&lt;br /&gt;
[&amp;quot;Clarify&amp;quot;] = 36000,&lt;br /&gt;
[&amp;quot;Class&amp;quot;] = 9090000,&lt;br /&gt;
[&amp;quot;Class/colour&amp;quot;] = 9140000,&lt;br /&gt;
[&amp;quot;Class/icon&amp;quot;] = 9110000,&lt;br /&gt;
[&amp;quot;Class_mask&amp;quot;] = 9310000,&lt;br /&gt;
[&amp;quot;Class_mask/b&amp;quot;] = 300000,&lt;br /&gt;
[&amp;quot;Classical&amp;quot;] = 7100,&lt;br /&gt;
[&amp;quot;Classicon&amp;quot;] = 4500,&lt;br /&gt;
[&amp;quot;Clc&amp;quot;] = 4300,&lt;br /&gt;
[&amp;quot;Cleanup&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Cleanup_reorganize&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;Cleanup_rewrite&amp;quot;] = 5300,&lt;br /&gt;
[&amp;quot;Clear&amp;quot;] = 3240000,&lt;br /&gt;
[&amp;quot;Clear-left&amp;quot;] = 19000,&lt;br /&gt;
[&amp;quot;Clear_left&amp;quot;] = 30000,&lt;br /&gt;
[&amp;quot;Clear_right&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Clerk-Note&amp;quot;] = 8400,&lt;br /&gt;
[&amp;quot;Clerknote&amp;quot;] = 6200,&lt;br /&gt;
[&amp;quot;Clickable_button&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Clickable_button_2&amp;quot;] = 771000,&lt;br /&gt;
[&amp;quot;Clr&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;Cmbox&amp;quot;] = 336000,&lt;br /&gt;
[&amp;quot;Cn&amp;quot;] = 73000,&lt;br /&gt;
[&amp;quot;Coat_of_arms&amp;quot;] = 7400,&lt;br /&gt;
[&amp;quot;Cob&amp;quot;] = 9500,&lt;br /&gt;
[&amp;quot;Code&amp;quot;] = 39000,&lt;br /&gt;
[&amp;quot;Col-1-of-2&amp;quot;] = 3100,&lt;br /&gt;
[&amp;quot;Col-2&amp;quot;] = 155000,&lt;br /&gt;
[&amp;quot;Col-2-of-2&amp;quot;] = 3000,&lt;br /&gt;
[&amp;quot;Col-3&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Col-4&amp;quot;] = 4200,&lt;br /&gt;
[&amp;quot;Col-begin&amp;quot;] = 203000,&lt;br /&gt;
[&amp;quot;Col-break&amp;quot;] = 199000,&lt;br /&gt;
[&amp;quot;Col-end&amp;quot;] = 200000,&lt;br /&gt;
[&amp;quot;Col-float&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Col-float-break&amp;quot;] = 2000,&lt;br /&gt;
[&amp;quot;Col-float-end&amp;quot;] = 2000,&lt;br /&gt;
[&amp;quot;Col-float/styles.css&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Col-start&amp;quot;] = 20000,&lt;br /&gt;
[&amp;quot;Colbegin&amp;quot;] = 51000,&lt;br /&gt;
[&amp;quot;Colend&amp;quot;] = 59000,&lt;br /&gt;
[&amp;quot;Collapse&amp;quot;] = 9700,&lt;br /&gt;
[&amp;quot;Collapse_bottom&amp;quot;] = 44000,&lt;br /&gt;
[&amp;quot;Collapse_top&amp;quot;] = 44000,&lt;br /&gt;
[&amp;quot;Collapsebottom&amp;quot;] = 3700,&lt;br /&gt;
[&amp;quot;Collapsetop&amp;quot;] = 3700,&lt;br /&gt;
[&amp;quot;Collapsible_list&amp;quot;] = 45000,&lt;br /&gt;
[&amp;quot;Collapsible_option&amp;quot;] = 123000,&lt;br /&gt;
[&amp;quot;Colledge&amp;quot;] = 2900,&lt;br /&gt;
[&amp;quot;College&amp;quot;] = 6900,&lt;br /&gt;
[&amp;quot;CollegePrimaryHeader&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;CollegePrimaryStyle&amp;quot;] = 82000,&lt;br /&gt;
[&amp;quot;College_Athlete_Recruit_End&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;College_Athlete_Recruit_Entry&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;College_Athlete_Recruit_Start&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;College_athlete_recruit_end&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;College_athlete_recruit_entry&amp;quot;] = 3500,&lt;br /&gt;
[&amp;quot;College_athlete_recruit_start&amp;quot;] = 3500,&lt;br /&gt;
[&amp;quot;College_color_list&amp;quot;] = 3500,&lt;br /&gt;
[&amp;quot;Colon&amp;quot;] = 17000,&lt;br /&gt;
[&amp;quot;Color&amp;quot;] = 429000,&lt;br /&gt;
[&amp;quot;Color_box&amp;quot;] = 60000,&lt;br /&gt;
[&amp;quot;Colorbox&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Colorbull&amp;quot;] = 4800,&lt;br /&gt;
[&amp;quot;Colored_link&amp;quot;] = 28000,&lt;br /&gt;
[&amp;quot;Colors&amp;quot;] = 18000,&lt;br /&gt;
[&amp;quot;Colour&amp;quot;] = 10000,&lt;br /&gt;
[&amp;quot;Coloured_link&amp;quot;] = 4400,&lt;br /&gt;
[&amp;quot;Columns-list&amp;quot;] = 89000,&lt;br /&gt;
[&amp;quot;Comedy&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Comic_Book_DB&amp;quot;] = 3700,&lt;br /&gt;
[&amp;quot;Comicbookdb&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;Comics-replaceability&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Comics_infobox_sec&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Comics_infobox_sec/creator_nat&amp;quot;] = 3000,&lt;br /&gt;
[&amp;quot;Comics_infobox_sec/formcat&amp;quot;] = 3100,&lt;br /&gt;
[&amp;quot;Comics_infobox_sec/genre&amp;quot;] = 3800,&lt;br /&gt;
[&amp;quot;Comics_infobox_sec/genrecat&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;Comicsproj&amp;quot;] = 29000,&lt;br /&gt;
[&amp;quot;Comicsyrimage&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Comma_separated_entries&amp;quot;] = 316000,&lt;br /&gt;
[&amp;quot;Comment&amp;quot;] = 4000,&lt;br /&gt;
[&amp;quot;Committed_identity&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Committed_identity/styles.css&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Commons&amp;quot;] = 64000,&lt;br /&gt;
[&amp;quot;Commons-inline&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Commons_cat&amp;quot;] = 48000,&lt;br /&gt;
[&amp;quot;Commons_category&amp;quot;] = 798000,&lt;br /&gt;
[&amp;quot;Commons_category-inline&amp;quot;] = 117000,&lt;br /&gt;
[&amp;quot;Commons_category_inline&amp;quot;] = 6800,&lt;br /&gt;
[&amp;quot;Commonscat&amp;quot;] = 71000,&lt;br /&gt;
[&amp;quot;Commonscat-inline&amp;quot;] = 23000,&lt;br /&gt;
[&amp;quot;Commonscat_inline&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Commonscatinline&amp;quot;] = 6800,&lt;br /&gt;
[&amp;quot;Compact_TOC&amp;quot;] = 6600,&lt;br /&gt;
[&amp;quot;Compact_ToC&amp;quot;] = 5200,&lt;br /&gt;
[&amp;quot;Compare&amp;quot;] = 7500,&lt;br /&gt;
[&amp;quot;Compare_image_with_Wikidata&amp;quot;] = 7500,&lt;br /&gt;
[&amp;quot;Composition_bar&amp;quot;] = 8200,&lt;br /&gt;
[&amp;quot;ConfirmationOTRS&amp;quot;] = 3100,&lt;br /&gt;
[&amp;quot;Confirmed&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Confused&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Confusing&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;CongBio&amp;quot;] = 9800,&lt;br /&gt;
[&amp;quot;CongLinks&amp;quot;] = 4300,&lt;br /&gt;
[&amp;quot;Connected_contributor&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Connected_contributor_(paid)&amp;quot;] = 5600,&lt;br /&gt;
[&amp;quot;Conservative_Party_(UK)/meta/color&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Conservative_Party_(UK)/meta/shortname&amp;quot;] = 9100,&lt;br /&gt;
[&amp;quot;Conservative_and_Unionist_Party_(UK)/meta/color&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Constellation_navbox&amp;quot;] = 5200,&lt;br /&gt;
[&amp;quot;Container&amp;quot;] = 8600,&lt;br /&gt;
[&amp;quot;Container_cat&amp;quot;] = 6400,&lt;br /&gt;
[&amp;quot;Container_category&amp;quot;] = 34000,&lt;br /&gt;
[&amp;quot;Containercat&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Contains_special_characters&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;Contains_special_characters/core&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;Content_category&amp;quot;] = 6800,&lt;br /&gt;
[&amp;quot;Context&amp;quot;] = 3800,&lt;br /&gt;
[&amp;quot;Continent2continental&amp;quot;] = 14000,&lt;br /&gt;
[&amp;quot;Continent_adjective_to_noun&amp;quot;] = 2200,&lt;br /&gt;
[&amp;quot;Controversial&amp;quot;] = 3000,&lt;br /&gt;
[&amp;quot;Convert&amp;quot;] = 1070000,&lt;br /&gt;
[&amp;quot;Convinfobox&amp;quot;] = 183000,&lt;br /&gt;
[&amp;quot;Convinfobox/2&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Convinfobox/3&amp;quot;] = 109000,&lt;br /&gt;
[&amp;quot;Convinfobox/pri2&amp;quot;] = 55000,&lt;br /&gt;
[&amp;quot;Convinfobox/prisec2&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Convinfobox/prisec3&amp;quot;] = 22000,&lt;br /&gt;
[&amp;quot;Convinfobox/sec2&amp;quot;] = 7300,&lt;br /&gt;
[&amp;quot;Coord&amp;quot;] = 1260000,&lt;br /&gt;
[&amp;quot;Coord_missing&amp;quot;] = 116000,&lt;br /&gt;
[&amp;quot;Coord_missing/CheckCat&amp;quot;] = 115000,&lt;br /&gt;
[&amp;quot;Coords&amp;quot;] = 7000,&lt;br /&gt;
[&amp;quot;Copied&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Copy_to_Wikimedia_Commons&amp;quot;] = 148000,&lt;br /&gt;
[&amp;quot;Copyvios&amp;quot;] = 6000,&lt;br /&gt;
[&amp;quot;Cospar&amp;quot;] = 2900,&lt;br /&gt;
[&amp;quot;Cot&amp;quot;] = 9300,&lt;br /&gt;
[&amp;quot;Count&amp;quot;] = 8100,&lt;br /&gt;
[&amp;quot;Country2continent&amp;quot;] = 23000,&lt;br /&gt;
[&amp;quot;Country2continental&amp;quot;] = 2000,&lt;br /&gt;
[&amp;quot;CountryPrefixThe&amp;quot;] = 97000,&lt;br /&gt;
[&amp;quot;Country_abbreviation&amp;quot;] = 82000,&lt;br /&gt;
[&amp;quot;Country_alias&amp;quot;] = 14000,&lt;br /&gt;
[&amp;quot;Country_at_games_navbox&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_at_games_navbox/below&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_data&amp;quot;] = 4900,&lt;br /&gt;
[&amp;quot;Country_data_ALB&amp;quot;] = 5800,&lt;br /&gt;
[&amp;quot;Country_data_ALG&amp;quot;] = 7700,&lt;br /&gt;
[&amp;quot;Country_data_AND&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;Country_data_ANG&amp;quot;] = 4000,&lt;br /&gt;
[&amp;quot;Country_data_ARG&amp;quot;] = 41000,&lt;br /&gt;
[&amp;quot;Country_data_ARM&amp;quot;] = 5900,&lt;br /&gt;
[&amp;quot;Country_data_AUS&amp;quot;] = 66000,&lt;br /&gt;
[&amp;quot;Country_data_AUT&amp;quot;] = 39000,&lt;br /&gt;
[&amp;quot;Country_data_AZE&amp;quot;] = 7100,&lt;br /&gt;
[&amp;quot;Country_data_Afghanistan&amp;quot;] = 10000,&lt;br /&gt;
[&amp;quot;Country_data_Alaska&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_data_Albania&amp;quot;] = 16000,&lt;br /&gt;
[&amp;quot;Country_data_Alberta&amp;quot;] = 3800,&lt;br /&gt;
[&amp;quot;Country_data_Algeria&amp;quot;] = 20000,&lt;br /&gt;
[&amp;quot;Country_data_American_Samoa&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Country_data_Andorra&amp;quot;] = 6800,&lt;br /&gt;
[&amp;quot;Country_data_Angola&amp;quot;] = 9800,&lt;br /&gt;
[&amp;quot;Country_data_Anguilla&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Country_data_Antigua_and_Barbuda&amp;quot;] = 5500,&lt;br /&gt;
[&amp;quot;Country_data_Apulia&amp;quot;] = 7900,&lt;br /&gt;
[&amp;quot;Country_data_Argentina&amp;quot;] = 67000,&lt;br /&gt;
[&amp;quot;Country_data_Arizona&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_data_Armenia&amp;quot;] = 17000,&lt;br /&gt;
[&amp;quot;Country_data_Aruba&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;Country_data_Australia&amp;quot;] = 105000,&lt;br /&gt;
[&amp;quot;Country_data_Austria&amp;quot;] = 61000,&lt;br /&gt;
[&amp;quot;Country_data_Azerbaijan&amp;quot;] = 22000,&lt;br /&gt;
[&amp;quot;Country_data_BAH&amp;quot;] = 3800,&lt;br /&gt;
[&amp;quot;Country_data_BAN&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;Country_data_BAR&amp;quot;] = 2200,&lt;br /&gt;
[&amp;quot;Country_data_BEL&amp;quot;] = 44000,&lt;br /&gt;
[&amp;quot;Country_data_BER&amp;quot;] = 2000,&lt;br /&gt;
[&amp;quot;Country_data_BHR&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;Country_data_BIH&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Country_data_BLR&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;Country_data_BOL&amp;quot;] = 5600,&lt;br /&gt;
[&amp;quot;Country_data_BOT&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_data_BRA&amp;quot;] = 50000,&lt;br /&gt;
[&amp;quot;Country_data_BUL&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;Country_data_Bahamas&amp;quot;] = 8800,&lt;br /&gt;
[&amp;quot;Country_data_Bahrain&amp;quot;] = 9000,&lt;br /&gt;
[&amp;quot;Country_data_Bangladesh&amp;quot;] = 14000,&lt;br /&gt;
[&amp;quot;Country_data_Barbados&amp;quot;] = 7000,&lt;br /&gt;
[&amp;quot;Country_data_Belarus&amp;quot;] = 34000,&lt;br /&gt;
[&amp;quot;Country_data_Belgium&amp;quot;] = 70000,&lt;br /&gt;
[&amp;quot;Country_data_Belize&amp;quot;] = 4600,&lt;br /&gt;
[&amp;quot;Country_data_Benin&amp;quot;] = 6200,&lt;br /&gt;
[&amp;quot;Country_data_Bermuda&amp;quot;] = 5300,&lt;br /&gt;
[&amp;quot;Country_data_Bhutan&amp;quot;] = 4200,&lt;br /&gt;
[&amp;quot;Country_data_Bolivia&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Country_data_Bosnia_and_Herzegovina&amp;quot;] = 22000,&lt;br /&gt;
[&amp;quot;Country_data_Botswana&amp;quot;] = 7700,&lt;br /&gt;
[&amp;quot;Country_data_Brazil&amp;quot;] = 85000,&lt;br /&gt;
[&amp;quot;Country_data_British_Columbia&amp;quot;] = 3200,&lt;br /&gt;
[&amp;quot;Country_data_British_Virgin_Islands&amp;quot;] = 3300,&lt;br /&gt;
[&amp;quot;Country_data_Brunei&amp;quot;] = 5500,&lt;br /&gt;
[&amp;quot;Country_data_Bulgaria&amp;quot;] = 41000,&lt;br /&gt;
[&amp;quot;Country_data_Burkina_Faso&amp;quot;] = 8700,&lt;br /&gt;
[&amp;quot;Country_data_Burma&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Country_data_Burundi&amp;quot;] = 4700,&lt;br /&gt;
[&amp;quot;Country_data_CAN&amp;quot;] = 53000,&lt;br /&gt;
[&amp;quot;Country_data_CGO&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_data_CHE&amp;quot;] = 4100,&lt;br /&gt;
[&amp;quot;Country_data_CHI&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Country_data_CHN&amp;quot;] = 36000,&lt;br /&gt;
[&amp;quot;Country_data_CIV&amp;quot;] = 6500,&lt;br /&gt;
[&amp;quot;Country_data_CMR&amp;quot;] = 7100,&lt;br /&gt;
[&amp;quot;Country_data_COD&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;Country_data_COL&amp;quot;] = 22000,&lt;br /&gt;
[&amp;quot;Country_data_CRC&amp;quot;] = 6100,&lt;br /&gt;
[&amp;quot;Country_data_CRO&amp;quot;] = 29000,&lt;br /&gt;
[&amp;quot;Country_data_CUB&amp;quot;] = 8200,&lt;br /&gt;
[&amp;quot;Country_data_CYP&amp;quot;] = 7600,&lt;br /&gt;
[&amp;quot;Country_data_CZE&amp;quot;] = 40000,&lt;br /&gt;
[&amp;quot;Country_data_California&amp;quot;] = 6400,&lt;br /&gt;
[&amp;quot;Country_data_Cambodia&amp;quot;] = 7900,&lt;br /&gt;
[&amp;quot;Country_data_Cameroon&amp;quot;] = 14000,&lt;br /&gt;
[&amp;quot;Country_data_Canada&amp;quot;] = 102000,&lt;br /&gt;
[&amp;quot;Country_data_Cape_Verde&amp;quot;] = 5000,&lt;br /&gt;
[&amp;quot;Country_data_Catalonia&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Country_data_Cayman_Islands&amp;quot;] = 4200,&lt;br /&gt;
[&amp;quot;Country_data_Central_African_Republic&amp;quot;] = 4100,&lt;br /&gt;
[&amp;quot;Country_data_Chad&amp;quot;] = 4600,&lt;br /&gt;
[&amp;quot;Country_data_Chile&amp;quot;] = 32000,&lt;br /&gt;
[&amp;quot;Country_data_China&amp;quot;] = 67000,&lt;br /&gt;
[&amp;quot;Country_data_Chinese_Taipei&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Country_data_Colombia&amp;quot;] = 37000,&lt;br /&gt;
[&amp;quot;Country_data_Colorado&amp;quot;] = 4900,&lt;br /&gt;
[&amp;quot;Country_data_Comoros&amp;quot;] = 3700,&lt;br /&gt;
[&amp;quot;Country_data_Confederate_States_of_America&amp;quot;] = 2900,&lt;br /&gt;
[&amp;quot;Country_data_Connecticut&amp;quot;] = 3000,&lt;br /&gt;
[&amp;quot;Country_data_Cook_Islands&amp;quot;] = 3300,&lt;br /&gt;
[&amp;quot;Country_data_Costa_Rica&amp;quot;] = 14000,&lt;br /&gt;
[&amp;quot;Country_data_Croatia&amp;quot;] = 46000,&lt;br /&gt;
[&amp;quot;Country_data_Cuba&amp;quot;] = 17000,&lt;br /&gt;
[&amp;quot;Country_data_Curaçao&amp;quot;] = 3500,&lt;br /&gt;
[&amp;quot;Country_data_Cyprus&amp;quot;] = 17000,&lt;br /&gt;
[&amp;quot;Country_data_Czech_Republic&amp;quot;] = 64000,&lt;br /&gt;
[&amp;quot;Country_data_Czechoslovakia&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Country_data_DEN&amp;quot;] = 29000,&lt;br /&gt;
[&amp;quot;Country_data_DEU&amp;quot;] = 7700,&lt;br /&gt;
[&amp;quot;Country_data_DNK&amp;quot;] = 3000,&lt;br /&gt;
[&amp;quot;Country_data_DOM&amp;quot;] = 7200,&lt;br /&gt;
[&amp;quot;Country_data_Democratic_Republic_of_the_Congo&amp;quot;] = 9500,&lt;br /&gt;
[&amp;quot;Country_data_Denmark&amp;quot;] = 58000,&lt;br /&gt;
[&amp;quot;Country_data_Djibouti&amp;quot;] = 3800,&lt;br /&gt;
[&amp;quot;Country_data_Dominica&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;Country_data_Dominican_Republic&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Country_data_ECU&amp;quot;] = 9700,&lt;br /&gt;
[&amp;quot;Country_data_EGY&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Country_data_ENG&amp;quot;] = 39000,&lt;br /&gt;
[&amp;quot;Country_data_ESA&amp;quot;] = 2200,&lt;br /&gt;
[&amp;quot;Country_data_ESP&amp;quot;] = 62000,&lt;br /&gt;
[&amp;quot;Country_data_EST&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Country_data_ETH&amp;quot;] = 3200,&lt;br /&gt;
[&amp;quot;Country_data_EU&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;Country_data_East_Germany&amp;quot;] = 10000,&lt;br /&gt;
[&amp;quot;Country_data_East_Timor&amp;quot;] = 4100,&lt;br /&gt;
[&amp;quot;Country_data_Ecuador&amp;quot;] = 19000,&lt;br /&gt;
[&amp;quot;Country_data_Egypt&amp;quot;] = 26000,&lt;br /&gt;
[&amp;quot;Country_data_El_Salvador&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Country_data_Empire_of_Japan&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;Country_data_England&amp;quot;] = 81000,&lt;br /&gt;
[&amp;quot;Country_data_Equatorial_Guinea&amp;quot;] = 4400,&lt;br /&gt;
[&amp;quot;Country_data_Eritrea&amp;quot;] = 4400,&lt;br /&gt;
[&amp;quot;Country_data_Estonia&amp;quot;] = 27000,&lt;br /&gt;
[&amp;quot;Country_data_Eswatini&amp;quot;] = 4200,&lt;br /&gt;
[&amp;quot;Country_data_Ethiopia&amp;quot;] = 10000,&lt;br /&gt;
[&amp;quot;Country_data_Europe&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;Country_data_European_Union&amp;quot;] = 6600,&lt;br /&gt;
[&amp;quot;Country_data_FIJ&amp;quot;] = 3300,&lt;br /&gt;
[&amp;quot;Country_data_FIN&amp;quot;] = 30000,&lt;br /&gt;
[&amp;quot;Country_data_FRA&amp;quot;] = 83000,&lt;br /&gt;
[&amp;quot;Country_data_FRG&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Country_data_FR_Yugoslavia&amp;quot;] = 3700,&lt;br /&gt;
[&amp;quot;Country_data_Falkland_Islands&amp;quot;] = 2000,&lt;br /&gt;
[&amp;quot;Country_data_Faroe_Islands&amp;quot;] = 4800,&lt;br /&gt;
[&amp;quot;Country_data_Federated_States_of_Micronesia&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;Country_data_Fiji&amp;quot;] = 9400,&lt;br /&gt;
[&amp;quot;Country_data_Finland&amp;quot;] = 53000,&lt;br /&gt;
[&amp;quot;Country_data_Florida&amp;quot;] = 6500,&lt;br /&gt;
[&amp;quot;Country_data_France&amp;quot;] = 178000,&lt;br /&gt;
[&amp;quot;Country_data_French_Polynesia&amp;quot;] = 3300,&lt;br /&gt;
[&amp;quot;Country_data_GAB&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;Country_data_GBR&amp;quot;] = 46000,&lt;br /&gt;
[&amp;quot;Country_data_GDR&amp;quot;] = 5600,&lt;br /&gt;
[&amp;quot;Country_data_GEO&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Country_data_GER&amp;quot;] = 69000,&lt;br /&gt;
[&amp;quot;Country_data_GHA&amp;quot;] = 8500,&lt;br /&gt;
[&amp;quot;Country_data_GRE&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;Country_data_GUA&amp;quot;] = 4700,&lt;br /&gt;
[&amp;quot;Country_data_GUI&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;Country_data_GUY&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;Country_data_Gabon&amp;quot;] = 6500,&lt;br /&gt;
[&amp;quot;Country_data_Gambia&amp;quot;] = 5400,&lt;br /&gt;
[&amp;quot;Country_data_Georgia&amp;quot;] = 10000,&lt;br /&gt;
[&amp;quot;Country_data_Georgia_(U.S._state)&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;Country_data_Georgia_(country)&amp;quot;] = 22000,&lt;br /&gt;
[&amp;quot;Country_data_German_Empire&amp;quot;] = 4700,&lt;br /&gt;
[&amp;quot;Country_data_Germany&amp;quot;] = 124000,&lt;br /&gt;
[&amp;quot;Country_data_Ghana&amp;quot;] = 19000,&lt;br /&gt;
[&amp;quot;Country_data_Gibraltar&amp;quot;] = 4400,&lt;br /&gt;
[&amp;quot;Country_data_Great_Britain&amp;quot;] = 54000,&lt;br /&gt;
[&amp;quot;Country_data_Greece&amp;quot;] = 46000,&lt;br /&gt;
[&amp;quot;Country_data_Greenland&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;Country_data_Grenada&amp;quot;] = 4500,&lt;br /&gt;
[&amp;quot;Country_data_Guadeloupe&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;Country_data_Guam&amp;quot;] = 4400,&lt;br /&gt;
[&amp;quot;Country_data_Guatemala&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Country_data_Guernsey&amp;quot;] = 2200,&lt;br /&gt;
[&amp;quot;Country_data_Guinea&amp;quot;] = 6900,&lt;br /&gt;
[&amp;quot;Country_data_Guinea-Bissau&amp;quot;] = 4100,&lt;br /&gt;
[&amp;quot;Country_data_Guyana&amp;quot;] = 7000,&lt;br /&gt;
[&amp;quot;Country_data_HAI&amp;quot;] = 3000,&lt;br /&gt;
[&amp;quot;Country_data_HKG&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Country_data_HON&amp;quot;] = 3900,&lt;br /&gt;
[&amp;quot;Country_data_HUN&amp;quot;] = 31000,&lt;br /&gt;
[&amp;quot;Country_data_Haiti&amp;quot;] = 7900,&lt;br /&gt;
[&amp;quot;Country_data_Honduras&amp;quot;] = 9700,&lt;br /&gt;
[&amp;quot;Country_data_Hong_Kong&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;Country_data_Hungary&amp;quot;] = 54000,&lt;br /&gt;
[&amp;quot;Country_data_IDN&amp;quot;] = 4800,&lt;br /&gt;
[&amp;quot;Country_data_INA&amp;quot;] = 9000,&lt;br /&gt;
[&amp;quot;Country_data_IND&amp;quot;] = 27000,&lt;br /&gt;
[&amp;quot;Country_data_IRE&amp;quot;] = 9700,&lt;br /&gt;
[&amp;quot;Country_data_IRI&amp;quot;] = 4200,&lt;br /&gt;
[&amp;quot;Country_data_IRL&amp;quot;] = 18000,&lt;br /&gt;
[&amp;quot;Country_data_IRN&amp;quot;] = 5400,&lt;br /&gt;
[&amp;quot;Country_data_IRQ&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;Country_data_ISL&amp;quot;] = 7500,&lt;br /&gt;
[&amp;quot;Country_data_ISR&amp;quot;] = 18000,&lt;br /&gt;
[&amp;quot;Country_data_ITA&amp;quot;] = 74000,&lt;br /&gt;
[&amp;quot;Country_data_Iceland&amp;quot;] = 18000,&lt;br /&gt;
[&amp;quot;Country_data_Idaho&amp;quot;] = 2000,&lt;br /&gt;
[&amp;quot;Country_data_Illinois&amp;quot;] = 5200,&lt;br /&gt;
[&amp;quot;Country_data_India&amp;quot;] = 89000,&lt;br /&gt;
[&amp;quot;Country_data_Indiana&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Country_data_Indonesia&amp;quot;] = 30000,&lt;br /&gt;
[&amp;quot;Country_data_Iowa&amp;quot;] = 2900,&lt;br /&gt;
[&amp;quot;Country_data_Iran&amp;quot;] = 84000,&lt;br /&gt;
[&amp;quot;Country_data_Iraq&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Country_data_Ireland&amp;quot;] = 29000,&lt;br /&gt;
[&amp;quot;Country_data_Isle_of_Man&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Country_data_Israel&amp;quot;] = 36000,&lt;br /&gt;
[&amp;quot;Country_data_Italy&amp;quot;] = 119000,&lt;br /&gt;
[&amp;quot;Country_data_Ivory_Coast&amp;quot;] = 14000,&lt;br /&gt;
[&amp;quot;Country_data_JAM&amp;quot;] = 8400,&lt;br /&gt;
[&amp;quot;Country_data_JOR&amp;quot;] = 3200,&lt;br /&gt;
[&amp;quot;Country_data_JP&amp;quot;] = 7800,&lt;br /&gt;
[&amp;quot;Country_data_JPN&amp;quot;] = 52000,&lt;br /&gt;
[&amp;quot;Country_data_Jamaica&amp;quot;] = 17000,&lt;br /&gt;
[&amp;quot;Country_data_Japan&amp;quot;] = 97000,&lt;br /&gt;
[&amp;quot;Country_data_Jersey&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;Country_data_Jordan&amp;quot;] = 9600,&lt;br /&gt;
[&amp;quot;Country_data_KAZ&amp;quot;] = 16000,&lt;br /&gt;
[&amp;quot;Country_data_KEN&amp;quot;] = 6100,&lt;br /&gt;
[&amp;quot;Country_data_KGZ&amp;quot;] = 3000,&lt;br /&gt;
[&amp;quot;Country_data_KOR&amp;quot;] = 27000,&lt;br /&gt;
[&amp;quot;Country_data_KSA&amp;quot;] = 4700,&lt;br /&gt;
[&amp;quot;Country_data_KUW&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;Country_data_Kazakhstan&amp;quot;] = 26000,&lt;br /&gt;
[&amp;quot;Country_data_Kenya&amp;quot;] = 16000,&lt;br /&gt;
[&amp;quot;Country_data_Kingdom_of_Great_Britain&amp;quot;] = 4100,&lt;br /&gt;
[&amp;quot;Country_data_Kingdom_of_Italy&amp;quot;] = 3500,&lt;br /&gt;
[&amp;quot;Country_data_Kiribati&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Country_data_Kosovo&amp;quot;] = 6800,&lt;br /&gt;
[&amp;quot;Country_data_Kuwait&amp;quot;] = 9000,&lt;br /&gt;
[&amp;quot;Country_data_Kyrgyzstan&amp;quot;] = 7800,&lt;br /&gt;
[&amp;quot;Country_data_LAT&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Country_data_LIB&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Country_data_LIE&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Country_data_LIT&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Country_data_LTU&amp;quot;] = 10000,&lt;br /&gt;
[&amp;quot;Country_data_LUX&amp;quot;] = 9100,&lt;br /&gt;
[&amp;quot;Country_data_LVA&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_data_Laos&amp;quot;] = 6500,&lt;br /&gt;
[&amp;quot;Country_data_Latvia&amp;quot;] = 25000,&lt;br /&gt;
[&amp;quot;Country_data_Lebanon&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Country_data_Lesotho&amp;quot;] = 4400,&lt;br /&gt;
[&amp;quot;Country_data_Liberia&amp;quot;] = 6000,&lt;br /&gt;
[&amp;quot;Country_data_Libya&amp;quot;] = 7500,&lt;br /&gt;
[&amp;quot;Country_data_Liechtenstein&amp;quot;] = 6900,&lt;br /&gt;
[&amp;quot;Country_data_Lithuania&amp;quot;] = 25000,&lt;br /&gt;
[&amp;quot;Country_data_Luxembourg&amp;quot;] = 19000,&lt;br /&gt;
[&amp;quot;Country_data_MAC&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;Country_data_MAR&amp;quot;] = 9800,&lt;br /&gt;
[&amp;quot;Country_data_MAS&amp;quot;] = 9500,&lt;br /&gt;
[&amp;quot;Country_data_MDA&amp;quot;] = 6100,&lt;br /&gt;
[&amp;quot;Country_data_MEX&amp;quot;] = 27000,&lt;br /&gt;
[&amp;quot;Country_data_MGL&amp;quot;] = 2200,&lt;br /&gt;
[&amp;quot;Country_data_MKD&amp;quot;] = 6100,&lt;br /&gt;
[&amp;quot;Country_data_MLI&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;Country_data_MLT&amp;quot;] = 5000,&lt;br /&gt;
[&amp;quot;Country_data_MNE&amp;quot;] = 6700,&lt;br /&gt;
[&amp;quot;Country_data_MON&amp;quot;] = 3000,&lt;br /&gt;
[&amp;quot;Country_data_MRI&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_data_MYA&amp;quot;] = 2900,&lt;br /&gt;
[&amp;quot;Country_data_MYS&amp;quot;] = 3900,&lt;br /&gt;
[&amp;quot;Country_data_Macau&amp;quot;] = 6500,&lt;br /&gt;
[&amp;quot;Country_data_Macedonia&amp;quot;] = 5000,&lt;br /&gt;
[&amp;quot;Country_data_Madagascar&amp;quot;] = 7600,&lt;br /&gt;
[&amp;quot;Country_data_Malawi&amp;quot;] = 4600,&lt;br /&gt;
[&amp;quot;Country_data_Malaysia&amp;quot;] = 30000,&lt;br /&gt;
[&amp;quot;Country_data_Maldives&amp;quot;] = 5200,&lt;br /&gt;
[&amp;quot;Country_data_Mali&amp;quot;] = 9600,&lt;br /&gt;
[&amp;quot;Country_data_Malta&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Country_data_Manitoba&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Country_data_Marshall_Islands&amp;quot;] = 3200,&lt;br /&gt;
[&amp;quot;Country_data_Martinique&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Country_data_Maryland&amp;quot;] = 3000,&lt;br /&gt;
[&amp;quot;Country_data_Massachusetts&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Country_data_Mauritania&amp;quot;] = 4700,&lt;br /&gt;
[&amp;quot;Country_data_Mauritius&amp;quot;] = 7200,&lt;br /&gt;
[&amp;quot;Country_data_Mexico&amp;quot;] = 52000,&lt;br /&gt;
[&amp;quot;Country_data_Michigan&amp;quot;] = 3900,&lt;br /&gt;
[&amp;quot;Country_data_Minnesota&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;Country_data_Missouri&amp;quot;] = 2000,&lt;br /&gt;
[&amp;quot;Country_data_Moldova&amp;quot;] = 14000,&lt;br /&gt;
[&amp;quot;Country_data_Monaco&amp;quot;] = 8800,&lt;br /&gt;
[&amp;quot;Country_data_Mongolia&amp;quot;] = 7900,&lt;br /&gt;
[&amp;quot;Country_data_Montana&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;Country_data_Montenegro&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Country_data_Montserrat&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;Country_data_Morocco&amp;quot;] = 22000,&lt;br /&gt;
[&amp;quot;Country_data_Mozambique&amp;quot;] = 6100,&lt;br /&gt;
[&amp;quot;Country_data_Myanmar&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Country_data_NAM&amp;quot;] = 3200,&lt;br /&gt;
[&amp;quot;Country_data_NED&amp;quot;] = 50000,&lt;br /&gt;
[&amp;quot;Country_data_NEP&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Country_data_NGA&amp;quot;] = 6700,&lt;br /&gt;
[&amp;quot;Country_data_NGR&amp;quot;] = 7100,&lt;br /&gt;
[&amp;quot;Country_data_NIR&amp;quot;] = 8600,&lt;br /&gt;
[&amp;quot;Country_data_NLD&amp;quot;] = 5700,&lt;br /&gt;
[&amp;quot;Country_data_NOR&amp;quot;] = 25000,&lt;br /&gt;
[&amp;quot;Country_data_NZ&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Country_data_NZL&amp;quot;] = 28000,&lt;br /&gt;
[&amp;quot;Country_data_Namibia&amp;quot;] = 8700,&lt;br /&gt;
[&amp;quot;Country_data_Nauru&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_data_Nazi_Germany&amp;quot;] = 8700,&lt;br /&gt;
[&amp;quot;Country_data_Nepal&amp;quot;] = 14000,&lt;br /&gt;
[&amp;quot;Country_data_Netherlands&amp;quot;] = 90000,&lt;br /&gt;
[&amp;quot;Country_data_Netherlands_Antilles&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_data_New_Brunswick&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;Country_data_New_Caledonia&amp;quot;] = 3100,&lt;br /&gt;
[&amp;quot;Country_data_New_Jersey&amp;quot;] = 4100,&lt;br /&gt;
[&amp;quot;Country_data_New_South_Wales&amp;quot;] = 5200,&lt;br /&gt;
[&amp;quot;Country_data_New_York&amp;quot;] = 3700,&lt;br /&gt;
[&amp;quot;Country_data_New_York_(state)&amp;quot;] = 5300,&lt;br /&gt;
[&amp;quot;Country_data_New_Zealand&amp;quot;] = 51000,&lt;br /&gt;
[&amp;quot;Country_data_Newfoundland_and_Labrador&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_data_Nicaragua&amp;quot;] = 8200,&lt;br /&gt;
[&amp;quot;Country_data_Niger&amp;quot;] = 4900,&lt;br /&gt;
[&amp;quot;Country_data_Nigeria&amp;quot;] = 26000,&lt;br /&gt;
[&amp;quot;Country_data_North_Carolina&amp;quot;] = 3300,&lt;br /&gt;
[&amp;quot;Country_data_North_Korea&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Country_data_North_Macedonia&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Country_data_Northern_Ireland&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Country_data_Northern_Mariana_Islands&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;Country_data_Norway&amp;quot;] = 57000,&lt;br /&gt;
[&amp;quot;Country_data_Nova_Scotia&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_data_OMA&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;Country_data_Ohio&amp;quot;] = 4800,&lt;br /&gt;
[&amp;quot;Country_data_Oman&amp;quot;] = 7600,&lt;br /&gt;
[&amp;quot;Country_data_Ontario&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;Country_data_Ottoman_Empire&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;Country_data_PAK&amp;quot;] = 7400,&lt;br /&gt;
[&amp;quot;Country_data_PAN&amp;quot;] = 6000,&lt;br /&gt;
[&amp;quot;Country_data_PAR&amp;quot;] = 9100,&lt;br /&gt;
[&amp;quot;Country_data_PER&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Country_data_PHI&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Country_data_PHL&amp;quot;] = 3000,&lt;br /&gt;
[&amp;quot;Country_data_PNG&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;Country_data_POL&amp;quot;] = 42000,&lt;br /&gt;
[&amp;quot;Country_data_POR&amp;quot;] = 26000,&lt;br /&gt;
[&amp;quot;Country_data_PRC&amp;quot;] = 3000,&lt;br /&gt;
[&amp;quot;Country_data_PRK&amp;quot;] = 4200,&lt;br /&gt;
[&amp;quot;Country_data_PRT&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Country_data_PUR&amp;quot;] = 7700,&lt;br /&gt;
[&amp;quot;Country_data_Pakistan&amp;quot;] = 25000,&lt;br /&gt;
[&amp;quot;Country_data_Palau&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Country_data_Palestine&amp;quot;] = 5800,&lt;br /&gt;
[&amp;quot;Country_data_Panama&amp;quot;] = 14000,&lt;br /&gt;
[&amp;quot;Country_data_Papua_New_Guinea&amp;quot;] = 7000,&lt;br /&gt;
[&amp;quot;Country_data_Paraguay&amp;quot;] = 17000,&lt;br /&gt;
[&amp;quot;Country_data_Pennsylvania&amp;quot;] = 3300,&lt;br /&gt;
[&amp;quot;Country_data_People&#039;s_Republic_of_China&amp;quot;] = 2900,&lt;br /&gt;
[&amp;quot;Country_data_Peru&amp;quot;] = 26000,&lt;br /&gt;
[&amp;quot;Country_data_Philippines&amp;quot;] = 30000,&lt;br /&gt;
[&amp;quot;Country_data_Poland&amp;quot;] = 127000,&lt;br /&gt;
[&amp;quot;Country_data_Portugal&amp;quot;] = 52000,&lt;br /&gt;
[&amp;quot;Country_data_Prussia&amp;quot;] = 2300,&lt;br /&gt;
[&amp;quot;Country_data_Puerto_Rico&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Country_data_QAT&amp;quot;] = 6400,&lt;br /&gt;
[&amp;quot;Country_data_Qatar&amp;quot;] = 14000,&lt;br /&gt;
[&amp;quot;Country_data_Quebec&amp;quot;] = 3900,&lt;br /&gt;
[&amp;quot;Country_data_ROC&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;Country_data_ROM&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Country_data_ROU&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;Country_data_RSA&amp;quot;] = 28000,&lt;br /&gt;
[&amp;quot;Country_data_RUS&amp;quot;] = 56000,&lt;br /&gt;
[&amp;quot;Country_data_Republic_of_China&amp;quot;] = 6100,&lt;br /&gt;
[&amp;quot;Country_data_Republic_of_Ireland&amp;quot;] = 20000,&lt;br /&gt;
[&amp;quot;Country_data_Republic_of_the_Congo&amp;quot;] = 6500,&lt;br /&gt;
[&amp;quot;Country_data_Romania&amp;quot;] = 54000,&lt;br /&gt;
[&amp;quot;Country_data_Russia&amp;quot;] = 95000,&lt;br /&gt;
[&amp;quot;Country_data_Russian_Empire&amp;quot;] = 4100,&lt;br /&gt;
[&amp;quot;Country_data_Rwanda&amp;quot;] = 6100,&lt;br /&gt;
[&amp;quot;Country_data_SAM&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;Country_data_SCG&amp;quot;] = 2900,&lt;br /&gt;
[&amp;quot;Country_data_SCO&amp;quot;] = 22000,&lt;br /&gt;
[&amp;quot;Country_data_SEN&amp;quot;] = 6200,&lt;br /&gt;
[&amp;quot;Country_data_SER&amp;quot;] = 3200,&lt;br /&gt;
[&amp;quot;Country_data_SGP&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_data_SIN&amp;quot;] = 6800,&lt;br /&gt;
[&amp;quot;Country_data_SLO&amp;quot;] = 17000,&lt;br /&gt;
[&amp;quot;Country_data_SLV&amp;quot;] = 2900,&lt;br /&gt;
[&amp;quot;Country_data_SMR&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Country_data_SPA&amp;quot;] = 3800,&lt;br /&gt;
[&amp;quot;Country_data_SRB&amp;quot;] = 22000,&lt;br /&gt;
[&amp;quot;Country_data_SRI&amp;quot;] = 4300,&lt;br /&gt;
[&amp;quot;Country_data_SUI&amp;quot;] = 36000,&lt;br /&gt;
[&amp;quot;Country_data_SVK&amp;quot;] = 25000,&lt;br /&gt;
[&amp;quot;Country_data_SVN&amp;quot;] = 5600,&lt;br /&gt;
[&amp;quot;Country_data_SWE&amp;quot;] = 49000,&lt;br /&gt;
[&amp;quot;Country_data_SWI&amp;quot;] = 4400,&lt;br /&gt;
[&amp;quot;Country_data_SYR&amp;quot;] = 3100,&lt;br /&gt;
[&amp;quot;Country_data_Saint_Kitts_and_Nevis&amp;quot;] = 4200,&lt;br /&gt;
[&amp;quot;Country_data_Saint_Lucia&amp;quot;] = 4600,&lt;br /&gt;
[&amp;quot;Country_data_Saint_Vincent_and_the_Grenadines&amp;quot;] = 4300,&lt;br /&gt;
[&amp;quot;Country_data_Samoa&amp;quot;] = 6700,&lt;br /&gt;
[&amp;quot;Country_data_San_Marino&amp;quot;] = 7200,&lt;br /&gt;
[&amp;quot;Country_data_Saskatchewan&amp;quot;] = 3500,&lt;br /&gt;
[&amp;quot;Country_data_Saudi_Arabia&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Country_data_Scotland&amp;quot;] = 42000,&lt;br /&gt;
[&amp;quot;Country_data_Senegal&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Country_data_Serbia&amp;quot;] = 44000,&lt;br /&gt;
[&amp;quot;Country_data_Serbia_and_Montenegro&amp;quot;] = 4600,&lt;br /&gt;
[&amp;quot;Country_data_Seychelles&amp;quot;] = 4500,&lt;br /&gt;
[&amp;quot;Country_data_Sierra_Leone&amp;quot;] = 6000,&lt;br /&gt;
[&amp;quot;Country_data_Singapore&amp;quot;] = 22000,&lt;br /&gt;
[&amp;quot;Country_data_Slovakia&amp;quot;] = 41000,&lt;br /&gt;
[&amp;quot;Country_data_Slovenia&amp;quot;] = 34000,&lt;br /&gt;
[&amp;quot;Country_data_Solomon_Islands&amp;quot;] = 4200,&lt;br /&gt;
[&amp;quot;Country_data_Somalia&amp;quot;] = 5100,&lt;br /&gt;
[&amp;quot;Country_data_South_Africa&amp;quot;] = 54000,&lt;br /&gt;
[&amp;quot;Country_data_South_Carolina&amp;quot;] = 3200,&lt;br /&gt;
[&amp;quot;Country_data_South_Korea&amp;quot;] = 51000,&lt;br /&gt;
[&amp;quot;Country_data_South_Sudan&amp;quot;] = 2900,&lt;br /&gt;
[&amp;quot;Country_data_Soviet_Union&amp;quot;] = 28000,&lt;br /&gt;
[&amp;quot;Country_data_Spain&amp;quot;] = 107000,&lt;br /&gt;
[&amp;quot;Country_data_Sri_Lanka&amp;quot;] = 16000,&lt;br /&gt;
[&amp;quot;Country_data_Sudan&amp;quot;] = 6700,&lt;br /&gt;
[&amp;quot;Country_data_Suriname&amp;quot;] = 5400,&lt;br /&gt;
[&amp;quot;Country_data_Sweden&amp;quot;] = 83000,&lt;br /&gt;
[&amp;quot;Country_data_Switzerland&amp;quot;] = 66000,&lt;br /&gt;
[&amp;quot;Country_data_Syria&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Country_data_São_Tomé_and_Príncipe&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Country_data_TAN&amp;quot;] = 2200,&lt;br /&gt;
[&amp;quot;Country_data_TCH&amp;quot;] = 9000,&lt;br /&gt;
[&amp;quot;Country_data_THA&amp;quot;] = 19000,&lt;br /&gt;
[&amp;quot;Country_data_TJK&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_data_TKM&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Country_data_TPE&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Country_data_TRI&amp;quot;] = 4600,&lt;br /&gt;
[&amp;quot;Country_data_TUN&amp;quot;] = 8400,&lt;br /&gt;
[&amp;quot;Country_data_TUR&amp;quot;] = 23000,&lt;br /&gt;
[&amp;quot;Country_data_Taiwan&amp;quot;] = 9900,&lt;br /&gt;
[&amp;quot;Country_data_Tajikistan&amp;quot;] = 7700,&lt;br /&gt;
[&amp;quot;Country_data_Tanzania&amp;quot;] = 8900,&lt;br /&gt;
[&amp;quot;Country_data_Texas&amp;quot;] = 5200,&lt;br /&gt;
[&amp;quot;Country_data_Thailand&amp;quot;] = 36000,&lt;br /&gt;
[&amp;quot;Country_data_Togo&amp;quot;] = 5600,&lt;br /&gt;
[&amp;quot;Country_data_Tonga&amp;quot;] = 5700,&lt;br /&gt;
[&amp;quot;Country_data_Trinidad_and_Tobago&amp;quot;] = 12000,&lt;br /&gt;
[&amp;quot;Country_data_Tunisia&amp;quot;] = 17000,&lt;br /&gt;
[&amp;quot;Country_data_Turkey&amp;quot;] = 64000,&lt;br /&gt;
[&amp;quot;Country_data_Turkmenistan&amp;quot;] = 6700,&lt;br /&gt;
[&amp;quot;Country_data_Turks_and_Caicos_Islands&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Country_data_Tuvalu&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;Country_data_U.S._Virgin_Islands&amp;quot;] = 4400,&lt;br /&gt;
[&amp;quot;Country_data_UAE&amp;quot;] = 8000,&lt;br /&gt;
[&amp;quot;Country_data_UGA&amp;quot;] = 3300,&lt;br /&gt;
[&amp;quot;Country_data_UK&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;Country_data_UKGBI&amp;quot;] = 2400,&lt;br /&gt;
[&amp;quot;Country_data_UKR&amp;quot;] = 31000,&lt;br /&gt;
[&amp;quot;Country_data_URS&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Country_data_URU&amp;quot;] = 13000,&lt;br /&gt;
[&amp;quot;Country_data_US&amp;quot;] = 5300,&lt;br /&gt;
[&amp;quot;Country_data_USA&amp;quot;] = 122000,&lt;br /&gt;
[&amp;quot;Country_data_USSR&amp;quot;] = 4300,&lt;br /&gt;
[&amp;quot;Country_data_UZB&amp;quot;] = 9300,&lt;br /&gt;
[&amp;quot;Country_data_Uganda&amp;quot;] = 10000,&lt;br /&gt;
[&amp;quot;Country_data_Ukraine&amp;quot;] = 52000,&lt;br /&gt;
[&amp;quot;Country_data_United_Arab_Emirates&amp;quot;] = 16000,&lt;br /&gt;
[&amp;quot;Country_data_United_Kingdom&amp;quot;] = 77000,&lt;br /&gt;
[&amp;quot;Country_data_United_Kingdom_of_Great_Britain_and_Ireland&amp;quot;] = 3600,&lt;br /&gt;
[&amp;quot;Country_data_United_Nations&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;Country_data_United_States&amp;quot;] = 255000,&lt;br /&gt;
[&amp;quot;Country_data_United_States_of_America&amp;quot;] = 4700,&lt;br /&gt;
[&amp;quot;Country_data_Uruguay&amp;quot;] = 24000,&lt;br /&gt;
[&amp;quot;Country_data_Uzbekistan&amp;quot;] = 16000,&lt;br /&gt;
[&amp;quot;Country_data_VEN&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Country_data_VIE&amp;quot;] = 5500,&lt;br /&gt;
[&amp;quot;Country_data_Vanuatu&amp;quot;] = 4500,&lt;br /&gt;
[&amp;quot;Country_data_Vatican_City&amp;quot;] = 2100,&lt;br /&gt;
[&amp;quot;Country_data_Venezuela&amp;quot;] = 27000,&lt;br /&gt;
[&amp;quot;Country_data_Vietnam&amp;quot;] = 18000,&lt;br /&gt;
[&amp;quot;Country_data_Virginia&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Country_data_WAL&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Country_data_Wales&amp;quot;] = 28000,&lt;br /&gt;
[&amp;quot;Country_data_Washington&amp;quot;] = 3200,&lt;br /&gt;
[&amp;quot;Country_data_Washington,_D.C.&amp;quot;] = 2200,&lt;br /&gt;
[&amp;quot;Country_data_Washington_(state)&amp;quot;] = 3400,&lt;br /&gt;
[&amp;quot;Country_data_West_Germany&amp;quot;] = 18000,&lt;br /&gt;
[&amp;quot;Country_data_West_Indies&amp;quot;] = 2200,&lt;br /&gt;
[&amp;quot;Country_data_Wisconsin&amp;quot;] = 5600,&lt;br /&gt;
[&amp;quot;Country_data_Wyoming&amp;quot;] = 2000,&lt;br /&gt;
[&amp;quot;Country_data_YUG&amp;quot;] = 8200,&lt;br /&gt;
[&amp;quot;Country_data_Yemen&amp;quot;] = 6300,&lt;br /&gt;
[&amp;quot;Country_data_Yugoslavia&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Country_data_ZAF&amp;quot;] = 4200,&lt;br /&gt;
[&amp;quot;Country_data_ZAM&amp;quot;] = 2600,&lt;br /&gt;
[&amp;quot;Country_data_ZIM&amp;quot;] = 7200,&lt;br /&gt;
[&amp;quot;Country_data_Zambia&amp;quot;] = 8000,&lt;br /&gt;
[&amp;quot;Country_data_Zimbabwe&amp;quot;] = 14000,&lt;br /&gt;
[&amp;quot;Country_flagbio&amp;quot;] = 22000,&lt;br /&gt;
[&amp;quot;Country_name&amp;quot;] = 9100,&lt;br /&gt;
[&amp;quot;Country_showdata&amp;quot;] = 5500,&lt;br /&gt;
[&amp;quot;Country_topics&amp;quot;] = 20000,&lt;br /&gt;
[&amp;quot;County&amp;quot;] = 7300,&lt;br /&gt;
[&amp;quot;County_(judet)_of_Romania&amp;quot;] = 3300,&lt;br /&gt;
[&amp;quot;Course_assignment&amp;quot;] = 4300,&lt;br /&gt;
[&amp;quot;Course_details&amp;quot;] = 4600,&lt;br /&gt;
[&amp;quot;Cquote&amp;quot;] = 36000,&lt;br /&gt;
[&amp;quot;Cr&amp;quot;] = 3700,&lt;br /&gt;
[&amp;quot;Create_taxonomy/link&amp;quot;] = 80000,&lt;br /&gt;
[&amp;quot;Cricinfo&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;Cricketarchive&amp;quot;] = 3100,&lt;br /&gt;
[&amp;quot;Crime_opentask&amp;quot;] = 30000,&lt;br /&gt;
[&amp;quot;Cross&amp;quot;] = 3300,&lt;br /&gt;
[&amp;quot;Crossreference&amp;quot;] = 2000,&lt;br /&gt;
[&amp;quot;Crossreference/styles.css&amp;quot;] = 2000,&lt;br /&gt;
[&amp;quot;Csv&amp;quot;] = 2700,&lt;br /&gt;
[&amp;quot;Ct&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Curlie&amp;quot;] = 7000,&lt;br /&gt;
[&amp;quot;Current_events_footer&amp;quot;] = 6100,&lt;br /&gt;
[&amp;quot;Current_events_header&amp;quot;] = 7100,&lt;br /&gt;
[&amp;quot;Currentdate&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;Cvt&amp;quot;] = 65000,&lt;br /&gt;
[&amp;quot;Cycling_Archives&amp;quot;] = 5800,&lt;br /&gt;
[&amp;quot;Cycling_archives&amp;quot;] = 4000,&lt;br /&gt;
[&amp;quot;Cycling_team_link&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Module:CFB_schedule&amp;quot;] = 21000,&lt;br /&gt;
[&amp;quot;Module:CallAssert&amp;quot;] = 202000,&lt;br /&gt;
[&amp;quot;Module:CanElecResTopTest&amp;quot;] = 4300,&lt;br /&gt;
[&amp;quot;Module:CanadaByProvinceCatNav&amp;quot;] = 9300,&lt;br /&gt;
[&amp;quot;Module:Cat_main&amp;quot;] = 164000,&lt;br /&gt;
[&amp;quot;Module:Cat_more_if_exists&amp;quot;] = 40000,&lt;br /&gt;
[&amp;quot;Module:Catalog_lookup_link&amp;quot;] = 476000,&lt;br /&gt;
[&amp;quot;Module:Category_described_in_year&amp;quot;] = 5400,&lt;br /&gt;
[&amp;quot;Module:Category_described_in_year/conf&amp;quot;] = 5400,&lt;br /&gt;
[&amp;quot;Module:Category_handler&amp;quot;] = 4120000,&lt;br /&gt;
[&amp;quot;Module:Category_handler/blacklist&amp;quot;] = 4120000,&lt;br /&gt;
[&amp;quot;Module:Category_handler/config&amp;quot;] = 4120000,&lt;br /&gt;
[&amp;quot;Module:Category_handler/data&amp;quot;] = 4120000,&lt;br /&gt;
[&amp;quot;Module:Category_handler/shared&amp;quot;] = 4120000,&lt;br /&gt;
[&amp;quot;Module:Category_see_also&amp;quot;] = 38000,&lt;br /&gt;
[&amp;quot;Module:Celestial_object_quadrangle&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Module:Check_DYK_hook&amp;quot;] = 105000,&lt;br /&gt;
[&amp;quot;Module:Check_for_clobbered_parameters&amp;quot;] = 572000,&lt;br /&gt;
[&amp;quot;Module:Check_for_deprecated_parameters&amp;quot;] = 364000,&lt;br /&gt;
[&amp;quot;Module:Check_for_unknown_parameters&amp;quot;] = 11500000,&lt;br /&gt;
[&amp;quot;Module:Check_isxn&amp;quot;] = 469000,&lt;br /&gt;
[&amp;quot;Module:Check_winner_by_scores&amp;quot;] = 11000,&lt;br /&gt;
[&amp;quot;Module:Citation/CS1&amp;quot;] = 4800000,&lt;br /&gt;
[&amp;quot;Module:Citation/CS1/COinS&amp;quot;] = 4800000,&lt;br /&gt;
[&amp;quot;Module:Citation/CS1/Configuration&amp;quot;] = 4800000,&lt;br /&gt;
[&amp;quot;Module:Citation/CS1/Date_validation&amp;quot;] = 4800000,&lt;br /&gt;
[&amp;quot;Module:Citation/CS1/Identifiers&amp;quot;] = 4800000,&lt;br /&gt;
[&amp;quot;Module:Citation/CS1/Suggestions&amp;quot;] = 29000,&lt;br /&gt;
[&amp;quot;Module:Citation/CS1/Utilities&amp;quot;] = 4800000,&lt;br /&gt;
[&amp;quot;Module:Citation/CS1/Whitelist&amp;quot;] = 4800000,&lt;br /&gt;
[&amp;quot;Module:Citation/CS1/styles.css&amp;quot;] = 4920000,&lt;br /&gt;
[&amp;quot;Module:Cite_Q&amp;quot;] = 45000,&lt;br /&gt;
[&amp;quot;Module:Cite_iucn&amp;quot;] = 32000,&lt;br /&gt;
[&amp;quot;Module:Clade&amp;quot;] = 5500,&lt;br /&gt;
[&amp;quot;Module:Clickable_button_2&amp;quot;] = 771000,&lt;br /&gt;
[&amp;quot;Module:Collapsible_list&amp;quot;] = 47000,&lt;br /&gt;
[&amp;quot;Module:College_color&amp;quot;] = 111000,&lt;br /&gt;
[&amp;quot;Module:College_color/data&amp;quot;] = 111000,&lt;br /&gt;
[&amp;quot;Module:Color_contrast&amp;quot;] = 447000,&lt;br /&gt;
[&amp;quot;Module:Color_contrast/colors&amp;quot;] = 449000,&lt;br /&gt;
[&amp;quot;Module:Commons_link&amp;quot;] = 91000,&lt;br /&gt;
[&amp;quot;Module:Complex_date&amp;quot;] = 61000,&lt;br /&gt;
[&amp;quot;Module:Convert&amp;quot;] = 1100000,&lt;br /&gt;
[&amp;quot;Module:Convert/data&amp;quot;] = 1100000,&lt;br /&gt;
[&amp;quot;Module:Convert/helper&amp;quot;] = 6000,&lt;br /&gt;
[&amp;quot;Module:Convert/text&amp;quot;] = 1100000,&lt;br /&gt;
[&amp;quot;Module:Convert/wikidata&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Module:Convert/wikidata/data&amp;quot;] = 2500,&lt;br /&gt;
[&amp;quot;Module:ConvertNumeric&amp;quot;] = 24000,&lt;br /&gt;
[&amp;quot;Module:Convert_character_width&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Module:Convert_character_width/data&amp;quot;] = 2800,&lt;br /&gt;
[&amp;quot;Module:Coordinates&amp;quot;] = 1260000,&lt;br /&gt;
[&amp;quot;Module:Coordinates/styles.css&amp;quot;] = 1220000,&lt;br /&gt;
[&amp;quot;Module:Copied&amp;quot;] = 15000,&lt;br /&gt;
[&amp;quot;Module:CountryAdjectiveDemonym&amp;quot;] = 39000,&lt;br /&gt;
[&amp;quot;Module:CountryAdjectiveDemonym/Adjectives&amp;quot;] = 39000,&lt;br /&gt;
[&amp;quot;Module:CountryAdjectiveDemonym/Demonyms&amp;quot;] = 39000,&lt;br /&gt;
[&amp;quot;Module:CountryAdjectiveDemonym/The&amp;quot;] = 39000,&lt;br /&gt;
[&amp;quot;Module:CountryData&amp;quot;] = 17000,&lt;br /&gt;
[&amp;quot;Module:Country_adjective&amp;quot;] = 3700,&lt;br /&gt;
[&amp;quot;Module:Country_alias&amp;quot;] = 45000,&lt;br /&gt;
[&amp;quot;Module:Country_alias/data&amp;quot;] = 45000,&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Transclusion_count&amp;diff=649</id>
		<title>Module:Transclusion count</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Transclusion_count&amp;diff=649"/>
		<updated>2021-04-26T10:44:14Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.fetch(frame)&lt;br /&gt;
	local template = nil&lt;br /&gt;
	local return_value = nil&lt;br /&gt;
&lt;br /&gt;
	-- Use demo parameter if it exists, otherswise use current template name&lt;br /&gt;
	local namespace = mw.title.getCurrentTitle().namespace&lt;br /&gt;
	if frame.args[&amp;quot;demo&amp;quot;] and frame.args[&amp;quot;demo&amp;quot;] ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		template = frame.args[&amp;quot;demo&amp;quot;]&lt;br /&gt;
	elseif namespace == 10 then -- Template namespace&lt;br /&gt;
		template = mw.title.getCurrentTitle().text&lt;br /&gt;
	elseif namespace == 828 then -- Module namespace&lt;br /&gt;
		template = (mw.site.namespaces[828].name .. &amp;quot;:&amp;quot; .. mw.title.getCurrentTitle().text)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- If in template or module namespace, look up count in /data&lt;br /&gt;
	if template ~= nil then&lt;br /&gt;
		namespace = mw.title.new(template, &amp;quot;Template&amp;quot;).namespace&lt;br /&gt;
		if namespace == 10 or namespace == 828 then&lt;br /&gt;
			template =  mw.ustring.gsub(template, &amp;quot;/doc$&amp;quot;, &amp;quot;&amp;quot;) -- strip /doc from end&lt;br /&gt;
			local index = mw.ustring.sub(mw.title.new(template).text,1,1)&lt;br /&gt;
			local data = mw.loadData(&#039;Module:Transclusion_count/data/&#039; .. (mw.ustring.find(index, &amp;quot;%a&amp;quot;) and index or &amp;quot;other&amp;quot;))&lt;br /&gt;
			return_value = tonumber(data[mw.ustring.gsub(template, &amp;quot; &amp;quot;, &amp;quot;_&amp;quot;)])&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- If database value doesn&#039;t exist, use value passed to template&lt;br /&gt;
	if return_value == nil and frame.args[1] ~= nil then&lt;br /&gt;
		local arg1=mw.ustring.match(frame.args[1], &#039;[%d,]+&#039;)&lt;br /&gt;
		if arg1 and arg1 ~= &#039;&#039; then&lt;br /&gt;
			return_value = tonumber(frame:callParserFunction(&#039;formatnum&#039;, arg1, &#039;R&#039;))&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return return_value	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:TableTools&amp;diff=647</id>
		<title>Module:TableTools</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:TableTools&amp;diff=647"/>
		<updated>2021-04-26T10:44:14Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
--                               TableTools                                       --&lt;br /&gt;
--                                                                                --&lt;br /&gt;
-- This module includes a number of functions for dealing with Lua tables.        --&lt;br /&gt;
-- It is a meta-module, meant to be called from other Lua modules, and should     --&lt;br /&gt;
-- not be called directly from #invoke.                                           --&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
local libraryUtil = require(&#039;libraryUtil&#039;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- Define often-used variables and functions.&lt;br /&gt;
local floor = math.floor&lt;br /&gt;
local infinity = math.huge&lt;br /&gt;
local checkType = libraryUtil.checkType&lt;br /&gt;
local checkTypeMulti = libraryUtil.checkTypeMulti&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
-- isPositiveInteger&lt;br /&gt;
--&lt;br /&gt;
-- This function returns true if the given value is a positive integer, and false&lt;br /&gt;
-- if not. Although it doesn&#039;t operate on tables, it is included here as it is&lt;br /&gt;
-- useful for determining whether a given table key is in the array part or the&lt;br /&gt;
-- hash part of a table.&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
--]]&lt;br /&gt;
function p.isPositiveInteger(v)&lt;br /&gt;
	return type(v) == &#039;number&#039; and v &amp;gt;= 1 and floor(v) == v and v &amp;lt; infinity&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
-- isNan&lt;br /&gt;
--&lt;br /&gt;
-- This function returns true if the given number is a NaN value, and false&lt;br /&gt;
-- if not. Although it doesn&#039;t operate on tables, it is included here as it is&lt;br /&gt;
-- useful for determining whether a value can be a valid table key. Lua will&lt;br /&gt;
-- generate an error if a NaN is used as a table key.&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
--]]&lt;br /&gt;
function p.isNan(v)&lt;br /&gt;
	return type(v) == &#039;number&#039; and tostring(v) == &#039;-nan&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
-- shallowClone&lt;br /&gt;
--&lt;br /&gt;
-- This returns a clone of a table. The value returned is a new table, but all&lt;br /&gt;
-- subtables and functions are shared. Metamethods are respected, but the returned&lt;br /&gt;
-- table will have no metatable of its own.&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
--]]&lt;br /&gt;
function p.shallowClone(t)&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	for k, v in pairs(t) do&lt;br /&gt;
		ret[k] = v&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
-- removeDuplicates&lt;br /&gt;
--&lt;br /&gt;
-- This removes duplicate values from an array. Non-positive-integer keys are&lt;br /&gt;
-- ignored. The earliest value is kept, and all subsequent duplicate values are&lt;br /&gt;
-- removed, but otherwise the array order is unchanged.&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
--]]&lt;br /&gt;
function p.removeDuplicates(t)&lt;br /&gt;
	checkType(&#039;removeDuplicates&#039;, 1, t, &#039;table&#039;)&lt;br /&gt;
	local isNan = p.isNan&lt;br /&gt;
	local ret, exists = {}, {}&lt;br /&gt;
	for i, v in ipairs(t) do&lt;br /&gt;
		if isNan(v) then&lt;br /&gt;
			-- NaNs can&#039;t be table keys, and they are also unique, so we don&#039;t need to check existence.&lt;br /&gt;
			ret[#ret + 1] = v&lt;br /&gt;
		else&lt;br /&gt;
			if not exists[v] then&lt;br /&gt;
				ret[#ret + 1] = v&lt;br /&gt;
				exists[v] = true&lt;br /&gt;
			end&lt;br /&gt;
		end	&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end			&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
-- numKeys&lt;br /&gt;
--&lt;br /&gt;
-- This takes a table and returns an array containing the numbers of any numerical&lt;br /&gt;
-- keys that have non-nil values, sorted in numerical order.&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
--]]&lt;br /&gt;
function p.numKeys(t)&lt;br /&gt;
	checkType(&#039;numKeys&#039;, 1, t, &#039;table&#039;)&lt;br /&gt;
	local isPositiveInteger = p.isPositiveInteger&lt;br /&gt;
	local nums = {}&lt;br /&gt;
	for k, v in pairs(t) do&lt;br /&gt;
		if isPositiveInteger(k) then&lt;br /&gt;
			nums[#nums + 1] = k&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(nums)&lt;br /&gt;
	return nums&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
-- affixNums&lt;br /&gt;
--&lt;br /&gt;
-- This takes a table and returns an array containing the numbers of keys with the&lt;br /&gt;
-- specified prefix and suffix. For example, for the table&lt;br /&gt;
-- {a1 = &#039;foo&#039;, a3 = &#039;bar&#039;, a6 = &#039;baz&#039;} and the prefix &amp;quot;a&amp;quot;, affixNums will&lt;br /&gt;
-- return {1, 3, 6}.&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
--]]&lt;br /&gt;
function p.affixNums(t, prefix, suffix)&lt;br /&gt;
	checkType(&#039;affixNums&#039;, 1, t, &#039;table&#039;)&lt;br /&gt;
	checkType(&#039;affixNums&#039;, 2, prefix, &#039;string&#039;, true)&lt;br /&gt;
	checkType(&#039;affixNums&#039;, 3, suffix, &#039;string&#039;, true)&lt;br /&gt;
&lt;br /&gt;
	local function cleanPattern(s)&lt;br /&gt;
		-- Cleans a pattern so that the magic characters ()%.[]*+-?^$ are interpreted literally.&lt;br /&gt;
		return s:gsub(&#039;([%(%)%%%.%[%]%*%+%-%?%^%$])&#039;, &#039;%%%1&#039;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	prefix = prefix or &#039;&#039;&lt;br /&gt;
	suffix = suffix or &#039;&#039;&lt;br /&gt;
	prefix = cleanPattern(prefix)&lt;br /&gt;
	suffix = cleanPattern(suffix)&lt;br /&gt;
	local pattern = &#039;^&#039; .. prefix .. &#039;([1-9]%d*)&#039; .. suffix .. &#039;$&#039;&lt;br /&gt;
&lt;br /&gt;
	local nums = {}&lt;br /&gt;
	for k, v in pairs(t) do&lt;br /&gt;
		if type(k) == &#039;string&#039; then			&lt;br /&gt;
			local num = mw.ustring.match(k, pattern)&lt;br /&gt;
			if num then&lt;br /&gt;
				nums[#nums + 1] = tonumber(num)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(nums)&lt;br /&gt;
	return nums&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
-- numData&lt;br /&gt;
--&lt;br /&gt;
-- Given a table with keys like (&amp;quot;foo1&amp;quot;, &amp;quot;bar1&amp;quot;, &amp;quot;foo2&amp;quot;, &amp;quot;baz2&amp;quot;), returns a table&lt;br /&gt;
-- of subtables in the format &lt;br /&gt;
-- { [1] = {foo = &#039;text&#039;, bar = &#039;text&#039;}, [2] = {foo = &#039;text&#039;, baz = &#039;text&#039;} }&lt;br /&gt;
-- Keys that don&#039;t end with an integer are stored in a subtable named &amp;quot;other&amp;quot;.&lt;br /&gt;
-- The compress option compresses the table so that it can be iterated over with&lt;br /&gt;
-- ipairs.&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
--]]&lt;br /&gt;
function p.numData(t, compress)&lt;br /&gt;
	checkType(&#039;numData&#039;, 1, t, &#039;table&#039;)&lt;br /&gt;
	checkType(&#039;numData&#039;, 2, compress, &#039;boolean&#039;, true)&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	for k, v in pairs(t) do&lt;br /&gt;
		local prefix, num = mw.ustring.match(tostring(k), &#039;^([^0-9]*)([1-9][0-9]*)$&#039;)&lt;br /&gt;
		if num then&lt;br /&gt;
			num = tonumber(num)&lt;br /&gt;
			local subtable = ret[num] or {}&lt;br /&gt;
			if prefix == &#039;&#039; then&lt;br /&gt;
				-- Positional parameters match the blank string; put them at the start of the subtable instead.&lt;br /&gt;
				prefix = 1&lt;br /&gt;
			end&lt;br /&gt;
			subtable[prefix] = v&lt;br /&gt;
			ret[num] = subtable&lt;br /&gt;
		else&lt;br /&gt;
			local subtable = ret.other or {}&lt;br /&gt;
			subtable[k] = v&lt;br /&gt;
			ret.other = subtable&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if compress then&lt;br /&gt;
		local other = ret.other&lt;br /&gt;
		ret = p.compressSparseArray(ret)&lt;br /&gt;
		ret.other = other&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
-- compressSparseArray&lt;br /&gt;
--&lt;br /&gt;
-- This takes an array with one or more nil values, and removes the nil values&lt;br /&gt;
-- while preserving the order, so that the array can be safely traversed with&lt;br /&gt;
-- ipairs.&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
--]]&lt;br /&gt;
function p.compressSparseArray(t)&lt;br /&gt;
	checkType(&#039;compressSparseArray&#039;, 1, t, &#039;table&#039;)&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	local nums = p.numKeys(t)&lt;br /&gt;
	for _, num in ipairs(nums) do&lt;br /&gt;
		ret[#ret + 1] = t[num]&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
-- sparseIpairs&lt;br /&gt;
--&lt;br /&gt;
-- This is an iterator for sparse arrays. It can be used like ipairs, but can&lt;br /&gt;
-- handle nil values.&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
--]]&lt;br /&gt;
function p.sparseIpairs(t)&lt;br /&gt;
	checkType(&#039;sparseIpairs&#039;, 1, t, &#039;table&#039;)&lt;br /&gt;
	local nums = p.numKeys(t)&lt;br /&gt;
	local i = 0&lt;br /&gt;
	local lim = #nums&lt;br /&gt;
	return function ()&lt;br /&gt;
		i = i + 1&lt;br /&gt;
		if i &amp;lt;= lim then&lt;br /&gt;
			local key = nums[i]&lt;br /&gt;
			return key, t[key]&lt;br /&gt;
		else&lt;br /&gt;
			return nil, nil&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
-- size&lt;br /&gt;
--&lt;br /&gt;
-- This returns the size of a key/value pair table. It will also work on arrays,&lt;br /&gt;
-- but for arrays it is more efficient to use the # operator.&lt;br /&gt;
------------------------------------------------------------------------------------&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
function p.size(t)&lt;br /&gt;
	checkType(&#039;size&#039;, 1, t, &#039;table&#039;)&lt;br /&gt;
	local i = 0&lt;br /&gt;
	for k in pairs(t) do&lt;br /&gt;
		i = i + 1&lt;br /&gt;
	end&lt;br /&gt;
	return i&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function defaultKeySort(item1, item2)&lt;br /&gt;
	-- &amp;quot;number&amp;quot; &amp;lt; &amp;quot;string&amp;quot;, so numbers will be sorted before strings.&lt;br /&gt;
	local type1, type2 = type(item1), type(item2)&lt;br /&gt;
	if type1 ~= type2 then&lt;br /&gt;
		return type1 &amp;lt; type2&lt;br /&gt;
	else -- This will fail with table, boolean, function.&lt;br /&gt;
		return item1 &amp;lt; item2&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
	Returns a list of the keys in a table, sorted using either a default&lt;br /&gt;
	comparison function or a custom keySort function.&lt;br /&gt;
]]&lt;br /&gt;
function p.keysToList(t, keySort, checked)&lt;br /&gt;
	if not checked then&lt;br /&gt;
		checkType(&#039;keysToList&#039;, 1, t, &#039;table&#039;)&lt;br /&gt;
		checkTypeMulti(&#039;keysToList&#039;, 2, keySort, { &#039;function&#039;, &#039;boolean&#039;, &#039;nil&#039; })&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local list = {}&lt;br /&gt;
	local index = 1&lt;br /&gt;
	for key, value in pairs(t) do&lt;br /&gt;
		list[index] = key&lt;br /&gt;
		index = index + 1&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if keySort ~= false then&lt;br /&gt;
		keySort = type(keySort) == &#039;function&#039; and keySort or defaultKeySort&lt;br /&gt;
		&lt;br /&gt;
		table.sort(list, keySort)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return list&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
	Iterates through a table, with the keys sorted using the keysToList function.&lt;br /&gt;
	If there are only numerical keys, sparseIpairs is probably more efficient.&lt;br /&gt;
]]&lt;br /&gt;
function p.sortedPairs(t, keySort)&lt;br /&gt;
	checkType(&#039;sortedPairs&#039;, 1, t, &#039;table&#039;)&lt;br /&gt;
	checkType(&#039;sortedPairs&#039;, 2, keySort, &#039;function&#039;, true)&lt;br /&gt;
	&lt;br /&gt;
	local list = p.keysToList(t, keySort, true)&lt;br /&gt;
	&lt;br /&gt;
	local i = 0&lt;br /&gt;
	return function()&lt;br /&gt;
		i = i + 1&lt;br /&gt;
		local key = list[i]&lt;br /&gt;
		if key ~= nil then&lt;br /&gt;
			return key, t[key]&lt;br /&gt;
		else&lt;br /&gt;
			return nil, nil&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
	Returns true if all keys in the table are consecutive integers starting at 1.&lt;br /&gt;
--]]&lt;br /&gt;
function p.isArray(t)&lt;br /&gt;
	checkType(&amp;quot;isArray&amp;quot;, 1, t, &amp;quot;table&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	local i = 0&lt;br /&gt;
	for k, v in pairs(t) do&lt;br /&gt;
		i = i + 1&lt;br /&gt;
		if t[i] == nil then&lt;br /&gt;
			return false&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- { &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;, &amp;quot;c&amp;quot; } -&amp;gt; { a = 1, b = 2, c = 3 }&lt;br /&gt;
function p.invert(array)&lt;br /&gt;
	checkType(&amp;quot;invert&amp;quot;, 1, array, &amp;quot;table&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	local map = {}&lt;br /&gt;
	for i, v in ipairs(array) do&lt;br /&gt;
		map[v] = i&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return map&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
	{ &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;, &amp;quot;c&amp;quot; } -&amp;gt; { [&amp;quot;a&amp;quot;] = true, [&amp;quot;b&amp;quot;] = true, [&amp;quot;c&amp;quot;] = true }&lt;br /&gt;
--]]&lt;br /&gt;
function p.listToSet(t)&lt;br /&gt;
	checkType(&amp;quot;listToSet&amp;quot;, 1, t, &amp;quot;table&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	local set = {}&lt;br /&gt;
	for _, item in ipairs(t) do&lt;br /&gt;
		set[item] = true&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return set&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
	Recursive deep copy function.&lt;br /&gt;
	Preserves identities of subtables.&lt;br /&gt;
	&lt;br /&gt;
]]&lt;br /&gt;
local function _deepCopy(orig, includeMetatable, already_seen)&lt;br /&gt;
	-- Stores copies of tables indexed by the original table.&lt;br /&gt;
	already_seen = already_seen or {}&lt;br /&gt;
	&lt;br /&gt;
	local copy = already_seen[orig]&lt;br /&gt;
	if copy ~= nil then&lt;br /&gt;
		return copy&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if type(orig) == &#039;table&#039; then&lt;br /&gt;
		copy = {}&lt;br /&gt;
		for orig_key, orig_value in pairs(orig) do&lt;br /&gt;
			copy[deepcopy(orig_key, includeMetatable, already_seen)] = deepcopy(orig_value, includeMetatable, already_seen)&lt;br /&gt;
		end&lt;br /&gt;
		already_seen[orig] = copy&lt;br /&gt;
		&lt;br /&gt;
		if includeMetatable then&lt;br /&gt;
			local mt = getmetatable(orig)&lt;br /&gt;
			if mt ~= nil then&lt;br /&gt;
				local mt_copy = deepcopy(mt, includeMetatable, already_seen)&lt;br /&gt;
				setmetatable(copy, mt_copy)&lt;br /&gt;
				already_seen[mt] = mt_copy&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else -- number, string, boolean, etc&lt;br /&gt;
		copy = orig&lt;br /&gt;
	end&lt;br /&gt;
	return copy&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.deepCopy(orig, noMetatable, already_seen)&lt;br /&gt;
	checkType(&amp;quot;deepCopy&amp;quot;, 3, already_seen, &amp;quot;table&amp;quot;, true)&lt;br /&gt;
	&lt;br /&gt;
	return _deepCopy(orig, not noMetatable, already_seen)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
	Concatenates all values in the table that are indexed by a number, in order.&lt;br /&gt;
	sparseConcat{ a, nil, c, d }  =&amp;gt;  &amp;quot;acd&amp;quot;&lt;br /&gt;
	sparseConcat{ nil, b, c, d }  =&amp;gt;  &amp;quot;bcd&amp;quot;&lt;br /&gt;
]]&lt;br /&gt;
function p.sparseConcat(t, sep, i, j)&lt;br /&gt;
	local list = {}&lt;br /&gt;
	&lt;br /&gt;
	local list_i = 0&lt;br /&gt;
	for _, v in p.sparseIpairs(t) do&lt;br /&gt;
		list_i = list_i + 1&lt;br /&gt;
		list[list_i] = v&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return table.concat(list, sep, i, j)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- Finds the length of an array, or of a quasi-array with keys such&lt;br /&gt;
-- as &amp;quot;data1&amp;quot;, &amp;quot;data2&amp;quot;, etc., using an exponential search algorithm. &lt;br /&gt;
-- It is similar to the operator #, but may return&lt;br /&gt;
-- a different value when there are gaps in the array portion of the table.&lt;br /&gt;
-- Intended to be used on data loaded with mw.loadData. For other tables, use #.&lt;br /&gt;
-- Note: #frame.args in frame object always be set to 0, regardless of &lt;br /&gt;
-- the number of unnamed template parameters, so use this function for&lt;br /&gt;
-- frame.args.&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
function p.length(t, prefix)&lt;br /&gt;
	-- requiring module inline so that [[Module:Exponential search]]&lt;br /&gt;
	-- which is only needed by this one function&lt;br /&gt;
	-- doesn&#039;t get millions of transclusions&lt;br /&gt;
	local expSearch = require(&amp;quot;Module:Exponential search&amp;quot;)&lt;br /&gt;
	checkType(&#039;length&#039;, 1, t, &#039;table&#039;)&lt;br /&gt;
	checkType(&#039;length&#039;, 2, prefix, &#039;string&#039;, true)&lt;br /&gt;
	return expSearch(function(i)&lt;br /&gt;
		local key&lt;br /&gt;
		if prefix then&lt;br /&gt;
			key = prefix .. tostring(i)&lt;br /&gt;
		else&lt;br /&gt;
			key = i&lt;br /&gt;
		end&lt;br /&gt;
		return t[key] ~= nil&lt;br /&gt;
	end) or 0&lt;br /&gt;
end&lt;br /&gt;
function p.inArray(arr, valueToFind)&lt;br /&gt;
	checkType(&amp;quot;inArray&amp;quot;, 1, arr, &amp;quot;table&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	-- if valueToFind is nil, error?&lt;br /&gt;
	&lt;br /&gt;
	for _, v in ipairs(arr) do&lt;br /&gt;
		if v == valueToFind then&lt;br /&gt;
			return true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:TNT&amp;diff=645</id>
		<title>Module:TNT</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:TNT&amp;diff=645"/>
		<updated>2021-04-26T10:44:14Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--&lt;br /&gt;
-- INTRO:   (!!! DO NOT RENAME THIS PAGE !!!)&lt;br /&gt;
--    This module allows any template or module to be copy/pasted between&lt;br /&gt;
--    wikis without any translation changes. All translation text is stored&lt;br /&gt;
--    in the global  Data:*.tab  pages on Commons, and used everywhere.&lt;br /&gt;
--&lt;br /&gt;
-- SEE:   https://www.mediawiki.org/wiki/Multilingual_Templates_and_Modules&lt;br /&gt;
--&lt;br /&gt;
-- ATTENTION:&lt;br /&gt;
--    Please do NOT rename this module - it has to be identical on all wikis.&lt;br /&gt;
--    This code is maintained at https://www.mediawiki.org/wiki/Module:TNT&lt;br /&gt;
--    Please do not modify it anywhere else, as it may get copied and override your changes.&lt;br /&gt;
--    Suggestions can be made at https://www.mediawiki.org/wiki/Module_talk:TNT&lt;br /&gt;
--&lt;br /&gt;
-- DESCRIPTION:&lt;br /&gt;
--    The &amp;quot;msg&amp;quot; function uses a Commons dataset to translate a message&lt;br /&gt;
--    with a given key (e.g. source-table), plus optional arguments&lt;br /&gt;
--    to the wiki markup in the current content language.&lt;br /&gt;
--    Use lang=xx to set language.  Example:&lt;br /&gt;
--&lt;br /&gt;
--    {{#invoke:TNT | msg&lt;br /&gt;
--     | I18n/Template:Graphs.tab  &amp;lt;!-- https://commons.wikimedia.org/wiki/Data:I18n/Template:Graphs.tab --&amp;gt;&lt;br /&gt;
--     | source-table              &amp;lt;!-- uses a translation message with id = &amp;quot;source-table&amp;quot; --&amp;gt;&lt;br /&gt;
--     | param1 }}                 &amp;lt;!-- optional parameter --&amp;gt;&lt;br /&gt;
--&lt;br /&gt;
--&lt;br /&gt;
--    The &amp;quot;doc&amp;quot; function will generate the &amp;lt;templatedata&amp;gt; parameter documentation for templates.&lt;br /&gt;
--    This way all template parameters can be stored and localized in a single Commons dataset.&lt;br /&gt;
--    NOTE: &amp;quot;doc&amp;quot; assumes that all documentation is located in Data:Templatedata/* on Commons.&lt;br /&gt;
--&lt;br /&gt;
--    {{#invoke:TNT | doc | Graph:Lines }}&lt;br /&gt;
--        uses https://commons.wikimedia.org/wiki/Data:Templatedata/Graph:Lines.tab&lt;br /&gt;
--        if the current page is Template:Graph:Lines/doc&lt;br /&gt;
--&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
local i18nDataset = &#039;I18n/Module:TNT.tab&#039;&lt;br /&gt;
&lt;br /&gt;
-- Forward declaration of the local functions&lt;br /&gt;
local sanitizeDataset, loadData, link, formatMessage&lt;br /&gt;
&lt;br /&gt;
function p.msg(frame)&lt;br /&gt;
	local dataset, id&lt;br /&gt;
	local params = {}&lt;br /&gt;
	local lang = nil&lt;br /&gt;
	for k, v in pairs(frame.args) do&lt;br /&gt;
		if k == 1 then&lt;br /&gt;
			dataset = mw.text.trim(v)&lt;br /&gt;
		elseif k == 2 then&lt;br /&gt;
			id = mw.text.trim(v)&lt;br /&gt;
		elseif type(k) == &#039;number&#039; then&lt;br /&gt;
			table.insert(params, mw.text.trim(v))&lt;br /&gt;
		elseif k == &#039;lang&#039; and v ~= &#039;_&#039; then&lt;br /&gt;
			lang = mw.text.trim(v)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return formatMessage(dataset, id, params, lang)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Identical to p.msg() above, but used from other lua modules&lt;br /&gt;
-- Parameters:  name of dataset, message key, optional arguments&lt;br /&gt;
-- Example with 2 params:  format(&#039;I18n/Module:TNT&#039;, &#039;error_bad_msgkey&#039;, &#039;my-key&#039;, &#039;my-dataset&#039;)&lt;br /&gt;
function p.format(dataset, key, ...)&lt;br /&gt;
	local checkType = require(&#039;libraryUtil&#039;).checkType&lt;br /&gt;
	checkType(&#039;format&#039;, 1, dataset, &#039;string&#039;)&lt;br /&gt;
	checkType(&#039;format&#039;, 2, key, &#039;string&#039;)&lt;br /&gt;
	return formatMessage(dataset, key, {...})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Identical to p.msg() above, but used from other lua modules with the language param&lt;br /&gt;
-- Parameters:  language code, name of dataset, message key, optional arguments&lt;br /&gt;
-- Example with 2 params:  formatInLanguage(&#039;es&#039;, I18n/Module:TNT&#039;, &#039;error_bad_msgkey&#039;, &#039;my-key&#039;, &#039;my-dataset&#039;)&lt;br /&gt;
function p.formatInLanguage(lang, dataset, key, ...)&lt;br /&gt;
	local checkType = require(&#039;libraryUtil&#039;).checkType&lt;br /&gt;
	checkType(&#039;formatInLanguage&#039;, 1, lang, &#039;string&#039;)&lt;br /&gt;
	checkType(&#039;formatInLanguage&#039;, 2, dataset, &#039;string&#039;)&lt;br /&gt;
	checkType(&#039;formatInLanguage&#039;, 3, key, &#039;string&#039;)&lt;br /&gt;
	return formatMessage(dataset, key, {...}, lang)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Obsolete function that adds a &#039;c:&#039; prefix to the first param.&lt;br /&gt;
-- &amp;quot;Sandbox/Sample.tab&amp;quot; -&amp;gt; &#039;c:Data:Sandbox/Sample.tab&#039;&lt;br /&gt;
function p.link(frame)&lt;br /&gt;
	return link(frame.args[1])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.doc(frame)&lt;br /&gt;
	local dataset = &#039;Templatedata/&#039; .. sanitizeDataset(frame.args[1])&lt;br /&gt;
	return frame:extensionTag(&#039;templatedata&#039;, p.getTemplateData(dataset)) ..&lt;br /&gt;
		   formatMessage(i18nDataset, &#039;edit_doc&#039;, {link(dataset)})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.getTemplateData(dataset)&lt;br /&gt;
	-- TODO: add &#039;_&#039; parameter once lua starts reindexing properly for &amp;quot;all&amp;quot; languages&lt;br /&gt;
	local data = loadData(dataset)&lt;br /&gt;
	local names = {}&lt;br /&gt;
	for _, field in pairs(data.schema.fields) do&lt;br /&gt;
		table.insert(names, field.name)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local params = {}&lt;br /&gt;
	local paramOrder = {}&lt;br /&gt;
	for _, row in pairs(data.data) do&lt;br /&gt;
		local newVal = {}&lt;br /&gt;
		local name = nil&lt;br /&gt;
		for pos, val in pairs(row) do&lt;br /&gt;
			local columnName = names[pos]&lt;br /&gt;
			if columnName == &#039;name&#039; then&lt;br /&gt;
				name = val&lt;br /&gt;
			else&lt;br /&gt;
				newVal[columnName] = val&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if name then&lt;br /&gt;
			params[name] = newVal&lt;br /&gt;
			table.insert(paramOrder, name)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Work around json encoding treating {&amp;quot;1&amp;quot;:{...}} as an [{...}]&lt;br /&gt;
	params[&#039;zzz123&#039;]=&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
	local json = mw.text.jsonEncode({&lt;br /&gt;
		params=params,&lt;br /&gt;
		paramOrder=paramOrder,&lt;br /&gt;
		description=data.description&lt;br /&gt;
	})&lt;br /&gt;
&lt;br /&gt;
	json = string.gsub(json,&#039;&amp;quot;zzz123&amp;quot;:&amp;quot;&amp;quot;,?&#039;, &amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	return json&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local functions&lt;br /&gt;
&lt;br /&gt;
sanitizeDataset = function(dataset)&lt;br /&gt;
	if not dataset then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	dataset = mw.text.trim(dataset)&lt;br /&gt;
	if dataset == &#039;&#039; then&lt;br /&gt;
		return nil&lt;br /&gt;
	elseif string.sub(dataset,-4) ~= &#039;.tab&#039; then&lt;br /&gt;
		return dataset .. &#039;.tab&#039;&lt;br /&gt;
	else&lt;br /&gt;
		return dataset&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
loadData = function(dataset, lang)&lt;br /&gt;
	dataset = sanitizeDataset(dataset)&lt;br /&gt;
	if not dataset then&lt;br /&gt;
		error(formatMessage(i18nDataset, &#039;error_no_dataset&#039;, {}))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Give helpful error to thirdparties who try and copy this module.&lt;br /&gt;
	if not mw.ext or not mw.ext.data or not mw.ext.data.get then&lt;br /&gt;
		error(&#039;Missing JsonConfig extension; Cannot load https://commons.wikimedia.org/wiki/Data:&#039; .. dataset)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local data = mw.ext.data.get(dataset, lang)&lt;br /&gt;
&lt;br /&gt;
	if data == false then&lt;br /&gt;
		if dataset == i18nDataset then&lt;br /&gt;
			-- Prevent cyclical calls&lt;br /&gt;
			error(&#039;Missing Commons dataset &#039; .. i18nDataset)&lt;br /&gt;
		else&lt;br /&gt;
			error(formatMessage(i18nDataset, &#039;error_bad_dataset&#039;, {link(dataset)}))&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return data&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Given a dataset name, convert it to a title with the &#039;commons:data:&#039; prefix&lt;br /&gt;
link = function(dataset)&lt;br /&gt;
	return &#039;c:Data:&#039; .. mw.text.trim(dataset or &#039;&#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
formatMessage = function(dataset, key, params, lang)&lt;br /&gt;
	for _, row in pairs(loadData(dataset, lang).data) do&lt;br /&gt;
		local id, msg = unpack(row)&lt;br /&gt;
		if id == key then&lt;br /&gt;
			local result = mw.message.newRawMessage(msg, unpack(params or {}))&lt;br /&gt;
			return result:plain()&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if dataset == i18nDataset then&lt;br /&gt;
		-- Prevent cyclical calls&lt;br /&gt;
		error(&#039;Invalid message key &amp;quot;&#039; .. key .. &#039;&amp;quot;&#039;)&lt;br /&gt;
	else&lt;br /&gt;
		error(formatMessage(i18nDataset, &#039;error_bad_msgkey&#039;, {key, link(dataset)}))&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:String&amp;diff=643</id>
		<title>Module:String</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:String&amp;diff=643"/>
		<updated>2021-04-26T10:44:14Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[&lt;br /&gt;
&lt;br /&gt;
This module is intended to provide access to basic string functions.&lt;br /&gt;
&lt;br /&gt;
Most of the functions provided here can be invoked with named parameters,&lt;br /&gt;
unnamed parameters, or a mixture.  If named parameters are used, Mediawiki will&lt;br /&gt;
automatically remove any leading or trailing whitespace from the parameter.&lt;br /&gt;
Depending on the intended use, it may be advantageous to either preserve or&lt;br /&gt;
remove such whitespace.&lt;br /&gt;
&lt;br /&gt;
Global options&lt;br /&gt;
    ignore_errors: If set to &#039;true&#039; or 1, any error condition will result in&lt;br /&gt;
        an empty string being returned rather than an error message.&lt;br /&gt;
&lt;br /&gt;
    error_category: If an error occurs, specifies the name of a category to&lt;br /&gt;
        include with the error message.  The default category is&lt;br /&gt;
        [Category:Errors reported by Module String].&lt;br /&gt;
&lt;br /&gt;
    no_category: If set to &#039;true&#039; or 1, no category will be added if an error&lt;br /&gt;
        is generated.&lt;br /&gt;
&lt;br /&gt;
Unit tests for this module are available at Module:String/tests.&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local str = {}&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
len&lt;br /&gt;
&lt;br /&gt;
This function returns the length of the target string.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|len|target_string|}}&lt;br /&gt;
OR&lt;br /&gt;
{{#invoke:String|len|s=target_string}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
    s: The string whose length to report&lt;br /&gt;
&lt;br /&gt;
If invoked using named parameters, Mediawiki will automatically remove any leading or&lt;br /&gt;
trailing whitespace from the target string.&lt;br /&gt;
]]&lt;br /&gt;
function str.len( frame )&lt;br /&gt;
	local new_args = str._getParameters( frame.args, {&#039;s&#039;} )&lt;br /&gt;
	local s = new_args[&#039;s&#039;] or &#039;&#039;&lt;br /&gt;
	return mw.ustring.len( s )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
sub&lt;br /&gt;
&lt;br /&gt;
This function returns a substring of the target string at specified indices.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|sub|target_string|start_index|end_index}}&lt;br /&gt;
OR&lt;br /&gt;
{{#invoke:String|sub|s=target_string|i=start_index|j=end_index}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
    s: The string to return a subset of&lt;br /&gt;
    i: The fist index of the substring to return, defaults to 1.&lt;br /&gt;
    j: The last index of the string to return, defaults to the last character.&lt;br /&gt;
&lt;br /&gt;
The first character of the string is assigned an index of 1.  If either i or j&lt;br /&gt;
is a negative value, it is interpreted the same as selecting a character by&lt;br /&gt;
counting from the end of the string.  Hence, a value of -1 is the same as&lt;br /&gt;
selecting the last character of the string.&lt;br /&gt;
&lt;br /&gt;
If the requested indices are out of range for the given string, an error is&lt;br /&gt;
reported.&lt;br /&gt;
]]&lt;br /&gt;
function str.sub( frame )&lt;br /&gt;
	local new_args = str._getParameters( frame.args, { &#039;s&#039;, &#039;i&#039;, &#039;j&#039; } )&lt;br /&gt;
	local s = new_args[&#039;s&#039;] or &#039;&#039;&lt;br /&gt;
	local i = tonumber( new_args[&#039;i&#039;] ) or 1&lt;br /&gt;
	local j = tonumber( new_args[&#039;j&#039;] ) or -1&lt;br /&gt;
&lt;br /&gt;
	local len = mw.ustring.len( s )&lt;br /&gt;
&lt;br /&gt;
	-- Convert negatives for range checking&lt;br /&gt;
	if i &amp;lt; 0 then&lt;br /&gt;
		i = len + i + 1&lt;br /&gt;
	end&lt;br /&gt;
	if j &amp;lt; 0 then&lt;br /&gt;
		j = len + j + 1&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if i &amp;gt; len or j &amp;gt; len or i &amp;lt; 1 or j &amp;lt; 1 then&lt;br /&gt;
		return str._error( &#039;String subset index out of range&#039; )&lt;br /&gt;
	end&lt;br /&gt;
	if j &amp;lt; i then&lt;br /&gt;
		return str._error( &#039;String subset indices out of order&#039; )&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return mw.ustring.sub( s, i, j )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
This function implements that features of {{str sub old}} and is kept in order&lt;br /&gt;
to maintain these older templates.&lt;br /&gt;
]]&lt;br /&gt;
function str.sublength( frame )&lt;br /&gt;
	local i = tonumber( frame.args.i ) or 0&lt;br /&gt;
	local len = tonumber( frame.args.len )&lt;br /&gt;
	return mw.ustring.sub( frame.args.s, i + 1, len and ( i + len ) )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
_match&lt;br /&gt;
&lt;br /&gt;
This function returns a substring from the source string that matches a&lt;br /&gt;
specified pattern. It is exported for use in other modules&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
strmatch = require(&amp;quot;Module:String&amp;quot;)._match&lt;br /&gt;
sresult = strmatch( s, pattern, start, match, plain, nomatch )&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
    s: The string to search&lt;br /&gt;
    pattern: The pattern or string to find within the string&lt;br /&gt;
    start: The index within the source string to start the search.  The first&lt;br /&gt;
        character of the string has index 1.  Defaults to 1.&lt;br /&gt;
    match: In some cases it may be possible to make multiple matches on a single&lt;br /&gt;
        string.  This specifies which match to return, where the first match is&lt;br /&gt;
        match= 1.  If a negative number is specified then a match is returned&lt;br /&gt;
        counting from the last match.  Hence match = -1 is the same as requesting&lt;br /&gt;
        the last match.  Defaults to 1.&lt;br /&gt;
    plain: A flag indicating that the pattern should be understood as plain&lt;br /&gt;
        text.  Defaults to false.&lt;br /&gt;
    nomatch: If no match is found, output the &amp;quot;nomatch&amp;quot; value rather than an error.&lt;br /&gt;
&lt;br /&gt;
For information on constructing Lua patterns, a form of [regular expression], see:&lt;br /&gt;
&lt;br /&gt;
* http://www.lua.org/manual/5.1/manual.html#5.4.1&lt;br /&gt;
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns&lt;br /&gt;
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
-- This sub-routine is exported for use in other modules&lt;br /&gt;
function str._match( s, pattern, start, match_index, plain_flag, nomatch )&lt;br /&gt;
	if s == &#039;&#039; then&lt;br /&gt;
		return str._error( &#039;Target string is empty&#039; )&lt;br /&gt;
	end&lt;br /&gt;
	if pattern == &#039;&#039; then&lt;br /&gt;
		return str._error( &#039;Pattern string is empty&#039; )&lt;br /&gt;
	end&lt;br /&gt;
	start = tonumber(start) or 1&lt;br /&gt;
	if math.abs(start) &amp;lt; 1 or math.abs(start) &amp;gt; mw.ustring.len( s ) then&lt;br /&gt;
		return str._error( &#039;Requested start is out of range&#039; )&lt;br /&gt;
	end&lt;br /&gt;
	if match_index == 0 then&lt;br /&gt;
		return str._error( &#039;Match index is out of range&#039; )&lt;br /&gt;
	end&lt;br /&gt;
	if plain_flag then&lt;br /&gt;
		pattern = str._escapePattern( pattern )&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local result&lt;br /&gt;
	if match_index == 1 then&lt;br /&gt;
		-- Find first match is simple case&lt;br /&gt;
		result = mw.ustring.match( s, pattern, start )&lt;br /&gt;
	else&lt;br /&gt;
		if start &amp;gt; 1 then&lt;br /&gt;
			s = mw.ustring.sub( s, start )&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		local iterator = mw.ustring.gmatch(s, pattern)&lt;br /&gt;
		if match_index &amp;gt; 0 then&lt;br /&gt;
			-- Forward search&lt;br /&gt;
			for w in iterator do&lt;br /&gt;
				match_index = match_index - 1&lt;br /&gt;
				if match_index == 0 then&lt;br /&gt;
					result = w&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			-- Reverse search&lt;br /&gt;
			local result_table = {}&lt;br /&gt;
			local count = 1&lt;br /&gt;
			for w in iterator do&lt;br /&gt;
				result_table[count] = w&lt;br /&gt;
				count = count + 1&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			result = result_table[ count + match_index ]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if result == nil then&lt;br /&gt;
		if nomatch == nil then&lt;br /&gt;
			return str._error( &#039;Match not found&#039; )&lt;br /&gt;
		else&lt;br /&gt;
			return nomatch&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return result&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
match&lt;br /&gt;
&lt;br /&gt;
This function returns a substring from the source string that matches a&lt;br /&gt;
specified pattern.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|match|source_string|pattern_string|start_index|match_number|plain_flag|nomatch_output}}&lt;br /&gt;
OR&lt;br /&gt;
{{#invoke:String|match|s=source_string|pattern=pattern_string|start=start_index&lt;br /&gt;
    |match=match_number|plain=plain_flag|nomatch=nomatch_output}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
    s: The string to search&lt;br /&gt;
    pattern: The pattern or string to find within the string&lt;br /&gt;
    start: The index within the source string to start the search.  The first&lt;br /&gt;
        character of the string has index 1.  Defaults to 1.&lt;br /&gt;
    match: In some cases it may be possible to make multiple matches on a single&lt;br /&gt;
        string.  This specifies which match to return, where the first match is&lt;br /&gt;
        match= 1.  If a negative number is specified then a match is returned&lt;br /&gt;
        counting from the last match.  Hence match = -1 is the same as requesting&lt;br /&gt;
        the last match.  Defaults to 1.&lt;br /&gt;
    plain: A flag indicating that the pattern should be understood as plain&lt;br /&gt;
        text.  Defaults to false.&lt;br /&gt;
    nomatch: If no match is found, output the &amp;quot;nomatch&amp;quot; value rather than an error.&lt;br /&gt;
&lt;br /&gt;
If invoked using named parameters, Mediawiki will automatically remove any leading or&lt;br /&gt;
trailing whitespace from each string.  In some circumstances this is desirable, in&lt;br /&gt;
other cases one may want to preserve the whitespace.&lt;br /&gt;
&lt;br /&gt;
If the match_number or start_index are out of range for the string being queried, then&lt;br /&gt;
this function generates an error.  An error is also generated if no match is found.&lt;br /&gt;
If one adds the parameter ignore_errors=true, then the error will be suppressed and&lt;br /&gt;
an empty string will be returned on any failure.&lt;br /&gt;
&lt;br /&gt;
For information on constructing Lua patterns, a form of [regular expression], see:&lt;br /&gt;
&lt;br /&gt;
* http://www.lua.org/manual/5.1/manual.html#5.4.1&lt;br /&gt;
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns&lt;br /&gt;
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
-- This is the entry point for #invoke:String|match&lt;br /&gt;
function str.match( frame )&lt;br /&gt;
	local new_args = str._getParameters( frame.args, {&#039;s&#039;, &#039;pattern&#039;, &#039;start&#039;, &#039;match&#039;, &#039;plain&#039;, &#039;nomatch&#039;} )&lt;br /&gt;
	local s = new_args[&#039;s&#039;] or &#039;&#039;&lt;br /&gt;
	local start = tonumber( new_args[&#039;start&#039;] ) or 1&lt;br /&gt;
	local plain_flag = str._getBoolean( new_args[&#039;plain&#039;] or false )&lt;br /&gt;
	local pattern = new_args[&#039;pattern&#039;] or &#039;&#039;&lt;br /&gt;
	local match_index = math.floor( tonumber(new_args[&#039;match&#039;]) or 1 )&lt;br /&gt;
	local nomatch = new_args[&#039;nomatch&#039;]&lt;br /&gt;
&lt;br /&gt;
	return str._match( s, pattern, start, match_index, plain_flag, nomatch )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
pos&lt;br /&gt;
&lt;br /&gt;
This function returns a single character from the target string at position pos.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|pos|target_string|index_value}}&lt;br /&gt;
OR&lt;br /&gt;
{{#invoke:String|pos|target=target_string|pos=index_value}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
    target: The string to search&lt;br /&gt;
    pos: The index for the character to return&lt;br /&gt;
&lt;br /&gt;
If invoked using named parameters, Mediawiki will automatically remove any leading or&lt;br /&gt;
trailing whitespace from the target string.  In some circumstances this is desirable, in&lt;br /&gt;
other cases one may want to preserve the whitespace.&lt;br /&gt;
&lt;br /&gt;
The first character has an index value of 1.&lt;br /&gt;
&lt;br /&gt;
If one requests a negative value, this function will select a character by counting backwards&lt;br /&gt;
from the end of the string.  In other words pos = -1 is the same as asking for the last character.&lt;br /&gt;
&lt;br /&gt;
A requested value of zero, or a value greater than the length of the string returns an error.&lt;br /&gt;
]]&lt;br /&gt;
function str.pos( frame )&lt;br /&gt;
	local new_args = str._getParameters( frame.args, {&#039;target&#039;, &#039;pos&#039;} )&lt;br /&gt;
	local target_str = new_args[&#039;target&#039;] or &#039;&#039;&lt;br /&gt;
	local pos = tonumber( new_args[&#039;pos&#039;] ) or 0&lt;br /&gt;
&lt;br /&gt;
	if pos == 0 or math.abs(pos) &amp;gt; mw.ustring.len( target_str ) then&lt;br /&gt;
		return str._error( &#039;String index out of range&#039; )&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return mw.ustring.sub( target_str, pos, pos )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
str_find&lt;br /&gt;
&lt;br /&gt;
This function duplicates the behavior of {{str_find}}, including all of its quirks.&lt;br /&gt;
This is provided in order to support existing templates, but is NOT RECOMMENDED for&lt;br /&gt;
new code and templates.  New code is recommended to use the &amp;quot;find&amp;quot; function instead.&lt;br /&gt;
&lt;br /&gt;
Returns the first index in &amp;quot;source&amp;quot; that is a match to &amp;quot;target&amp;quot;.  Indexing is 1-based,&lt;br /&gt;
and the function returns -1 if the &amp;quot;target&amp;quot; string is not present in &amp;quot;source&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Important Note: If the &amp;quot;target&amp;quot; string is empty / missing, this function returns a&lt;br /&gt;
value of &amp;quot;1&amp;quot;, which is generally unexpected behavior, and must be accounted for&lt;br /&gt;
separatetly.&lt;br /&gt;
]]&lt;br /&gt;
function str.str_find( frame )&lt;br /&gt;
	local new_args = str._getParameters( frame.args, {&#039;source&#039;, &#039;target&#039;} )&lt;br /&gt;
	local source_str = new_args[&#039;source&#039;] or &#039;&#039;&lt;br /&gt;
	local target_str = new_args[&#039;target&#039;] or &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
	if target_str == &#039;&#039; then&lt;br /&gt;
		return 1&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local start = mw.ustring.find( source_str, target_str, 1, true )&lt;br /&gt;
	if start == nil then&lt;br /&gt;
		start = -1&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return start&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
find&lt;br /&gt;
&lt;br /&gt;
This function allows one to search for a target string or pattern within another&lt;br /&gt;
string.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|find|source_str|target_string|start_index|plain_flag}}&lt;br /&gt;
OR&lt;br /&gt;
{{#invoke:String|find|source=source_str|target=target_str|start=start_index|plain=plain_flag}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
    source: The string to search&lt;br /&gt;
    target: The string or pattern to find within source&lt;br /&gt;
    start: The index within the source string to start the search, defaults to 1&lt;br /&gt;
    plain: Boolean flag indicating that target should be understood as plain&lt;br /&gt;
        text and not as a Lua style regular expression, defaults to true&lt;br /&gt;
&lt;br /&gt;
If invoked using named parameters, Mediawiki will automatically remove any leading or&lt;br /&gt;
trailing whitespace from the parameter.  In some circumstances this is desirable, in&lt;br /&gt;
other cases one may want to preserve the whitespace.&lt;br /&gt;
&lt;br /&gt;
This function returns the first index &amp;gt;= &amp;quot;start&amp;quot; where &amp;quot;target&amp;quot; can be found&lt;br /&gt;
within &amp;quot;source&amp;quot;.  Indices are 1-based.  If &amp;quot;target&amp;quot; is not found, then this&lt;br /&gt;
function returns 0.  If either &amp;quot;source&amp;quot; or &amp;quot;target&amp;quot; are missing / empty, this&lt;br /&gt;
function also returns 0.&lt;br /&gt;
&lt;br /&gt;
This function should be safe for UTF-8 strings.&lt;br /&gt;
]]&lt;br /&gt;
function str.find( frame )&lt;br /&gt;
	local new_args = str._getParameters( frame.args, {&#039;source&#039;, &#039;target&#039;, &#039;start&#039;, &#039;plain&#039; } )&lt;br /&gt;
	local source_str = new_args[&#039;source&#039;] or &#039;&#039;&lt;br /&gt;
	local pattern = new_args[&#039;target&#039;] or &#039;&#039;&lt;br /&gt;
	local start_pos = tonumber(new_args[&#039;start&#039;]) or 1&lt;br /&gt;
	local plain = new_args[&#039;plain&#039;] or true&lt;br /&gt;
&lt;br /&gt;
	if source_str == &#039;&#039; or pattern == &#039;&#039; then&lt;br /&gt;
		return 0&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	plain = str._getBoolean( plain )&lt;br /&gt;
&lt;br /&gt;
	local start = mw.ustring.find( source_str, pattern, start_pos, plain )&lt;br /&gt;
	if start == nil then&lt;br /&gt;
		start = 0&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return start&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
replace&lt;br /&gt;
&lt;br /&gt;
This function allows one to replace a target string or pattern within another&lt;br /&gt;
string.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|replace|source_str|pattern_string|replace_string|replacement_count|plain_flag}}&lt;br /&gt;
OR&lt;br /&gt;
{{#invoke:String|replace|source=source_string|pattern=pattern_string|replace=replace_string|&lt;br /&gt;
   count=replacement_count|plain=plain_flag}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
    source: The string to search&lt;br /&gt;
    pattern: The string or pattern to find within source&lt;br /&gt;
    replace: The replacement text&lt;br /&gt;
    count: The number of occurences to replace, defaults to all.&lt;br /&gt;
    plain: Boolean flag indicating that pattern should be understood as plain&lt;br /&gt;
        text and not as a Lua style regular expression, defaults to true&lt;br /&gt;
]]&lt;br /&gt;
function str.replace( frame )&lt;br /&gt;
	local new_args = str._getParameters( frame.args, {&#039;source&#039;, &#039;pattern&#039;, &#039;replace&#039;, &#039;count&#039;, &#039;plain&#039; } )&lt;br /&gt;
	local source_str = new_args[&#039;source&#039;] or &#039;&#039;&lt;br /&gt;
	local pattern = new_args[&#039;pattern&#039;] or &#039;&#039;&lt;br /&gt;
	local replace = new_args[&#039;replace&#039;] or &#039;&#039;&lt;br /&gt;
	local count = tonumber( new_args[&#039;count&#039;] )&lt;br /&gt;
	local plain = new_args[&#039;plain&#039;] or true&lt;br /&gt;
&lt;br /&gt;
	if source_str == &#039;&#039; or pattern == &#039;&#039; then&lt;br /&gt;
		return source_str&lt;br /&gt;
	end&lt;br /&gt;
	plain = str._getBoolean( plain )&lt;br /&gt;
&lt;br /&gt;
	if plain then&lt;br /&gt;
		pattern = str._escapePattern( pattern )&lt;br /&gt;
		replace = mw.ustring.gsub( replace, &amp;quot;%%&amp;quot;, &amp;quot;%%%%&amp;quot; ) --Only need to escape replacement sequences.&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local result&lt;br /&gt;
&lt;br /&gt;
	if count ~= nil then&lt;br /&gt;
		result = mw.ustring.gsub( source_str, pattern, replace, count )&lt;br /&gt;
	else&lt;br /&gt;
		result = mw.ustring.gsub( source_str, pattern, replace )&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
    simple function to pipe string.rep to templates.&lt;br /&gt;
]]&lt;br /&gt;
function str.rep( frame )&lt;br /&gt;
	local repetitions = tonumber( frame.args[2] )&lt;br /&gt;
	if not repetitions then&lt;br /&gt;
		return str._error( &#039;function rep expects a number as second parameter, received &amp;quot;&#039; .. ( frame.args[2] or &#039;&#039; ) .. &#039;&amp;quot;&#039; )&lt;br /&gt;
	end&lt;br /&gt;
	return string.rep( frame.args[1] or &#039;&#039;, repetitions )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
escapePattern&lt;br /&gt;
&lt;br /&gt;
This function escapes special characters from a Lua string pattern. See [1]&lt;br /&gt;
for details on how patterns work.&lt;br /&gt;
&lt;br /&gt;
[1] https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|escapePattern|pattern_string}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
    pattern_string: The pattern string to escape.&lt;br /&gt;
]]&lt;br /&gt;
function str.escapePattern( frame )&lt;br /&gt;
	local pattern_str = frame.args[1]&lt;br /&gt;
	if not pattern_str then&lt;br /&gt;
		return str._error( &#039;No pattern string specified&#039; )&lt;br /&gt;
	end&lt;br /&gt;
	local result = str._escapePattern( pattern_str )&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
count&lt;br /&gt;
This function counts the number of occurrences of one string in another.&lt;br /&gt;
]]&lt;br /&gt;
function str.count(frame)&lt;br /&gt;
	local args = str._getParameters(frame.args, {&#039;source&#039;, &#039;pattern&#039;, &#039;plain&#039;})&lt;br /&gt;
	local source = args.source or &#039;&#039;&lt;br /&gt;
	local pattern = args.pattern or &#039;&#039;&lt;br /&gt;
	local plain = str._getBoolean(args.plain or true)&lt;br /&gt;
	if plain then&lt;br /&gt;
		pattern = str._escapePattern(pattern)&lt;br /&gt;
	end&lt;br /&gt;
	local _, count = mw.ustring.gsub(source, pattern, &#039;&#039;)&lt;br /&gt;
	return count&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
endswith&lt;br /&gt;
This function determines whether a string ends with another string.&lt;br /&gt;
]]&lt;br /&gt;
function str.endswith(frame)&lt;br /&gt;
	local args = str._getParameters(frame.args, {&#039;source&#039;, &#039;pattern&#039;})&lt;br /&gt;
	local source = args.source or &#039;&#039;&lt;br /&gt;
	local pattern = args.pattern or &#039;&#039;&lt;br /&gt;
	if pattern == &#039;&#039; then&lt;br /&gt;
		-- All strings end with the empty string.&lt;br /&gt;
		return &amp;quot;yes&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	if mw.ustring.sub(source, -mw.ustring.len(pattern), -1) == pattern then&lt;br /&gt;
		return &amp;quot;yes&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
join&lt;br /&gt;
&lt;br /&gt;
Join all non empty arguments together; the first argument is the separator.&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|join|sep|one|two|three}}&lt;br /&gt;
]]&lt;br /&gt;
function str.join(frame)&lt;br /&gt;
	local args = {}&lt;br /&gt;
	local sep&lt;br /&gt;
	for _, v in ipairs( frame.args ) do&lt;br /&gt;
		if sep then&lt;br /&gt;
			if v ~= &#039;&#039; then&lt;br /&gt;
				table.insert(args, v)&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			sep = v&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat( args, sep or &#039;&#039; )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper function that populates the argument list given that user may need to use a mix of&lt;br /&gt;
named and unnamed parameters.  This is relevant because named parameters are not&lt;br /&gt;
identical to unnamed parameters due to string trimming, and when dealing with strings&lt;br /&gt;
we sometimes want to either preserve or remove that whitespace depending on the application.&lt;br /&gt;
]]&lt;br /&gt;
function str._getParameters( frame_args, arg_list )&lt;br /&gt;
	local new_args = {}&lt;br /&gt;
	local index = 1&lt;br /&gt;
	local value&lt;br /&gt;
&lt;br /&gt;
	for _, arg in ipairs( arg_list ) do&lt;br /&gt;
		value = frame_args[arg]&lt;br /&gt;
		if value == nil then&lt;br /&gt;
			value = frame_args[index]&lt;br /&gt;
			index = index + 1&lt;br /&gt;
		end&lt;br /&gt;
		new_args[arg] = value&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return new_args&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper function to handle error messages.&lt;br /&gt;
]]&lt;br /&gt;
function str._error( error_str )&lt;br /&gt;
	local frame = mw.getCurrentFrame()&lt;br /&gt;
	local error_category = frame.args.error_category or &#039;Errors reported by Module String&#039;&lt;br /&gt;
	local ignore_errors = frame.args.ignore_errors or false&lt;br /&gt;
	local no_category = frame.args.no_category or false&lt;br /&gt;
&lt;br /&gt;
	if str._getBoolean(ignore_errors) then&lt;br /&gt;
		return &#039;&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local error_str = &#039;&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;String Module Error: &#039; .. error_str .. &#039;&amp;lt;/strong&amp;gt;&#039;&lt;br /&gt;
	if error_category ~= &#039;&#039; and not str._getBoolean( no_category ) then&lt;br /&gt;
		error_str = &#039;[[Category:&#039; .. error_category .. &#039;]]&#039; .. error_str&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return error_str&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper Function to interpret boolean strings&lt;br /&gt;
]]&lt;br /&gt;
function str._getBoolean( boolean_str )&lt;br /&gt;
	local boolean_value&lt;br /&gt;
&lt;br /&gt;
	if type( boolean_str ) == &#039;string&#039; then&lt;br /&gt;
		boolean_str = boolean_str:lower()&lt;br /&gt;
		if boolean_str == &#039;false&#039; or boolean_str == &#039;no&#039; or boolean_str == &#039;0&#039;&lt;br /&gt;
				or boolean_str == &#039;&#039; then&lt;br /&gt;
			boolean_value = false&lt;br /&gt;
		else&lt;br /&gt;
			boolean_value = true&lt;br /&gt;
		end&lt;br /&gt;
	elseif type( boolean_str ) == &#039;boolean&#039; then&lt;br /&gt;
		boolean_value = boolean_str&lt;br /&gt;
	else&lt;br /&gt;
		error( &#039;No boolean value found&#039; )&lt;br /&gt;
	end&lt;br /&gt;
	return boolean_value&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper function that escapes all pattern characters so that they will be treated&lt;br /&gt;
as plain text.&lt;br /&gt;
]]&lt;br /&gt;
function str._escapePattern( pattern_str )&lt;br /&gt;
	return mw.ustring.gsub( pattern_str, &amp;quot;([%(%)%.%%%+%-%*%?%[%^%$%]])&amp;quot;, &amp;quot;%%%1&amp;quot; )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return str&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Protection_banner/config&amp;diff=641</id>
		<title>Module:Protection banner/config</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Protection_banner/config&amp;diff=641"/>
		<updated>2021-04-26T10:44:14Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;-- This module provides configuration data for [[Module:Protection banner]].&lt;br /&gt;
&lt;br /&gt;
return {&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
--&lt;br /&gt;
--                                BANNER DATA&lt;br /&gt;
--&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- Banner data consists of six fields:&lt;br /&gt;
-- * text - the main protection text that appears at the top of protection&lt;br /&gt;
--   banners.&lt;br /&gt;
-- * explanation - the text that appears below the main protection text, used&lt;br /&gt;
--   to explain the details of the protection.&lt;br /&gt;
-- * tooltip - the tooltip text you see when you move the mouse over a small&lt;br /&gt;
--   padlock icon.&lt;br /&gt;
-- * link - the page that the small padlock icon links to.&lt;br /&gt;
-- * alt - the alt text for the small padlock icon. This is also used as tooltip&lt;br /&gt;
--   text for the large protection banners.&lt;br /&gt;
-- * image - the padlock image used in both protection banners and small padlock&lt;br /&gt;
--   icons.&lt;br /&gt;
--&lt;br /&gt;
-- The module checks in three separate tables to find a value for each field.&lt;br /&gt;
-- First it checks the banners table, which has values specific to the reason&lt;br /&gt;
-- for the page being protected. Then the module checks the defaultBanners&lt;br /&gt;
-- table, which has values specific to each protection level. Finally, the&lt;br /&gt;
-- module checks the masterBanner table, which holds data for protection&lt;br /&gt;
-- templates to use if no data has been found in the previous two tables.&lt;br /&gt;
--&lt;br /&gt;
-- The values in the banner data can take parameters. These are specified&lt;br /&gt;
-- using ${TEXTLIKETHIS} (a dollar sign preceding a parameter name&lt;br /&gt;
-- enclosed in curly braces).&lt;br /&gt;
--&lt;br /&gt;
--                          Available parameters:&lt;br /&gt;
--&lt;br /&gt;
-- ${CURRENTVERSION} - a link to the page history or the move log, with the&lt;br /&gt;
-- display message &amp;quot;current-version-edit-display&amp;quot; or&lt;br /&gt;
-- &amp;quot;current-version-move-display&amp;quot;.&lt;br /&gt;
--&lt;br /&gt;
-- ${EDITREQUEST} - a link to create an edit request for the current page.&lt;br /&gt;
--&lt;br /&gt;
-- ${EXPLANATIONBLURB} - an explanation blurb, e.g. &amp;quot;Please discuss any changes&lt;br /&gt;
-- on the talk page; you may submit a request to ask an administrator to make&lt;br /&gt;
-- an edit if it is minor or supported by consensus.&amp;quot;&lt;br /&gt;
--&lt;br /&gt;
-- ${IMAGELINK} - a link to set the image to, depending on the protection&lt;br /&gt;
-- action and protection level.&lt;br /&gt;
--&lt;br /&gt;
-- ${INTROBLURB} - the PROTECTIONBLURB parameter, plus the expiry if an expiry&lt;br /&gt;
-- is set. E.g. &amp;quot;Editing of this page by new or unregistered users is currently &lt;br /&gt;
-- disabled until dd Month YYYY.&amp;quot;&lt;br /&gt;
--&lt;br /&gt;
-- ${INTROFRAGMENT} - the same as ${INTROBLURB}, but without final punctuation&lt;br /&gt;
-- so that it can be used in run-on sentences.&lt;br /&gt;
--&lt;br /&gt;
-- ${PAGETYPE} - the type of the page, e.g. &amp;quot;article&amp;quot; or &amp;quot;template&amp;quot;.&lt;br /&gt;
-- Defined in the cfg.pagetypes table.&lt;br /&gt;
--&lt;br /&gt;
-- ${PROTECTIONBLURB} - a blurb explaining the protection level of the page, e.g.&lt;br /&gt;
-- &amp;quot;Editing of this page by new or unregistered users is currently disabled&amp;quot;&lt;br /&gt;
--&lt;br /&gt;
-- ${PROTECTIONDATE} - the protection date, if it has been supplied to the&lt;br /&gt;
-- template.&lt;br /&gt;
--&lt;br /&gt;
-- ${PROTECTIONLEVEL} - the protection level, e.g. &amp;quot;fully protected&amp;quot; or&lt;br /&gt;
-- &amp;quot;semi-protected&amp;quot;.&lt;br /&gt;
--&lt;br /&gt;
-- ${PROTECTIONLOG} - a link to the protection log or the pending changes log,&lt;br /&gt;
-- depending on the protection action.&lt;br /&gt;
--&lt;br /&gt;
-- ${TALKPAGE} - a link to the talk page. If a section is specified, links&lt;br /&gt;
-- straight to that talk page section.&lt;br /&gt;
--&lt;br /&gt;
-- ${TOOLTIPBLURB} - uses the PAGETYPE, PROTECTIONTYPE and EXPIRY parameters to&lt;br /&gt;
-- create a blurb like &amp;quot;This template is semi-protected&amp;quot;, or &amp;quot;This article is&lt;br /&gt;
-- move-protected until DD Month YYYY&amp;quot;.&lt;br /&gt;
--&lt;br /&gt;
-- ${VANDAL} - links for the specified username (or the root page name)&lt;br /&gt;
-- using Module:Vandal-m.&lt;br /&gt;
--&lt;br /&gt;
--                                 Functions&lt;br /&gt;
--&lt;br /&gt;
-- For advanced users, it is possible to use Lua functions instead of strings&lt;br /&gt;
-- in the banner config tables. Using functions gives flexibility that is not&lt;br /&gt;
-- possible just by using parameters. Functions take two arguments, the&lt;br /&gt;
-- protection object and the template arguments, and they must output a string.&lt;br /&gt;
--&lt;br /&gt;
-- For example:&lt;br /&gt;
--&lt;br /&gt;
-- text = function (protectionObj, args)&lt;br /&gt;
--     if protectionObj.level == &#039;autoconfirmed&#039; then&lt;br /&gt;
--         return &#039;foo&#039;&lt;br /&gt;
--     else&lt;br /&gt;
--         return &#039;bar&#039;&lt;br /&gt;
--     end&lt;br /&gt;
-- end&lt;br /&gt;
--&lt;br /&gt;
-- Some protection object properties and methods that may be useful:&lt;br /&gt;
-- protectionObj.action - the protection action&lt;br /&gt;
-- protectionObj.level - the protection level&lt;br /&gt;
-- protectionObj.reason - the protection reason&lt;br /&gt;
-- protectionObj.expiry - the expiry. Nil if unset, the string &amp;quot;indef&amp;quot; if set&lt;br /&gt;
--     to indefinite, and the protection time in unix time if temporary.&lt;br /&gt;
-- protectionObj.protectionDate - the protection date in unix time, or nil if&lt;br /&gt;
--     unspecified.&lt;br /&gt;
-- protectionObj.bannerConfig - the banner config found by the module. Beware&lt;br /&gt;
--     of editing the config field used by the function, as it could create an&lt;br /&gt;
--     infinite loop.&lt;br /&gt;
-- protectionObj:isProtected - returns a boolean showing whether the page is&lt;br /&gt;
--     protected.&lt;br /&gt;
-- protectionObj:isTemporary - returns a boolean showing whether the expiry is&lt;br /&gt;
--     temporary.&lt;br /&gt;
-- protectionObj:isIncorrect - returns a boolean showing whether the protection&lt;br /&gt;
--     template is incorrect.&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
-- The master banner data, used if no values have been found in banners or&lt;br /&gt;
-- defaultBanners.&lt;br /&gt;
masterBanner = {&lt;br /&gt;
	text = &#039;${INTROBLURB}&#039;,&lt;br /&gt;
	explanation = &#039;${EXPLANATIONBLURB}&#039;,&lt;br /&gt;
	tooltip = &#039;${TOOLTIPBLURB}&#039;,&lt;br /&gt;
	link = &#039;${IMAGELINK}&#039;,&lt;br /&gt;
	alt = &#039;Page ${PROTECTIONLEVEL}&#039;&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
-- The default banner data. This holds banner data for different protection&lt;br /&gt;
-- levels.&lt;br /&gt;
-- *required* - this table needs edit, move, autoreview and upload subtables.&lt;br /&gt;
defaultBanners = {&lt;br /&gt;
	edit = {},&lt;br /&gt;
	move = {},&lt;br /&gt;
	autoreview = {&lt;br /&gt;
		default = {&lt;br /&gt;
			alt = &#039;Page protected with pending changes&#039;,&lt;br /&gt;
			tooltip = &#039;All edits by unregistered and new users are subject to review prior to becoming visible to unregistered users&#039;,&lt;br /&gt;
			image = &#039;Pending-protection-shackle.svg&#039;&lt;br /&gt;
		}&lt;br /&gt;
	},&lt;br /&gt;
	upload = {}&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
-- The banner data. This holds banner data for different protection reasons.&lt;br /&gt;
-- In fact, the reasons specified in this table control which reasons are&lt;br /&gt;
-- valid inputs to the first positional parameter.&lt;br /&gt;
--&lt;br /&gt;
-- There is also a non-standard &amp;quot;description&amp;quot; field that can be used for items&lt;br /&gt;
-- in this table. This is a description of the protection reason for use in the&lt;br /&gt;
-- module documentation.&lt;br /&gt;
--&lt;br /&gt;
-- *required* - this table needs edit, move, autoreview and upload subtables.&lt;br /&gt;
banners = {&lt;br /&gt;
	edit = {&lt;br /&gt;
		blp = {&lt;br /&gt;
			description = &#039;For pages protected to promote compliance with the&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Biographies of living persons&#039;&lt;br /&gt;
				.. &#039;|biographies of living persons]] policy&#039;,&lt;br /&gt;
			text = &#039;${INTROFRAGMENT} to promote compliance with&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Biographies of living persons&#039;&lt;br /&gt;
				.. &amp;quot;|Wikipedia&#039;s&amp;amp;nbsp;policy on&amp;amp;nbsp;the&amp;amp;nbsp;biographies&amp;quot;&lt;br /&gt;
				.. &#039; of&amp;amp;nbsp;living&amp;amp;nbsp;people]].&#039;,&lt;br /&gt;
			tooltip = &#039;${TOOLTIPFRAGMENT} to promote compliance with the policy on&#039;&lt;br /&gt;
				.. &#039; biographies of living persons&#039;,&lt;br /&gt;
		},&lt;br /&gt;
		dmca = {&lt;br /&gt;
			description = &#039;For pages protected by the Wikimedia Foundation&#039;&lt;br /&gt;
				.. &#039; due to [[Digital Millennium Copyright Act]] takedown requests&#039;,&lt;br /&gt;
			explanation = function (protectionObj, args)&lt;br /&gt;
				local ret = &#039;Pursuant to a rights owner notice under the Digital&#039;&lt;br /&gt;
					.. &#039; Millennium Copyright Act (DMCA) regarding some content&#039;&lt;br /&gt;
					.. &#039; in this article, the Wikimedia Foundation acted under&#039;&lt;br /&gt;
					.. &#039; applicable law and took down and restricted the content&#039;&lt;br /&gt;
					.. &#039; in question.&#039;&lt;br /&gt;
				if args.notice then&lt;br /&gt;
					ret = ret .. &#039; A copy of the received notice can be found here: &#039;&lt;br /&gt;
						.. args.notice .. &#039;.&#039;&lt;br /&gt;
				end&lt;br /&gt;
				ret = ret .. &#039; For more information, including websites discussing&#039;&lt;br /&gt;
					.. &#039; how to file a counter-notice, please see&#039;&lt;br /&gt;
					.. &amp;quot; [[Wikipedia:Office actions]] and the article&#039;s ${TALKPAGE}.&amp;quot;&lt;br /&gt;
					.. &amp;quot;&#039;&#039;&#039;Do not remove this template from the article until the&amp;quot;&lt;br /&gt;
					.. &amp;quot; restrictions are withdrawn&#039;&#039;&#039;.&amp;quot;&lt;br /&gt;
				return ret&lt;br /&gt;
			end,&lt;br /&gt;
			image = &#039;Office-protection-shackle.svg&#039;,&lt;br /&gt;
		},&lt;br /&gt;
		dispute = {&lt;br /&gt;
			description = &#039;For pages protected due to editing disputes&#039;,&lt;br /&gt;
			text = function (protectionObj, args)&lt;br /&gt;
				-- Find the value of &amp;quot;disputes&amp;quot;.&lt;br /&gt;
				local display = &#039;disputes&#039;&lt;br /&gt;
				local disputes&lt;br /&gt;
				if args.section then&lt;br /&gt;
					disputes = string.format(&lt;br /&gt;
						&#039;[[%s:%s#%s|%s]]&#039;,&lt;br /&gt;
						mw.site.namespaces[protectionObj.title.namespace].talk.name,&lt;br /&gt;
						protectionObj.title.text,&lt;br /&gt;
						args.section,&lt;br /&gt;
						display&lt;br /&gt;
					)&lt;br /&gt;
				else&lt;br /&gt;
					disputes = display&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				-- Make the blurb, depending on the expiry.&lt;br /&gt;
				local msg&lt;br /&gt;
				if type(protectionObj.expiry) == &#039;number&#039; then&lt;br /&gt;
					msg = &#039;${INTROFRAGMENT} or until editing %s have been resolved.&#039;&lt;br /&gt;
				else&lt;br /&gt;
					msg = &#039;${INTROFRAGMENT} until editing %s have been resolved.&#039;&lt;br /&gt;
				end&lt;br /&gt;
				return string.format(msg, disputes)&lt;br /&gt;
			end,&lt;br /&gt;
			explanation = &amp;quot;This protection is &#039;&#039;&#039;not&#039;&#039;&#039; an endorsement of the&amp;quot;&lt;br /&gt;
				.. &#039; ${CURRENTVERSION}. ${EXPLANATIONBLURB}&#039;,&lt;br /&gt;
			tooltip = &#039;${TOOLTIPFRAGMENT} due to editing disputes&#039;,&lt;br /&gt;
		},&lt;br /&gt;
		ecp = {&lt;br /&gt;
			description = &#039;For articles in topic areas authorized by&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Arbitration Committee|ArbCom]] or&#039;&lt;br /&gt;
				.. &#039; meets the criteria for community use&#039;,&lt;br /&gt;
			tooltip = &#039;This ${PAGETYPE} is extended-confirmed protected&#039;,&lt;br /&gt;
			alt = &#039;Extended-protected ${PAGETYPE}&#039;,&lt;br /&gt;
		},&lt;br /&gt;
		mainpage = {&lt;br /&gt;
			description = &#039;For pages protected for being displayed on the [[Main Page]]&#039;,&lt;br /&gt;
			text = &#039;This file is currently&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:This page is protected|protected]] from&#039;&lt;br /&gt;
				.. &#039; editing because it is currently or will soon be displayed&#039;&lt;br /&gt;
				.. &#039; on the [[Main Page]].&#039;,&lt;br /&gt;
			explanation = &#039;Images on the Main Page are protected due to their high&#039;&lt;br /&gt;
				.. &#039; visibility. Please discuss any necessary changes on the ${TALKPAGE}.&#039;&lt;br /&gt;
				.. &#039;&amp;lt;br /&amp;gt;&amp;lt;span style=&amp;quot;font-size:90%;&amp;quot;&amp;gt;&#039;&lt;br /&gt;
				.. &amp;quot;&#039;&#039;&#039;Administrators:&#039;&#039;&#039; Once this image is definitely off the Main Page,&amp;quot;&lt;br /&gt;
				.. &#039; please unprotect this file, or reduce to semi-protection,&#039;&lt;br /&gt;
				.. &#039; as appropriate.&amp;lt;/span&amp;gt;&#039;,&lt;br /&gt;
		},&lt;br /&gt;
		office = {&lt;br /&gt;
			description = &#039;For pages protected by the Wikimedia Foundation&#039;,&lt;br /&gt;
			text = function (protectionObj, args)&lt;br /&gt;
				local ret = &#039;This ${PAGETYPE} is currently under the&#039;&lt;br /&gt;
					.. &#039; scrutiny of the&#039;&lt;br /&gt;
					.. &#039; [[Wikipedia:Office actions|Wikimedia Foundation Office]]&#039;&lt;br /&gt;
					.. &#039; and is protected.&#039;&lt;br /&gt;
				if protectionObj.protectionDate then&lt;br /&gt;
					ret = ret .. &#039; It has been protected since ${PROTECTIONDATE}.&#039;&lt;br /&gt;
				end&lt;br /&gt;
				return ret&lt;br /&gt;
			end,&lt;br /&gt;
			explanation = &amp;quot;If you can edit this page, please discuss all changes and&amp;quot;&lt;br /&gt;
				.. &amp;quot; additions on the ${TALKPAGE} first. &#039;&#039;&#039;Do not remove protection from this&amp;quot;&lt;br /&gt;
				.. &amp;quot; page unless you are authorized by the Wikimedia Foundation to do&amp;quot;&lt;br /&gt;
				.. &amp;quot; so.&#039;&#039;&#039;&amp;quot;,&lt;br /&gt;
			image = &#039;Office-protection-shackle.svg&#039;,&lt;br /&gt;
		},&lt;br /&gt;
		reset = {&lt;br /&gt;
			description = &#039;For pages protected by the Wikimedia Foundation and&#039;&lt;br /&gt;
				.. &#039; &amp;quot;reset&amp;quot; to a bare-bones version&#039;,&lt;br /&gt;
 			text = &#039;This ${PAGETYPE} is currently under the&#039;&lt;br /&gt;
					.. &#039; scrutiny of the&#039;&lt;br /&gt;
					.. &#039; [[Wikipedia:Office actions|Wikimedia Foundation Office]]&#039;&lt;br /&gt;
					.. &#039; and is protected.&#039;,&lt;br /&gt;
			explanation = function (protectionObj, args)&lt;br /&gt;
				local ret = &#039;&#039;&lt;br /&gt;
				if protectionObj.protectionDate then&lt;br /&gt;
					ret = ret .. &#039;On ${PROTECTIONDATE} this ${PAGETYPE} was&#039;&lt;br /&gt;
				else&lt;br /&gt;
					ret = ret .. &#039;This ${PAGETYPE} has been&#039;&lt;br /&gt;
				end&lt;br /&gt;
				ret = ret .. &#039; reduced to a&#039;&lt;br /&gt;
				.. &#039; simplified, &amp;quot;bare bones&amp;quot; version so that it may be completely&#039;&lt;br /&gt;
				.. &#039; rewritten to ensure it meets the policies of&#039;&lt;br /&gt;
				.. &#039; [[WP:NPOV|Neutral Point of View]] and [[WP:V|Verifiability]].&#039;&lt;br /&gt;
				.. &#039; Standard Wikipedia policies will apply to its rewriting—which&#039;&lt;br /&gt;
				.. &#039; will eventually be open to all editors—and will be strictly&#039;&lt;br /&gt;
				.. &#039; enforced. The ${PAGETYPE} has been ${PROTECTIONLEVEL} while&#039;&lt;br /&gt;
				.. &#039; it is being rebuilt.\n\n&#039;&lt;br /&gt;
				.. &#039;Any insertion of material directly from&#039;&lt;br /&gt;
				.. &#039; pre-protection revisions of the ${PAGETYPE} will be removed, as&#039;&lt;br /&gt;
				.. &#039; will any material added to the ${PAGETYPE} that is not properly&#039;&lt;br /&gt;
				.. &#039; sourced. The associated talk page(s) were also cleared on the&#039;&lt;br /&gt;
				.. &amp;quot; same date.\n\n&amp;quot;&lt;br /&gt;
				.. &amp;quot;If you can edit this page, please discuss all changes and&amp;quot;&lt;br /&gt;
				.. &amp;quot; additions on the ${TALKPAGE} first. &#039;&#039;&#039;Do not override&amp;quot;&lt;br /&gt;
				.. &amp;quot; this action, and do not remove protection from this page,&amp;quot;&lt;br /&gt;
				.. &amp;quot; unless you are authorized by the Wikimedia Foundation&amp;quot;&lt;br /&gt;
				.. &amp;quot; to do so. No editor may remove this notice.&#039;&#039;&#039;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
				return ret&lt;br /&gt;
			end,&lt;br /&gt;
			image = &#039;Office-protection-shackle.svg&#039;,&lt;br /&gt;
		},&lt;br /&gt;
		sock = {&lt;br /&gt;
			description = &#039;For pages protected due to&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Sock puppetry|sock puppetry]]&#039;,&lt;br /&gt;
			text = &#039;${INTROFRAGMENT} to prevent [[Wikipedia:Sock puppetry|sock puppets]] of&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Blocking policy|blocked]] or&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Banning policy|banned users]]&#039;&lt;br /&gt;
				.. &#039; from editing it.&#039;,&lt;br /&gt;
			tooltip = &#039;${TOOLTIPFRAGMENT} to prevent sock puppets of blocked or banned users from&#039;&lt;br /&gt;
				.. &#039; editing it&#039;,&lt;br /&gt;
		},&lt;br /&gt;
		template = {&lt;br /&gt;
			description = &#039;For [[Wikipedia:High-risk templates|high-risk]]&#039;&lt;br /&gt;
				.. &#039; templates and Lua modules&#039;,&lt;br /&gt;
			text = &#039;This is a permanently [[Help:Protection|protected]] ${PAGETYPE},&#039;&lt;br /&gt;
				.. &#039; as it is [[Wikipedia:High-risk templates|high-risk]].&#039;,&lt;br /&gt;
			explanation = &#039;Please discuss any changes on the ${TALKPAGE}; you may&#039;&lt;br /&gt;
				.. &#039; ${EDITREQUEST} to ask an&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Administrators|administrator]] or&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Template editor|template editor]] to make an edit if&#039;&lt;br /&gt;
				.. &#039; it is [[Help:Minor edit#When to mark an edit as a minor edit&#039;&lt;br /&gt;
				.. &#039;|uncontroversial]] or supported by&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Consensus|consensus]]. You can also&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Requests for page protection|request]] that the page be&#039;&lt;br /&gt;
				.. &#039; unprotected.&#039;,&lt;br /&gt;
			tooltip = &#039;This high-risk ${PAGETYPE} is permanently ${PROTECTIONLEVEL}&#039;&lt;br /&gt;
				.. &#039; to prevent vandalism&#039;,&lt;br /&gt;
			alt = &#039;Permanently protected ${PAGETYPE}&#039;,&lt;br /&gt;
		},&lt;br /&gt;
		usertalk = {&lt;br /&gt;
			description = &#039;For pages protected against disruptive edits by a&#039;&lt;br /&gt;
				.. &#039; particular user&#039;,&lt;br /&gt;
			text = &#039;${INTROFRAGMENT} to prevent ${VANDAL} from using it to make disruptive edits,&#039;&lt;br /&gt;
				.. &#039; such as abusing the&#039;&lt;br /&gt;
				.. &#039; &amp;amp;#123;&amp;amp;#123;[[Template:unblock|unblock]]&amp;amp;#125;&amp;amp;#125; template.&#039;,&lt;br /&gt;
			explanation = &#039;If you cannot edit this user talk page and you need to&#039;&lt;br /&gt;
				.. &#039; make a change or leave a message, you can&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Requests for page protection&#039;&lt;br /&gt;
				.. &#039;#Current requests for edits to a protected page&#039;&lt;br /&gt;
				.. &#039;|request an edit]],&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Requests for page protection&#039;&lt;br /&gt;
				.. &#039;#Current requests for reduction in protection level&#039;&lt;br /&gt;
				.. &#039;|request unprotection]],&#039;&lt;br /&gt;
				.. &#039; [[Special:Userlogin|log in]],&#039;&lt;br /&gt;
				.. &#039; or [[Special:UserLogin/signup|create an account]].&#039;,&lt;br /&gt;
		},&lt;br /&gt;
		vandalism = {&lt;br /&gt;
			description = &#039;For pages protected against&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Vandalism|vandalism]]&#039;,&lt;br /&gt;
			text = &#039;${INTROFRAGMENT} due to [[Wikipedia:Vandalism|vandalism]].&#039;,&lt;br /&gt;
			explanation = function (protectionObj, args)&lt;br /&gt;
				local ret = &#039;&#039;&lt;br /&gt;
				if protectionObj.level == &#039;sysop&#039; then&lt;br /&gt;
					ret = ret .. &amp;quot;This protection is &#039;&#039;&#039;not&#039;&#039;&#039; an endorsement of the&amp;quot;&lt;br /&gt;
						.. &#039; ${CURRENTVERSION}. &#039;&lt;br /&gt;
				end&lt;br /&gt;
				return ret .. &#039;${EXPLANATIONBLURB}&#039;&lt;br /&gt;
			end,&lt;br /&gt;
			tooltip = &#039;${TOOLTIPFRAGMENT} due to vandalism&#039;,&lt;br /&gt;
		}&lt;br /&gt;
	},&lt;br /&gt;
	move = {&lt;br /&gt;
		dispute = {&lt;br /&gt;
			description = &#039;For pages protected against page moves due to&#039;&lt;br /&gt;
				.. &#039; disputes over the page title&#039;,&lt;br /&gt;
			explanation = &amp;quot;This protection is &#039;&#039;&#039;not&#039;&#039;&#039; an endorsement of the&amp;quot;&lt;br /&gt;
				.. &#039; ${CURRENTVERSION}. ${EXPLANATIONBLURB}&#039;,&lt;br /&gt;
			image = &#039;Move-protection-shackle.svg&#039;&lt;br /&gt;
		},&lt;br /&gt;
		vandalism = {&lt;br /&gt;
			description = &#039;For pages protected against&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Vandalism#Page-move vandalism&#039;&lt;br /&gt;
				.. &#039; |page-move vandalism]]&#039;&lt;br /&gt;
		}&lt;br /&gt;
	},&lt;br /&gt;
	autoreview = {},&lt;br /&gt;
	upload = {}&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
--&lt;br /&gt;
--                            GENERAL DATA TABLES&lt;br /&gt;
--&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Protection blurbs&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This table produces the protection blurbs available with the&lt;br /&gt;
-- ${PROTECTIONBLURB} parameter. It is sorted by protection action and&lt;br /&gt;
-- protection level, and is checked by the module in the following order:&lt;br /&gt;
-- 1. page&#039;s protection action, page&#039;s protection level&lt;br /&gt;
-- 2. page&#039;s protection action, default protection level&lt;br /&gt;
-- 3. &amp;quot;edit&amp;quot; protection action, default protection level&lt;br /&gt;
--&lt;br /&gt;
-- It is possible to use banner parameters inside this table.&lt;br /&gt;
-- *required* - this table needs edit, move, autoreview and upload subtables.&lt;br /&gt;
protectionBlurbs = {&lt;br /&gt;
	edit = {&lt;br /&gt;
		default = &#039;This ${PAGETYPE} is currently [[Help:Protection|&#039;&lt;br /&gt;
			.. &#039;protected]] from editing&#039;,&lt;br /&gt;
		autoconfirmed = &#039;Editing of this ${PAGETYPE} by [[Wikipedia:User access&#039;&lt;br /&gt;
			.. &#039; levels#New users|new]] or [[Wikipedia:User access levels#Unregistered&#039;&lt;br /&gt;
			.. &#039; users|unregistered]] users is currently [[Help:Protection|disabled]]&#039;,&lt;br /&gt;
		extendedconfirmed = &#039;This ${PAGETYPE} is currently under extended confirmed protection&#039;,&lt;br /&gt;
	},&lt;br /&gt;
	move = {&lt;br /&gt;
		default = &#039;This ${PAGETYPE} is currently [[Help:Protection|protected]]&#039;&lt;br /&gt;
			.. &#039; from [[Help:Moving a page|page moves]]&#039;&lt;br /&gt;
	},&lt;br /&gt;
	autoreview = {&lt;br /&gt;
		default = &#039;All edits made to this ${PAGETYPE} by&#039;&lt;br /&gt;
			.. &#039; [[Wikipedia:User access levels#New users|new]] or&#039;&lt;br /&gt;
			.. &#039; [[Wikipedia:User access levels#Unregistered users|unregistered]]&#039;&lt;br /&gt;
			.. &#039; users are currently&#039;&lt;br /&gt;
			.. &#039; [[Wikipedia:Pending changes|subject to review]]&#039;&lt;br /&gt;
	},&lt;br /&gt;
	upload = {&lt;br /&gt;
		default = &#039;Uploading new versions of this ${PAGETYPE} is currently disabled&#039;&lt;br /&gt;
	}&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Explanation blurbs&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This table produces the explanation blurbs available with the&lt;br /&gt;
-- ${EXPLANATIONBLURB} parameter. It is sorted by protection action,&lt;br /&gt;
-- protection level, and whether the page is a talk page or not. If the page is&lt;br /&gt;
-- a talk page it will have a talk key of &amp;quot;talk&amp;quot;; otherwise it will have a talk&lt;br /&gt;
-- key of &amp;quot;subject&amp;quot;. The table is checked in the following order:&lt;br /&gt;
-- 1. page&#039;s protection action, page&#039;s protection level, page&#039;s talk key&lt;br /&gt;
-- 2. page&#039;s protection action, page&#039;s protection level, default talk key&lt;br /&gt;
-- 3. page&#039;s protection action, default protection level, page&#039;s talk key&lt;br /&gt;
-- 4. page&#039;s protection action, default protection level, default talk key&lt;br /&gt;
--&lt;br /&gt;
-- It is possible to use banner parameters inside this table.&lt;br /&gt;
-- *required* - this table needs edit, move, autoreview and upload subtables.&lt;br /&gt;
explanationBlurbs = {&lt;br /&gt;
	edit = {&lt;br /&gt;
		autoconfirmed = {&lt;br /&gt;
			subject = &#039;See the [[Wikipedia:Protection policy|&#039;&lt;br /&gt;
				.. &#039;protection policy]] and ${PROTECTIONLOG} for more details. If you&#039;&lt;br /&gt;
				.. &#039; cannot edit this ${PAGETYPE} and you wish to make a change, you can&#039;&lt;br /&gt;
				.. &#039; ${EDITREQUEST}, discuss changes on the ${TALKPAGE},&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Requests for page protection&#039;&lt;br /&gt;
				.. &#039;#Current requests for reduction in protection level&#039;&lt;br /&gt;
				.. &#039;|request unprotection]], [[Special:Userlogin|log in]], or&#039;&lt;br /&gt;
				.. &#039; [[Special:UserLogin/signup|create an account]].&#039;,&lt;br /&gt;
			default = &#039;See the [[Wikipedia:Protection policy|&#039;&lt;br /&gt;
				.. &#039;protection policy]] and ${PROTECTIONLOG} for more details. If you&#039;&lt;br /&gt;
				.. &#039; cannot edit this ${PAGETYPE} and you wish to make a change, you can&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Requests for page protection&#039;&lt;br /&gt;
				.. &#039;#Current requests for reduction in protection level&#039;&lt;br /&gt;
				.. &#039;|request unprotection]], [[Special:Userlogin|log in]], or&#039;&lt;br /&gt;
				.. &#039; [[Special:UserLogin/signup|create an account]].&#039;,&lt;br /&gt;
		},&lt;br /&gt;
		extendedconfirmed = {&lt;br /&gt;
			default = &#039;Extended confirmed protection prevents edits from all unregistered editors&#039;&lt;br /&gt;
				.. &#039; and registered users with fewer than 30 days tenure and 500 edits.&#039;&lt;br /&gt;
				.. &#039; The [[Wikipedia:Protection policy#extended|policy on community use]]&#039;&lt;br /&gt;
				.. &#039; specifies that extended confirmed protection can be applied to combat&#039;&lt;br /&gt;
				.. &#039; disruption, if semi-protection has proven to be ineffective.&#039;&lt;br /&gt;
				.. &#039; Extended confirmed protection may also be applied to enforce&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Arbitration Committee|arbitration sanctions]].&#039;&lt;br /&gt;
				.. &#039; Please discuss any changes on the ${TALKPAGE}; you may&#039;&lt;br /&gt;
				.. &#039; ${EDITREQUEST} to ask for uncontroversial changes supported by&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Consensus|consensus]].&#039;&lt;br /&gt;
		},&lt;br /&gt;
		default = {&lt;br /&gt;
			subject = &#039;See the [[Wikipedia:Protection policy|&#039;&lt;br /&gt;
				.. &#039;protection policy]] and ${PROTECTIONLOG} for more details.&#039;&lt;br /&gt;
				.. &#039; Please discuss any changes on the ${TALKPAGE}; you&#039;&lt;br /&gt;
				.. &#039; may ${EDITREQUEST} to ask an&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Administrators|administrator]] to make an edit if it&#039;&lt;br /&gt;
				.. &#039; is [[Help:Minor edit#When to mark an edit as a minor edit&#039;&lt;br /&gt;
				.. &#039;|uncontroversial]] or supported by [[Wikipedia:Consensus&#039;&lt;br /&gt;
				.. &#039;|consensus]]. You may also [[Wikipedia:Requests for&#039;&lt;br /&gt;
				.. &#039; page protection#Current requests for reduction in protection level&#039;&lt;br /&gt;
				.. &#039;|request]] that this page be unprotected.&#039;,&lt;br /&gt;
			default = &#039;See the [[Wikipedia:Protection policy|&#039;&lt;br /&gt;
				.. &#039;protection policy]] and ${PROTECTIONLOG} for more details.&#039;&lt;br /&gt;
				.. &#039; You may [[Wikipedia:Requests for page&#039;&lt;br /&gt;
				.. &#039; protection#Current requests for edits to a protected page|request an&#039;&lt;br /&gt;
				.. &#039; edit]] to this page, or [[Wikipedia:Requests for&#039;&lt;br /&gt;
				.. &#039; page protection#Current requests for reduction in protection level&#039;&lt;br /&gt;
				.. &#039;|ask]] for it to be unprotected.&#039;&lt;br /&gt;
		}&lt;br /&gt;
	},&lt;br /&gt;
	move = {&lt;br /&gt;
		default = {&lt;br /&gt;
			subject = &#039;See the [[Wikipedia:Protection policy|&#039;&lt;br /&gt;
				.. &#039;protection policy]] and ${PROTECTIONLOG} for more details.&#039;&lt;br /&gt;
				.. &#039; The page may still be edited but cannot be moved&#039;&lt;br /&gt;
				.. &#039; until unprotected. Please discuss any suggested moves on the&#039;&lt;br /&gt;
				.. &#039; ${TALKPAGE} or at [[Wikipedia:Requested moves]]. You can also&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Requests for page protection|request]] that the page be&#039;&lt;br /&gt;
				.. &#039; unprotected.&#039;,&lt;br /&gt;
			default = &#039;See the [[Wikipedia:Protection policy|&#039;&lt;br /&gt;
				.. &#039;protection policy]] and ${PROTECTIONLOG} for more details.&#039;&lt;br /&gt;
				.. &#039; The page may still be edited but cannot be moved&#039;&lt;br /&gt;
				.. &#039; until unprotected. Please discuss any suggested moves at&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Requested moves]]. You can also&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Requests for page protection|request]] that the page be&#039;&lt;br /&gt;
				.. &#039; unprotected.&#039;&lt;br /&gt;
		}&lt;br /&gt;
	},&lt;br /&gt;
	autoreview = {&lt;br /&gt;
		default = {&lt;br /&gt;
			default = &#039;See the [[Wikipedia:Protection policy|&#039;&lt;br /&gt;
				.. &#039;protection policy]] and ${PROTECTIONLOG} for more details.&#039;&lt;br /&gt;
				.. &#039; Edits to this ${PAGETYPE} by new and unregistered users&#039;&lt;br /&gt;
				.. &#039; will not be visible to readers until they are accepted by&#039;&lt;br /&gt;
				.. &#039; a reviewer. To avoid the need for your edits to be&#039;&lt;br /&gt;
				.. &#039; reviewed, you may&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Requests for page protection&#039;&lt;br /&gt;
				.. &#039;#Current requests for reduction in protection level&#039;&lt;br /&gt;
				.. &#039;|request unprotection]], [[Special:Userlogin|log in]], or&#039;&lt;br /&gt;
				.. &#039; [[Special:UserLogin/signup|create an account]].&#039;&lt;br /&gt;
		},&lt;br /&gt;
	},&lt;br /&gt;
	upload = {&lt;br /&gt;
		default = {&lt;br /&gt;
			default = &#039;See the [[Wikipedia:Protection policy|&#039;&lt;br /&gt;
				.. &#039;protection policy]] and ${PROTECTIONLOG} for more details.&#039;&lt;br /&gt;
				.. &#039; The page may still be edited but new versions of the file&#039;&lt;br /&gt;
				.. &#039; cannot be uploaded until it is unprotected. You can&#039;&lt;br /&gt;
				.. &#039; request that a new version be uploaded by using a&#039;&lt;br /&gt;
				.. &#039; [[Wikipedia:Edit requests|protected edit request]], or you&#039;&lt;br /&gt;
				.. &#039; can  [[Wikipedia:Requests for page protection|request]]&#039;&lt;br /&gt;
				.. &#039; that the file be unprotected.&#039;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Protection levels&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This table provides the data for the ${PROTECTIONLEVEL} parameter, which&lt;br /&gt;
-- produces a short label for different protection levels. It is sorted by&lt;br /&gt;
-- protection action and protection level, and is checked in the following&lt;br /&gt;
-- order:&lt;br /&gt;
-- 1. page&#039;s protection action, page&#039;s protection level&lt;br /&gt;
-- 2. page&#039;s protection action, default protection level&lt;br /&gt;
-- 3. &amp;quot;edit&amp;quot; protection action, default protection level&lt;br /&gt;
--&lt;br /&gt;
-- It is possible to use banner parameters inside this table.&lt;br /&gt;
-- *required* - this table needs edit, move, autoreview and upload subtables.&lt;br /&gt;
protectionLevels = {&lt;br /&gt;
	edit = {&lt;br /&gt;
		default = &#039;protected&#039;,&lt;br /&gt;
		templateeditor = &#039;template-protected&#039;,&lt;br /&gt;
		extendedconfirmed = &#039;extended-protected&#039;,&lt;br /&gt;
		autoconfirmed = &#039;semi-protected&#039;,&lt;br /&gt;
	},&lt;br /&gt;
	move = {&lt;br /&gt;
		default = &#039;move-protected&#039;&lt;br /&gt;
	},&lt;br /&gt;
	autoreview = {&lt;br /&gt;
	},&lt;br /&gt;
	upload = {&lt;br /&gt;
		default = &#039;upload-protected&#039;&lt;br /&gt;
	}&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Images&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This table lists different padlock images for each protection action and&lt;br /&gt;
-- protection level. It is used if an image is not specified in any of the&lt;br /&gt;
-- banner data tables, and if the page does not satisfy the conditions for using&lt;br /&gt;
-- the [&#039;image-filename-indef&#039;] image. It is checked in the following order:&lt;br /&gt;
-- 1. page&#039;s protection action, page&#039;s protection level&lt;br /&gt;
-- 2. page&#039;s protection action, default protection level&lt;br /&gt;
images = {&lt;br /&gt;
	edit = {&lt;br /&gt;
		default = &#039;Full-protection-shackle.svg&#039;,&lt;br /&gt;
		templateeditor = &#039;Template-protection-shackle.svg&#039;,&lt;br /&gt;
		extendedconfirmed = &#039;Extended-protection-shackle.svg&#039;,&lt;br /&gt;
		autoconfirmed = &#039;Semi-protection-shackle.svg&#039;&lt;br /&gt;
	},&lt;br /&gt;
	move = {&lt;br /&gt;
		default = &#039;Move-protection-shackle.svg&#039;,&lt;br /&gt;
	},&lt;br /&gt;
	autoreview = {&lt;br /&gt;
		default = &#039;Pending-protection-shackle.svg&#039;&lt;br /&gt;
	},&lt;br /&gt;
	upload = {&lt;br /&gt;
		default = &#039;Upload-protection-shackle.svg&#039;&lt;br /&gt;
	}&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
-- Pages with a reason specified in this table will show the special &amp;quot;indef&amp;quot;&lt;br /&gt;
-- padlock, defined in the &#039;image-filename-indef&#039; message, if no expiry is set.&lt;br /&gt;
indefImageReasons = {&lt;br /&gt;
	template = true&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Image links&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This table provides the data for the ${IMAGELINK} parameter, which gets&lt;br /&gt;
-- the image link for small padlock icons based on the page&#039;s protection action&lt;br /&gt;
-- and protection level. It is checked in the following order:&lt;br /&gt;
-- 1. page&#039;s protection action, page&#039;s protection level&lt;br /&gt;
-- 2. page&#039;s protection action, default protection level&lt;br /&gt;
-- 3. &amp;quot;edit&amp;quot; protection action, default protection level&lt;br /&gt;
--&lt;br /&gt;
-- It is possible to use banner parameters inside this table.&lt;br /&gt;
-- *required* - this table needs edit, move, autoreview and upload subtables.&lt;br /&gt;
imageLinks = {&lt;br /&gt;
	edit = {&lt;br /&gt;
		default = &#039;Wikipedia:Protection policy#full&#039;,&lt;br /&gt;
		templateeditor = &#039;Wikipedia:Protection policy#template&#039;,&lt;br /&gt;
		extendedconfirmed = &#039;Wikipedia:Protection policy#extended&#039;,&lt;br /&gt;
		autoconfirmed = &#039;Wikipedia:Protection policy#semi&#039;&lt;br /&gt;
	},&lt;br /&gt;
	move = {&lt;br /&gt;
		default = &#039;Wikipedia:Protection policy#move&#039;&lt;br /&gt;
	},&lt;br /&gt;
	autoreview = {&lt;br /&gt;
		default = &#039;Wikipedia:Protection policy#pending&#039;&lt;br /&gt;
	},&lt;br /&gt;
	upload = {&lt;br /&gt;
		default = &#039;Wikipedia:Protection policy#upload&#039;&lt;br /&gt;
	}&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Padlock indicator names&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This table provides the &amp;quot;name&amp;quot; attribute for the &amp;lt;indicator&amp;gt; extension tag&lt;br /&gt;
-- with which small padlock icons are generated. All indicator tags on a page&lt;br /&gt;
-- are displayed in alphabetical order based on this attribute, and with&lt;br /&gt;
-- indicator tags with duplicate names, the last tag on the page wins.&lt;br /&gt;
-- The attribute is chosen based on the protection action; table keys must be a&lt;br /&gt;
-- protection action name or the string &amp;quot;default&amp;quot;.&lt;br /&gt;
padlockIndicatorNames = {&lt;br /&gt;
	autoreview = &#039;pp-autoreview&#039;,&lt;br /&gt;
	default = &#039;pp-default&#039;&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Protection categories&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- The protection categories are stored in the protectionCategories table.&lt;br /&gt;
-- Keys to this table are made up of the following strings:&lt;br /&gt;
--&lt;br /&gt;
-- 1. the expiry date&lt;br /&gt;
-- 2. the namespace&lt;br /&gt;
-- 3. the protection reason (e.g. &amp;quot;dispute&amp;quot; or &amp;quot;vandalism&amp;quot;)&lt;br /&gt;
-- 4. the protection level (e.g. &amp;quot;sysop&amp;quot; or &amp;quot;autoconfirmed&amp;quot;)&lt;br /&gt;
-- 5. the action (e.g. &amp;quot;edit&amp;quot; or &amp;quot;move&amp;quot;)&lt;br /&gt;
-- &lt;br /&gt;
-- When the module looks up a category in the table, first it will will check to&lt;br /&gt;
-- see a key exists that corresponds to all five parameters. For example, a&lt;br /&gt;
-- user page semi-protected from vandalism for two weeks would have the key&lt;br /&gt;
-- &amp;quot;temp-user-vandalism-autoconfirmed-edit&amp;quot;. If no match is found, the module&lt;br /&gt;
-- changes the first part of the key to &amp;quot;all&amp;quot; and checks the table again. It&lt;br /&gt;
-- keeps checking increasingly generic key combinations until it finds the&lt;br /&gt;
-- field, or until it reaches the key &amp;quot;all-all-all-all-all&amp;quot;.&lt;br /&gt;
--&lt;br /&gt;
-- The module uses a binary matrix to determine the order in which to search.&lt;br /&gt;
-- This is best demonstrated by a table. In this table, the &amp;quot;0&amp;quot; values&lt;br /&gt;
-- represent &amp;quot;all&amp;quot;, and the &amp;quot;1&amp;quot; values represent the original data (e.g.&lt;br /&gt;
-- &amp;quot;indef&amp;quot; or &amp;quot;file&amp;quot; or &amp;quot;vandalism&amp;quot;).&lt;br /&gt;
--&lt;br /&gt;
--        expiry    namespace reason   level     action&lt;br /&gt;
-- order&lt;br /&gt;
-- 1      1         1         1        1         1&lt;br /&gt;
-- 2      0         1         1        1         1&lt;br /&gt;
-- 3      1         0         1        1         1&lt;br /&gt;
-- 4      0         0         1        1         1&lt;br /&gt;
-- 5      1         1         0        1         1&lt;br /&gt;
-- 6      0         1         0        1         1&lt;br /&gt;
-- 7      1         0         0        1         1&lt;br /&gt;
-- 8      0         0         0        1         1&lt;br /&gt;
-- 9      1         1         1        0         1&lt;br /&gt;
-- 10     0         1         1        0         1&lt;br /&gt;
-- 11     1         0         1        0         1&lt;br /&gt;
-- 12     0         0         1        0         1&lt;br /&gt;
-- 13     1         1         0        0         1&lt;br /&gt;
-- 14     0         1         0        0         1&lt;br /&gt;
-- 15     1         0         0        0         1&lt;br /&gt;
-- 16     0         0         0        0         1&lt;br /&gt;
-- 17     1         1         1        1         0&lt;br /&gt;
-- 18     0         1         1        1         0&lt;br /&gt;
-- 19     1         0         1        1         0&lt;br /&gt;
-- 20     0         0         1        1         0&lt;br /&gt;
-- 21     1         1         0        1         0&lt;br /&gt;
-- 22     0         1         0        1         0&lt;br /&gt;
-- 23     1         0         0        1         0&lt;br /&gt;
-- 24     0         0         0        1         0&lt;br /&gt;
-- 25     1         1         1        0         0&lt;br /&gt;
-- 26     0         1         1        0         0&lt;br /&gt;
-- 27     1         0         1        0         0&lt;br /&gt;
-- 28     0         0         1        0         0&lt;br /&gt;
-- 29     1         1         0        0         0&lt;br /&gt;
-- 30     0         1         0        0         0&lt;br /&gt;
-- 31     1         0         0        0         0&lt;br /&gt;
-- 32     0         0         0        0         0&lt;br /&gt;
--&lt;br /&gt;
-- In this scheme the action has the highest priority, as it is the last&lt;br /&gt;
-- to change, and the expiry has the least priority, as it changes the most.&lt;br /&gt;
-- The priorities of the expiry, the protection level and the action are&lt;br /&gt;
-- fixed, but the priorities of the reason and the namespace can be swapped&lt;br /&gt;
-- through the use of the cfg.bannerDataNamespaceHasPriority table.&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
-- If the reason specified to the template is listed in this table,&lt;br /&gt;
-- namespace data will take priority over reason data in the protectionCategories&lt;br /&gt;
-- table.&lt;br /&gt;
reasonsWithNamespacePriority = {&lt;br /&gt;
	vandalism = true,&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
-- The string to use as a namespace key for the protectionCategories table for each&lt;br /&gt;
-- namespace number.&lt;br /&gt;
categoryNamespaceKeys = {&lt;br /&gt;
	[  2] = &#039;user&#039;,&lt;br /&gt;
	[  3] = &#039;user&#039;,&lt;br /&gt;
	[  4] = &#039;project&#039;,&lt;br /&gt;
	[  6] = &#039;file&#039;,&lt;br /&gt;
	[  8] = &#039;mediawiki&#039;,&lt;br /&gt;
	[ 10] = &#039;template&#039;,&lt;br /&gt;
	[ 12] = &#039;project&#039;,&lt;br /&gt;
	[ 14] = &#039;category&#039;,&lt;br /&gt;
	[100] = &#039;portal&#039;,&lt;br /&gt;
	[828] = &#039;module&#039;,&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
protectionCategories = {&lt;br /&gt;
	[&#039;all|all|all|all|all&#039;]                     = &#039;Wikipedia fully protected pages&#039;,&lt;br /&gt;
	[&#039;all|all|office|all|all&#039;]                  = &#039;Wikipedia Office-protected pages&#039;,&lt;br /&gt;
	[&#039;all|all|reset|all|all&#039;]                   = &#039;Wikipedia Office-protected pages&#039;,&lt;br /&gt;
	[&#039;all|all|dmca|all|all&#039;]                    = &#039;Wikipedia Office-protected pages&#039;,&lt;br /&gt;
	[&#039;all|all|mainpage|all|all&#039;]                = &#039;Wikipedia fully-protected main page files&#039;,&lt;br /&gt;
	[&#039;all|all|all|extendedconfirmed|all&#039;]       = &#039;Wikipedia extended-confirmed-protected pages&#039;,&lt;br /&gt;
	[&#039;all|all|ecp|extendedconfirmed|all&#039;]       = &#039;Wikipedia extended-confirmed-protected pages&#039;,&lt;br /&gt;
	[&#039;all|template|all|all|edit&#039;]               = &#039;Wikipedia fully protected templates&#039;,&lt;br /&gt;
	[&#039;all|all|all|autoconfirmed|edit&#039;]          = &#039;Wikipedia semi-protected pages&#039;,&lt;br /&gt;
	[&#039;indef|all|all|autoconfirmed|edit&#039;]        = &#039;Wikipedia indefinitely semi-protected pages&#039;,&lt;br /&gt;
	[&#039;all|all|blp|autoconfirmed|edit&#039;]          = &#039;Wikipedia indefinitely semi-protected biographies of living people&#039;,&lt;br /&gt;
	[&#039;temp|all|blp|autoconfirmed|edit&#039;]         = &#039;Wikipedia temporarily semi-protected biographies of living people&#039;,&lt;br /&gt;
	[&#039;all|all|dispute|autoconfirmed|edit&#039;]      = &#039;Wikipedia pages semi-protected due to dispute&#039;,&lt;br /&gt;
	[&#039;all|all|sock|autoconfirmed|edit&#039;]         = &#039;Wikipedia pages semi-protected from banned users&#039;,&lt;br /&gt;
	[&#039;all|all|vandalism|autoconfirmed|edit&#039;]    = &#039;Wikipedia pages semi-protected against vandalism&#039;,&lt;br /&gt;
	[&#039;all|category|all|autoconfirmed|edit&#039;]     = &#039;Wikipedia semi-protected categories&#039;,&lt;br /&gt;
	[&#039;all|file|all|autoconfirmed|edit&#039;]         = &#039;Wikipedia semi-protected files&#039;,&lt;br /&gt;
	[&#039;all|portal|all|autoconfirmed|edit&#039;]       = &#039;Wikipedia semi-protected portals&#039;,&lt;br /&gt;
	[&#039;all|project|all|autoconfirmed|edit&#039;]      = &#039;Wikipedia semi-protected project pages&#039;,&lt;br /&gt;
	[&#039;all|talk|all|autoconfirmed|edit&#039;]         = &#039;Wikipedia semi-protected talk pages&#039;,&lt;br /&gt;
	[&#039;all|template|all|autoconfirmed|edit&#039;]     = &#039;Wikipedia semi-protected templates&#039;,&lt;br /&gt;
	[&#039;all|user|all|autoconfirmed|edit&#039;]         = &#039;Wikipedia semi-protected user and user talk pages&#039;,&lt;br /&gt;
	[&#039;all|template|all|templateeditor|edit&#039;]    = &#039;Wikipedia template-protected templates&#039;,&lt;br /&gt;
	[&#039;all|template|all|templateeditor|move&#039;]    = &#039;Wikipedia template-protected templates&#039;, -- move-protected&lt;br /&gt;
	[&#039;all|all|blp|sysop|edit&#039;]                  = &#039;Wikipedia indefinitely protected biographies of living people&#039;,&lt;br /&gt;
	[&#039;temp|all|blp|sysop|edit&#039;]                 = &#039;Wikipedia temporarily protected biographies of living people&#039;,&lt;br /&gt;
	[&#039;all|all|dispute|sysop|edit&#039;]              = &#039;Wikipedia pages protected due to dispute&#039;,&lt;br /&gt;
	[&#039;all|all|sock|sysop|edit&#039;]                 = &#039;Wikipedia pages protected from banned users&#039;,&lt;br /&gt;
	[&#039;all|all|vandalism|sysop|edit&#039;]            = &#039;Wikipedia pages protected against vandalism&#039;,&lt;br /&gt;
	[&#039;all|category|all|sysop|edit&#039;]             = &#039;Wikipedia fully protected categories&#039;,&lt;br /&gt;
	[&#039;all|file|all|sysop|edit&#039;]                 = &#039;Wikipedia fully-protected files&#039;,&lt;br /&gt;
	[&#039;all|project|all|sysop|edit&#039;]              = &#039;Wikipedia fully-protected project pages&#039;,&lt;br /&gt;
	[&#039;all|talk|all|sysop|edit&#039;]                 = &#039;Wikipedia fully-protected talk pages&#039;,&lt;br /&gt;
	[&#039;all|template|all|extendedconfirmed|edit&#039;] = &#039;Wikipedia extended-confirmed-protected templates&#039;,&lt;br /&gt;
	[&#039;all|template|all|sysop|edit&#039;]             = &#039;Wikipedia fully protected templates&#039;,&lt;br /&gt;
	[&#039;all|user|all|sysop|edit&#039;]                 = &#039;Wikipedia fully protected user and user talk pages&#039;,&lt;br /&gt;
	[&#039;all|module|all|all|edit&#039;]                 = &#039;Wikipedia fully-protected modules&#039;,&lt;br /&gt;
	[&#039;all|module|all|templateeditor|edit&#039;]      = &#039;Wikipedia template-protected modules&#039;,&lt;br /&gt;
	[&#039;all|module|all|autoconfirmed|edit&#039;]       = &#039;Wikipedia semi-protected modules&#039;,&lt;br /&gt;
	[&#039;all|all|all|sysop|move&#039;]                  = &#039;Wikipedia move-protected pages&#039;,&lt;br /&gt;
	[&#039;indef|all|all|sysop|move&#039;]                = &#039;Wikipedia indefinitely move-protected pages&#039;,&lt;br /&gt;
	[&#039;all|all|dispute|sysop|move&#039;]              = &#039;Wikipedia pages move-protected due to dispute&#039;,&lt;br /&gt;
	[&#039;all|all|vandalism|sysop|move&#039;]            = &#039;Wikipedia pages move-protected due to vandalism&#039;,&lt;br /&gt;
	[&#039;all|portal|all|sysop|move&#039;]               = &#039;Wikipedia move-protected portals&#039;,&lt;br /&gt;
	[&#039;all|portal|all|sysop|move&#039;]               = &#039;Wikipedia move-protected portals&#039;,&lt;br /&gt;
	[&#039;all|project|all|sysop|move&#039;]              = &#039;Wikipedia move-protected project pages&#039;,&lt;br /&gt;
	[&#039;all|talk|all|sysop|move&#039;]                 = &#039;Wikipedia move-protected talk pages&#039;,&lt;br /&gt;
	[&#039;all|template|all|sysop|move&#039;]             = &#039;Wikipedia move-protected templates&#039;,&lt;br /&gt;
	[&#039;all|user|all|sysop|move&#039;]                 = &#039;Wikipedia move-protected user and user talk pages&#039;,&lt;br /&gt;
	[&#039;all|all|all|autoconfirmed|autoreview&#039;]    = &#039;Wikipedia pending changes protected pages&#039;,&lt;br /&gt;
	[&#039;all|file|all|all|upload&#039;]                 = &#039;Wikipedia upload-protected files&#039;,&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Expiry category config&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This table configures the expiry category behaviour for each protection&lt;br /&gt;
-- action.&lt;br /&gt;
-- * If set to true, setting that action will always categorise the page if&lt;br /&gt;
--   an expiry parameter is not set.&lt;br /&gt;
-- * If set to false, setting that action will never categorise the page.&lt;br /&gt;
-- * If set to nil, the module will categorise the page if:&lt;br /&gt;
--   1) an expiry parameter is not set, and&lt;br /&gt;
--   2) a reason is provided, and&lt;br /&gt;
--   3) the specified reason is not blacklisted in the reasonsWithoutExpiryCheck&lt;br /&gt;
--      table.&lt;br /&gt;
&lt;br /&gt;
expiryCheckActions = {&lt;br /&gt;
	edit = nil,&lt;br /&gt;
	move = false,&lt;br /&gt;
	autoreview = true,&lt;br /&gt;
	upload = false&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
reasonsWithoutExpiryCheck = {&lt;br /&gt;
	blp = true,&lt;br /&gt;
	template = true,&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Pagetypes&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This table produces the page types available with the ${PAGETYPE} parameter.&lt;br /&gt;
-- Keys are namespace numbers, or the string &amp;quot;default&amp;quot; for the default value.&lt;br /&gt;
pagetypes = {&lt;br /&gt;
	[0] = &#039;article&#039;,&lt;br /&gt;
	[6] = &#039;file&#039;,&lt;br /&gt;
	[10] = &#039;template&#039;,&lt;br /&gt;
	[14] = &#039;category&#039;,&lt;br /&gt;
	[828] = &#039;module&#039;,&lt;br /&gt;
	default = &#039;page&#039;&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Strings marking indefinite protection&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This table contains values passed to the expiry parameter that mean the page&lt;br /&gt;
-- is protected indefinitely.&lt;br /&gt;
indefStrings = {&lt;br /&gt;
	[&#039;indef&#039;] = true,&lt;br /&gt;
	[&#039;indefinite&#039;] = true,&lt;br /&gt;
	[&#039;indefinitely&#039;] = true,&lt;br /&gt;
	[&#039;infinite&#039;] = true,&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Group hierarchy&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This table maps each group to all groups that have a superset of the original&lt;br /&gt;
-- group&#039;s page editing permissions.&lt;br /&gt;
hierarchy = {&lt;br /&gt;
	sysop = {},&lt;br /&gt;
	reviewer = {&#039;sysop&#039;},&lt;br /&gt;
	filemover = {&#039;sysop&#039;},&lt;br /&gt;
	templateeditor = {&#039;sysop&#039;},&lt;br /&gt;
	extendedconfirmed = {&#039;sysop&#039;},&lt;br /&gt;
	autoconfirmed = {&#039;reviewer&#039;, &#039;filemover&#039;, &#039;templateeditor&#039;, &#039;extendedconfirmed&#039;},&lt;br /&gt;
	user = {&#039;autoconfirmed&#039;},&lt;br /&gt;
	[&#039;*&#039;] = {&#039;user&#039;}&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Wrapper templates and their default arguments&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This table contains wrapper templates used with the module, and their&lt;br /&gt;
-- default arguments. Templates specified in this table should contain the&lt;br /&gt;
-- following invocation, and no other template content:&lt;br /&gt;
--&lt;br /&gt;
-- {{#invoke:Protection banner|main}}&lt;br /&gt;
--&lt;br /&gt;
-- If other content is desired, it can be added between&lt;br /&gt;
-- &amp;lt;noinclude&amp;gt;...&amp;lt;/noinclude&amp;gt; tags.&lt;br /&gt;
--&lt;br /&gt;
-- When a user calls one of these wrapper templates, they will use the&lt;br /&gt;
-- default arguments automatically. However, users can override any of the&lt;br /&gt;
-- arguments.&lt;br /&gt;
wrappers = {&lt;br /&gt;
	[&#039;Template:Pp&#039;]                         = {},&lt;br /&gt;
	[&#039;Template:Pp-extended&#039;]                = {&#039;ecp&#039;},&lt;br /&gt;
	[&#039;Template:Pp-blp&#039;]                     = {&#039;blp&#039;},&lt;br /&gt;
	-- we don&#039;t need Template:Pp-create&lt;br /&gt;
	[&#039;Template:Pp-dispute&#039;]                 = {&#039;dispute&#039;},&lt;br /&gt;
	[&#039;Template:Pp-main-page&#039;]               = {&#039;mainpage&#039;},&lt;br /&gt;
	[&#039;Template:Pp-move&#039;]                    = {action = &#039;move&#039;},&lt;br /&gt;
	[&#039;Template:Pp-move-dispute&#039;]            = {&#039;dispute&#039;, action = &#039;move&#039;},&lt;br /&gt;
	-- we don&#039;t need Template:Pp-move-indef&lt;br /&gt;
	[&#039;Template:Pp-move-vandalism&#039;]          = {&#039;vandalism&#039;, action = &#039;move&#039;},&lt;br /&gt;
	[&#039;Template:Pp-office&#039;]                  = {&#039;office&#039;},&lt;br /&gt;
	[&#039;Template:Pp-office-dmca&#039;]             = {&#039;dmca&#039;},&lt;br /&gt;
	[&#039;Template:Pp-pc&#039;]                      = {action = &#039;autoreview&#039;, small = true},&lt;br /&gt;
	[&#039;Template:Pp-pc1&#039;]                     = {action = &#039;autoreview&#039;, small = true},&lt;br /&gt;
	[&#039;Template:Pp-reset&#039;]                   = {&#039;reset&#039;},&lt;br /&gt;
	[&#039;Template:Pp-semi-indef&#039;]              = {small = true},&lt;br /&gt;
	[&#039;Template:Pp-sock&#039;]                    = {&#039;sock&#039;},&lt;br /&gt;
	[&#039;Template:Pp-template&#039;]                = {&#039;template&#039;, small = true},&lt;br /&gt;
	[&#039;Template:Pp-upload&#039;]                  = {action = &#039;upload&#039;},&lt;br /&gt;
	[&#039;Template:Pp-usertalk&#039;]                = {&#039;usertalk&#039;},&lt;br /&gt;
	[&#039;Template:Pp-vandalism&#039;]               = {&#039;vandalism&#039;},&lt;br /&gt;
},&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- &lt;br /&gt;
--                                 MESSAGES&lt;br /&gt;
-- &lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
msg = {&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Intro blurb and intro fragment&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- These messages specify what is produced by the ${INTROBLURB} and&lt;br /&gt;
-- ${INTROFRAGMENT} parameters. If the protection is temporary they use the&lt;br /&gt;
-- intro-blurb-expiry or intro-fragment-expiry, and if not they use&lt;br /&gt;
-- intro-blurb-noexpiry or intro-fragment-noexpiry.&lt;br /&gt;
-- It is possible to use banner parameters in these messages.&lt;br /&gt;
[&#039;intro-blurb-expiry&#039;] = &#039;${PROTECTIONBLURB} until ${EXPIRY}.&#039;,&lt;br /&gt;
[&#039;intro-blurb-noexpiry&#039;] = &#039;${PROTECTIONBLURB}.&#039;,&lt;br /&gt;
[&#039;intro-fragment-expiry&#039;] = &#039;${PROTECTIONBLURB} until ${EXPIRY},&#039;,&lt;br /&gt;
[&#039;intro-fragment-noexpiry&#039;] = &#039;${PROTECTIONBLURB}&#039;,&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Tooltip blurb&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- These messages specify what is produced by the ${TOOLTIPBLURB} parameter.&lt;br /&gt;
-- If the protection is temporary the tooltip-blurb-expiry message is used, and&lt;br /&gt;
-- if not the tooltip-blurb-noexpiry message is used.&lt;br /&gt;
-- It is possible to use banner parameters in these messages.&lt;br /&gt;
[&#039;tooltip-blurb-expiry&#039;] = &#039;This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY}.&#039;,&lt;br /&gt;
[&#039;tooltip-blurb-noexpiry&#039;] = &#039;This ${PAGETYPE} is ${PROTECTIONLEVEL}.&#039;,&lt;br /&gt;
[&#039;tooltip-fragment-expiry&#039;] = &#039;This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY},&#039;,&lt;br /&gt;
[&#039;tooltip-fragment-noexpiry&#039;] = &#039;This ${PAGETYPE} is ${PROTECTIONLEVEL}&#039;,&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Special explanation blurb&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- An explanation blurb for pages that cannot be unprotected, e.g. for pages&lt;br /&gt;
-- in the MediaWiki namespace.&lt;br /&gt;
-- It is possible to use banner parameters in this message.&lt;br /&gt;
[&#039;explanation-blurb-nounprotect&#039;] = &#039;See the [[Wikipedia:Protection policy|&#039;&lt;br /&gt;
	.. &#039;protection policy]] and ${PROTECTIONLOG} for more details.&#039;&lt;br /&gt;
	.. &#039; Please discuss any changes on the ${TALKPAGE}; you&#039;&lt;br /&gt;
	.. &#039; may ${EDITREQUEST} to ask an&#039;&lt;br /&gt;
	.. &#039; [[Wikipedia:Administrators|administrator]] to make an edit if it&#039;&lt;br /&gt;
	.. &#039; is [[Help:Minor edit#When to mark an edit as a minor edit&#039;&lt;br /&gt;
	.. &#039;|uncontroversial]] or supported by [[Wikipedia:Consensus&#039;&lt;br /&gt;
	.. &#039;|consensus]].&#039;,&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Protection log display values&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- These messages determine the display values for the protection log link&lt;br /&gt;
-- or the pending changes log link produced by the ${PROTECTIONLOG} parameter.&lt;br /&gt;
-- It is possible to use banner parameters in these messages.&lt;br /&gt;
[&#039;protection-log-display&#039;] = &#039;protection log&#039;,&lt;br /&gt;
[&#039;pc-log-display&#039;] = &#039;pending changes log&#039;,&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Current version display values&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- These messages determine the display values for the page history link&lt;br /&gt;
-- or the move log link produced by the ${CURRENTVERSION} parameter.&lt;br /&gt;
-- It is possible to use banner parameters in these messages.&lt;br /&gt;
[&#039;current-version-move-display&#039;] = &#039;current title&#039;,&lt;br /&gt;
[&#039;current-version-edit-display&#039;] = &#039;current version&#039;,&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Talk page&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This message determines the display value of the talk page link produced&lt;br /&gt;
-- with the ${TALKPAGE} parameter.&lt;br /&gt;
-- It is possible to use banner parameters in this message.&lt;br /&gt;
[&#039;talk-page-link-display&#039;] = &#039;talk page&#039;,&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Edit requests&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This message determines the display value of the edit request link produced&lt;br /&gt;
-- with the ${EDITREQUEST} parameter.&lt;br /&gt;
-- It is possible to use banner parameters in this message.&lt;br /&gt;
[&#039;edit-request-display&#039;] = &#039;submit an edit request&#039;,&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Expiry date format&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- This is the format for the blurb expiry date. It should be valid input for&lt;br /&gt;
-- the first parameter of the #time parser function.&lt;br /&gt;
[&#039;expiry-date-format&#039;] = &#039;F j, Y &amp;quot;at&amp;quot; H:i e&#039;,&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Tracking categories&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- These messages determine which tracking categories the module outputs.&lt;br /&gt;
[&#039;tracking-category-incorrect&#039;] = &#039;Wikipedia pages with incorrect protection templates&#039;,&lt;br /&gt;
[&#039;tracking-category-template&#039;] = &#039;Wikipedia template-protected pages other than templates and modules&#039;,&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Images&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- These are images that are not defined by their protection action and protection level.&lt;br /&gt;
[&#039;image-filename-indef&#039;] = &#039;Full-protection-shackle.svg&#039;,&lt;br /&gt;
[&#039;image-filename-default&#039;] = &#039;Transparent.gif&#039;,&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- End messages&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- End configuration&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Protection_banner&amp;diff=639</id>
		<title>Module:Protection banner</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Protection_banner&amp;diff=639"/>
		<updated>2021-04-26T10:44:14Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;-- This module implements {{pp-meta}} and its daughter templates such as&lt;br /&gt;
-- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}.&lt;br /&gt;
&lt;br /&gt;
-- Initialise necessary modules.&lt;br /&gt;
require(&#039;Module:No globals&#039;)&lt;br /&gt;
local makeFileLink = require(&#039;Module:File link&#039;)._main&lt;br /&gt;
local effectiveProtectionLevel = require(&#039;Module:Effective protection level&#039;)._main&lt;br /&gt;
local effectiveProtectionExpiry = require(&#039;Module:Effective protection expiry&#039;)._main&lt;br /&gt;
local yesno = require(&#039;Module:Yesno&#039;)&lt;br /&gt;
&lt;br /&gt;
-- Lazily initialise modules and objects we don&#039;t always need.&lt;br /&gt;
local getArgs, makeMessageBox, lang&lt;br /&gt;
&lt;br /&gt;
-- Set constants.&lt;br /&gt;
local CONFIG_MODULE = &#039;Module:Protection banner/config&#039;&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Helper functions&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local function makeCategoryLink(cat, sort)&lt;br /&gt;
	if cat then&lt;br /&gt;
		return string.format(&lt;br /&gt;
			&#039;[[%s:%s|%s]]&#039;,&lt;br /&gt;
			mw.site.namespaces[14].name,&lt;br /&gt;
			cat,&lt;br /&gt;
			sort&lt;br /&gt;
		)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Validation function for the expiry and the protection date&lt;br /&gt;
local function validateDate(dateString, dateType)&lt;br /&gt;
	if not lang then&lt;br /&gt;
		lang = mw.language.getContentLanguage()&lt;br /&gt;
	end&lt;br /&gt;
	local success, result = pcall(lang.formatDate, lang, &#039;U&#039;, dateString)&lt;br /&gt;
	if success then&lt;br /&gt;
		result = tonumber(result)&lt;br /&gt;
		if result then&lt;br /&gt;
			return result&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	error(string.format(&lt;br /&gt;
		&#039;invalid %s: %s&#039;,&lt;br /&gt;
		dateType,&lt;br /&gt;
		tostring(dateString)&lt;br /&gt;
	), 4)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function makeFullUrl(page, query, display)&lt;br /&gt;
	return string.format(&lt;br /&gt;
		&#039;[%s %s]&#039;,&lt;br /&gt;
		tostring(mw.uri.fullUrl(page, query)),&lt;br /&gt;
		display&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Given a directed graph formatted as node -&amp;gt; table of direct successors,&lt;br /&gt;
-- get a table of all nodes reachable from a given node (though always&lt;br /&gt;
-- including the given node).&lt;br /&gt;
local function getReachableNodes(graph, start)&lt;br /&gt;
	local toWalk, retval = {[start] = true}, {}&lt;br /&gt;
	while true do&lt;br /&gt;
		-- Can&#039;t use pairs() since we&#039;re adding and removing things as we&#039;re iterating&lt;br /&gt;
		local k = next(toWalk) -- This always gets the &amp;quot;first&amp;quot; key&lt;br /&gt;
		if k == nil then&lt;br /&gt;
			return retval&lt;br /&gt;
		end&lt;br /&gt;
		toWalk[k] = nil&lt;br /&gt;
		retval[k] = true&lt;br /&gt;
		for _,v in ipairs(graph[k]) do&lt;br /&gt;
			if not retval[v] then&lt;br /&gt;
				toWalk[v] = true&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Protection class&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local Protection = {}&lt;br /&gt;
Protection.__index = Protection&lt;br /&gt;
&lt;br /&gt;
Protection.supportedActions = {&lt;br /&gt;
	edit = true,&lt;br /&gt;
	move = true,&lt;br /&gt;
	autoreview = true,&lt;br /&gt;
	upload = true&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Protection.bannerConfigFields = {&lt;br /&gt;
	&#039;text&#039;,&lt;br /&gt;
	&#039;explanation&#039;,&lt;br /&gt;
	&#039;tooltip&#039;,&lt;br /&gt;
	&#039;alt&#039;,&lt;br /&gt;
	&#039;link&#039;,&lt;br /&gt;
	&#039;image&#039;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function Protection.new(args, cfg, title)&lt;br /&gt;
	local obj = {}&lt;br /&gt;
	obj._cfg = cfg&lt;br /&gt;
	obj.title = title or mw.title.getCurrentTitle()&lt;br /&gt;
&lt;br /&gt;
	-- Set action&lt;br /&gt;
	if not args.action then&lt;br /&gt;
		obj.action = &#039;edit&#039;&lt;br /&gt;
	elseif Protection.supportedActions[args.action] then&lt;br /&gt;
		obj.action = args.action&lt;br /&gt;
	else&lt;br /&gt;
		error(string.format(&lt;br /&gt;
			&#039;invalid action: %s&#039;,&lt;br /&gt;
			tostring(args.action)&lt;br /&gt;
		), 3)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Set level&lt;br /&gt;
	obj.level = args.demolevel or effectiveProtectionLevel(obj.action, obj.title)&lt;br /&gt;
	if not obj.level or (obj.action == &#039;move&#039; and obj.level == &#039;autoconfirmed&#039;) then&lt;br /&gt;
		-- Users need to be autoconfirmed to move pages anyway, so treat&lt;br /&gt;
		-- semi-move-protected pages as unprotected.&lt;br /&gt;
		obj.level = &#039;*&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Set expiry&lt;br /&gt;
	local effectiveExpiry = effectiveProtectionExpiry(obj.action, obj.title)&lt;br /&gt;
	if effectiveExpiry == &#039;infinity&#039; then&lt;br /&gt;
		obj.expiry = &#039;indef&#039;&lt;br /&gt;
	elseif effectiveExpiry ~= &#039;unknown&#039; then&lt;br /&gt;
		obj.expiry = validateDate(effectiveExpiry, &#039;expiry date&#039;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Set reason&lt;br /&gt;
	if args[1] then&lt;br /&gt;
		obj.reason = mw.ustring.lower(args[1])&lt;br /&gt;
		if obj.reason:find(&#039;|&#039;) then&lt;br /&gt;
			error(&#039;reasons cannot contain the pipe character (&amp;quot;|&amp;quot;)&#039;, 3)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Set protection date&lt;br /&gt;
	if args.date then&lt;br /&gt;
		obj.protectionDate = validateDate(args.date, &#039;protection date&#039;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Set banner config&lt;br /&gt;
	do&lt;br /&gt;
		obj.bannerConfig = {}&lt;br /&gt;
		local configTables = {}&lt;br /&gt;
		if cfg.banners[obj.action] then&lt;br /&gt;
			configTables[#configTables + 1] = cfg.banners[obj.action][obj.reason]&lt;br /&gt;
		end&lt;br /&gt;
		if cfg.defaultBanners[obj.action] then&lt;br /&gt;
			configTables[#configTables + 1] = cfg.defaultBanners[obj.action][obj.level]&lt;br /&gt;
			configTables[#configTables + 1] = cfg.defaultBanners[obj.action].default&lt;br /&gt;
		end&lt;br /&gt;
		configTables[#configTables + 1] = cfg.masterBanner&lt;br /&gt;
		for i, field in ipairs(Protection.bannerConfigFields) do&lt;br /&gt;
			for j, t in ipairs(configTables) do&lt;br /&gt;
				if t[field] then&lt;br /&gt;
					obj.bannerConfig[field] = t[field]&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return setmetatable(obj, Protection)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Protection:isUserScript()&lt;br /&gt;
	-- Whether the page is a user JavaScript or CSS page.&lt;br /&gt;
	local title = self.title&lt;br /&gt;
	return title.namespace == 2 and (&lt;br /&gt;
		title.contentModel == &#039;javascript&#039; or title.contentModel == &#039;css&#039;&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Protection:isProtected()&lt;br /&gt;
	return self.level ~= &#039;*&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Protection:shouldShowLock()&lt;br /&gt;
	-- Whether we should output a banner/padlock&lt;br /&gt;
	return self:isProtected() and not self:isUserScript()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Whether this page needs a protection category.&lt;br /&gt;
Protection.shouldHaveProtectionCategory = Protection.shouldShowLock&lt;br /&gt;
&lt;br /&gt;
function Protection:isTemporary()&lt;br /&gt;
	return type(self.expiry) == &#039;number&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Protection:makeProtectionCategory()&lt;br /&gt;
	if not self:shouldHaveProtectionCategory() then&lt;br /&gt;
		return &#039;&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local cfg = self._cfg&lt;br /&gt;
	local title = self.title&lt;br /&gt;
	&lt;br /&gt;
	-- Get the expiry key fragment.&lt;br /&gt;
	local expiryFragment&lt;br /&gt;
	if self.expiry == &#039;indef&#039; then&lt;br /&gt;
		expiryFragment = self.expiry&lt;br /&gt;
	elseif type(self.expiry) == &#039;number&#039; then&lt;br /&gt;
		expiryFragment = &#039;temp&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Get the namespace key fragment.&lt;br /&gt;
	local namespaceFragment = cfg.categoryNamespaceKeys[title.namespace]&lt;br /&gt;
	if not namespaceFragment and title.namespace % 2 == 1 then&lt;br /&gt;
			namespaceFragment = &#039;talk&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Define the order that key fragments are tested in. This is done with an&lt;br /&gt;
	-- array of tables containing the value to be tested, along with its&lt;br /&gt;
	-- position in the cfg.protectionCategories table.&lt;br /&gt;
	local order = {&lt;br /&gt;
		{val = expiryFragment,    keypos = 1},&lt;br /&gt;
		{val = namespaceFragment, keypos = 2},&lt;br /&gt;
		{val = self.reason,       keypos = 3},&lt;br /&gt;
		{val = self.level,        keypos = 4},&lt;br /&gt;
		{val = self.action,       keypos = 5}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	--[[&lt;br /&gt;
	-- The old protection templates used an ad-hoc protection category system,&lt;br /&gt;
	-- with some templates prioritising namespaces in their categories, and&lt;br /&gt;
	-- others prioritising the protection reason. To emulate this in this module&lt;br /&gt;
	-- we use the config table cfg.reasonsWithNamespacePriority to set the&lt;br /&gt;
	-- reasons for which namespaces have priority over protection reason.&lt;br /&gt;
	-- If we are dealing with one of those reasons, move the namespace table to&lt;br /&gt;
	-- the end of the order table, i.e. give it highest priority. If not, the&lt;br /&gt;
	-- reason should have highest priority, so move that to the end of the table&lt;br /&gt;
	-- instead.&lt;br /&gt;
	--]]&lt;br /&gt;
	table.insert(order, table.remove(order, self.reason and cfg.reasonsWithNamespacePriority[self.reason] and 2 or 3))&lt;br /&gt;
 &lt;br /&gt;
	--[[&lt;br /&gt;
	-- Define the attempt order. Inactive subtables (subtables with nil &amp;quot;value&amp;quot;&lt;br /&gt;
	-- fields) are moved to the end, where they will later be given the key&lt;br /&gt;
	-- &amp;quot;all&amp;quot;. This is to cut down on the number of table lookups in&lt;br /&gt;
	-- cfg.protectionCategories, which grows exponentially with the number of&lt;br /&gt;
	-- non-nil keys. We keep track of the number of active subtables with the&lt;br /&gt;
	-- noActive parameter.&lt;br /&gt;
	--]]&lt;br /&gt;
	local noActive, attemptOrder&lt;br /&gt;
	do&lt;br /&gt;
		local active, inactive = {}, {}&lt;br /&gt;
		for i, t in ipairs(order) do&lt;br /&gt;
			if t.val then&lt;br /&gt;
				active[#active + 1] = t&lt;br /&gt;
			else&lt;br /&gt;
				inactive[#inactive + 1] = t&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		noActive = #active&lt;br /&gt;
		attemptOrder = active&lt;br /&gt;
		for i, t in ipairs(inactive) do&lt;br /&gt;
			attemptOrder[#attemptOrder + 1] = t&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
 &lt;br /&gt;
	--[[&lt;br /&gt;
	-- Check increasingly generic key combinations until we find a match. If a&lt;br /&gt;
	-- specific category exists for the combination of key fragments we are&lt;br /&gt;
	-- given, that match will be found first. If not, we keep trying different&lt;br /&gt;
	-- key fragment combinations until we match using the key&lt;br /&gt;
	-- &amp;quot;all-all-all-all-all&amp;quot;.&lt;br /&gt;
	--&lt;br /&gt;
	-- To generate the keys, we index the key subtables using a binary matrix&lt;br /&gt;
	-- with indexes i and j. j is only calculated up to the number of active&lt;br /&gt;
	-- subtables. For example, if there were three active subtables, the matrix&lt;br /&gt;
	-- would look like this, with 0 corresponding to the key fragment &amp;quot;all&amp;quot;, and&lt;br /&gt;
	-- 1 corresponding to other key fragments.&lt;br /&gt;
	-- &lt;br /&gt;
	--   j 1  2  3&lt;br /&gt;
	-- i  &lt;br /&gt;
	-- 1   1  1  1&lt;br /&gt;
	-- 2   0  1  1&lt;br /&gt;
	-- 3   1  0  1&lt;br /&gt;
	-- 4   0  0  1&lt;br /&gt;
	-- 5   1  1  0&lt;br /&gt;
	-- 6   0  1  0&lt;br /&gt;
	-- 7   1  0  0&lt;br /&gt;
	-- 8   0  0  0&lt;br /&gt;
	-- &lt;br /&gt;
	-- Values of j higher than the number of active subtables are set&lt;br /&gt;
	-- to the string &amp;quot;all&amp;quot;.&lt;br /&gt;
	--&lt;br /&gt;
	-- A key for cfg.protectionCategories is constructed for each value of i.&lt;br /&gt;
	-- The position of the value in the key is determined by the keypos field in&lt;br /&gt;
	-- each subtable.&lt;br /&gt;
	--]]&lt;br /&gt;
	local cats = cfg.protectionCategories&lt;br /&gt;
	for i = 1, 2^noActive do&lt;br /&gt;
		local key = {}&lt;br /&gt;
		for j, t in ipairs(attemptOrder) do&lt;br /&gt;
			if j &amp;gt; noActive then&lt;br /&gt;
				key[t.keypos] = &#039;all&#039;&lt;br /&gt;
			else&lt;br /&gt;
				local quotient = i / 2 ^ (j - 1)&lt;br /&gt;
				quotient = math.ceil(quotient)&lt;br /&gt;
				if quotient % 2 == 1 then&lt;br /&gt;
					key[t.keypos] = t.val&lt;br /&gt;
				else&lt;br /&gt;
					key[t.keypos] = &#039;all&#039;&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		key = table.concat(key, &#039;|&#039;)&lt;br /&gt;
		local attempt = cats[key]&lt;br /&gt;
		if attempt then&lt;br /&gt;
			return makeCategoryLink(attempt, title.text)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return &#039;&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Protection:isIncorrect()&lt;br /&gt;
	local expiry = self.expiry&lt;br /&gt;
	return not self:shouldHaveProtectionCategory()&lt;br /&gt;
		or type(expiry) == &#039;number&#039; and expiry &amp;lt; os.time()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Protection:isTemplateProtectedNonTemplate()&lt;br /&gt;
	local action, namespace = self.action, self.title.namespace&lt;br /&gt;
	return self.level == &#039;templateeditor&#039;&lt;br /&gt;
		and (&lt;br /&gt;
			(action ~= &#039;edit&#039; and action ~= &#039;move&#039;)&lt;br /&gt;
			or (namespace ~= 10 and namespace ~= 828)&lt;br /&gt;
		)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Protection:makeCategoryLinks()&lt;br /&gt;
	local msg = self._cfg.msg&lt;br /&gt;
	local ret = {self:makeProtectionCategory()}&lt;br /&gt;
	if self:isIncorrect() then&lt;br /&gt;
		ret[#ret + 1] = makeCategoryLink(&lt;br /&gt;
			msg[&#039;tracking-category-incorrect&#039;],&lt;br /&gt;
			self.title.text&lt;br /&gt;
		)&lt;br /&gt;
	end&lt;br /&gt;
	if self:isTemplateProtectedNonTemplate() then&lt;br /&gt;
		ret[#ret + 1] = makeCategoryLink(&lt;br /&gt;
			msg[&#039;tracking-category-template&#039;],&lt;br /&gt;
			self.title.text&lt;br /&gt;
		)&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(ret)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Blurb class&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local Blurb = {}&lt;br /&gt;
Blurb.__index = Blurb&lt;br /&gt;
&lt;br /&gt;
Blurb.bannerTextFields = {&lt;br /&gt;
	text = true,&lt;br /&gt;
	explanation = true,&lt;br /&gt;
	tooltip = true,&lt;br /&gt;
	alt = true,&lt;br /&gt;
	link = true&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function Blurb.new(protectionObj, args, cfg)&lt;br /&gt;
	return setmetatable({&lt;br /&gt;
		_cfg = cfg,&lt;br /&gt;
		_protectionObj = protectionObj,&lt;br /&gt;
		_args = args&lt;br /&gt;
	}, Blurb)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Private methods --&lt;br /&gt;
&lt;br /&gt;
function Blurb:_formatDate(num)&lt;br /&gt;
	-- Formats a Unix timestamp into dd Month, YYYY format.&lt;br /&gt;
	lang = lang or mw.language.getContentLanguage()&lt;br /&gt;
	local success, date = pcall(&lt;br /&gt;
		lang.formatDate,&lt;br /&gt;
		lang,&lt;br /&gt;
		self._cfg.msg[&#039;expiry-date-format&#039;] or &#039;j F Y&#039;,&lt;br /&gt;
		&#039;@&#039; .. tostring(num)&lt;br /&gt;
	)&lt;br /&gt;
	if success then&lt;br /&gt;
		return date&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_getExpandedMessage(msgKey)&lt;br /&gt;
	return self:_substituteParameters(self._cfg.msg[msgKey])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_substituteParameters(msg)&lt;br /&gt;
	if not self._params then&lt;br /&gt;
		local parameterFuncs = {}&lt;br /&gt;
&lt;br /&gt;
		parameterFuncs.CURRENTVERSION     = self._makeCurrentVersionParameter&lt;br /&gt;
		parameterFuncs.EDITREQUEST        = self._makeEditRequestParameter&lt;br /&gt;
		parameterFuncs.EXPIRY             = self._makeExpiryParameter&lt;br /&gt;
		parameterFuncs.EXPLANATIONBLURB   = self._makeExplanationBlurbParameter&lt;br /&gt;
		parameterFuncs.IMAGELINK          = self._makeImageLinkParameter&lt;br /&gt;
		parameterFuncs.INTROBLURB         = self._makeIntroBlurbParameter&lt;br /&gt;
		parameterFuncs.INTROFRAGMENT      = self._makeIntroFragmentParameter&lt;br /&gt;
		parameterFuncs.PAGETYPE           = self._makePagetypeParameter&lt;br /&gt;
		parameterFuncs.PROTECTIONBLURB    = self._makeProtectionBlurbParameter&lt;br /&gt;
		parameterFuncs.PROTECTIONDATE     = self._makeProtectionDateParameter&lt;br /&gt;
		parameterFuncs.PROTECTIONLEVEL    = self._makeProtectionLevelParameter&lt;br /&gt;
		parameterFuncs.PROTECTIONLOG      = self._makeProtectionLogParameter&lt;br /&gt;
		parameterFuncs.TALKPAGE           = self._makeTalkPageParameter&lt;br /&gt;
		parameterFuncs.TOOLTIPBLURB       = self._makeTooltipBlurbParameter&lt;br /&gt;
		parameterFuncs.TOOLTIPFRAGMENT    = self._makeTooltipFragmentParameter&lt;br /&gt;
		parameterFuncs.VANDAL             = self._makeVandalTemplateParameter&lt;br /&gt;
		&lt;br /&gt;
		self._params = setmetatable({}, {&lt;br /&gt;
			__index = function (t, k)&lt;br /&gt;
				local param&lt;br /&gt;
				if parameterFuncs[k] then&lt;br /&gt;
					param = parameterFuncs[k](self)&lt;br /&gt;
				end&lt;br /&gt;
				param = param or &#039;&#039;&lt;br /&gt;
				t[k] = param&lt;br /&gt;
				return param&lt;br /&gt;
			end&lt;br /&gt;
		})&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	msg = msg:gsub(&#039;${(%u+)}&#039;, self._params)&lt;br /&gt;
	return msg&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeCurrentVersionParameter()&lt;br /&gt;
	-- A link to the page history or the move log, depending on the kind of&lt;br /&gt;
	-- protection.&lt;br /&gt;
	local pagename = self._protectionObj.title.prefixedText&lt;br /&gt;
	if self._protectionObj.action == &#039;move&#039; then&lt;br /&gt;
		-- We need the move log link.&lt;br /&gt;
		return makeFullUrl(&lt;br /&gt;
			&#039;Special:Log&#039;,&lt;br /&gt;
			{type = &#039;move&#039;, page = pagename},&lt;br /&gt;
			self:_getExpandedMessage(&#039;current-version-move-display&#039;)&lt;br /&gt;
		)&lt;br /&gt;
	else&lt;br /&gt;
		-- We need the history link.&lt;br /&gt;
		return makeFullUrl(&lt;br /&gt;
			pagename,&lt;br /&gt;
			{action = &#039;history&#039;},&lt;br /&gt;
			self:_getExpandedMessage(&#039;current-version-edit-display&#039;)&lt;br /&gt;
		)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeEditRequestParameter()&lt;br /&gt;
	local mEditRequest = require(&#039;Module:Submit an edit request&#039;)&lt;br /&gt;
	local action = self._protectionObj.action&lt;br /&gt;
	local level = self._protectionObj.level&lt;br /&gt;
	&lt;br /&gt;
	-- Get the edit request type.&lt;br /&gt;
	local requestType&lt;br /&gt;
	if action == &#039;edit&#039; then&lt;br /&gt;
		if level == &#039;autoconfirmed&#039; then&lt;br /&gt;
			requestType = &#039;semi&#039;&lt;br /&gt;
		elseif level == &#039;extendedconfirmed&#039; then&lt;br /&gt;
			requestType = &#039;extended&#039;&lt;br /&gt;
		elseif level == &#039;templateeditor&#039; then&lt;br /&gt;
			requestType = &#039;template&#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	requestType = requestType or &#039;full&#039;&lt;br /&gt;
	&lt;br /&gt;
	-- Get the display value.&lt;br /&gt;
	local display = self:_getExpandedMessage(&#039;edit-request-display&#039;)&lt;br /&gt;
&lt;br /&gt;
	return mEditRequest._link{type = requestType, display = display}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeExpiryParameter()&lt;br /&gt;
	local expiry = self._protectionObj.expiry&lt;br /&gt;
	if type(expiry) == &#039;number&#039; then&lt;br /&gt;
		return self:_formatDate(expiry)&lt;br /&gt;
	else&lt;br /&gt;
		return expiry&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeExplanationBlurbParameter()&lt;br /&gt;
	-- Cover special cases first.&lt;br /&gt;
	if self._protectionObj.title.namespace == 8 then&lt;br /&gt;
		-- MediaWiki namespace&lt;br /&gt;
		return self:_getExpandedMessage(&#039;explanation-blurb-nounprotect&#039;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Get explanation blurb table keys&lt;br /&gt;
	local action = self._protectionObj.action&lt;br /&gt;
	local level = self._protectionObj.level&lt;br /&gt;
	local talkKey = self._protectionObj.title.isTalkPage and &#039;talk&#039; or &#039;subject&#039;&lt;br /&gt;
&lt;br /&gt;
	-- Find the message in the explanation blurb table and substitute any&lt;br /&gt;
	-- parameters.&lt;br /&gt;
	local explanations = self._cfg.explanationBlurbs&lt;br /&gt;
	local msg&lt;br /&gt;
	if explanations[action][level] and explanations[action][level][talkKey] then&lt;br /&gt;
		msg = explanations[action][level][talkKey]&lt;br /&gt;
	elseif explanations[action][level] and explanations[action][level].default then&lt;br /&gt;
		msg = explanations[action][level].default&lt;br /&gt;
	elseif explanations[action].default and explanations[action].default[talkKey] then&lt;br /&gt;
		msg = explanations[action].default[talkKey]&lt;br /&gt;
	elseif explanations[action].default and explanations[action].default.default then&lt;br /&gt;
		msg = explanations[action].default.default&lt;br /&gt;
	else&lt;br /&gt;
		error(string.format(&lt;br /&gt;
			&#039;could not find explanation blurb for action &amp;quot;%s&amp;quot;, level &amp;quot;%s&amp;quot; and talk key &amp;quot;%s&amp;quot;&#039;,&lt;br /&gt;
			action,&lt;br /&gt;
			level,&lt;br /&gt;
			talkKey&lt;br /&gt;
		), 8)&lt;br /&gt;
	end&lt;br /&gt;
	return self:_substituteParameters(msg)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeImageLinkParameter()&lt;br /&gt;
	local imageLinks = self._cfg.imageLinks&lt;br /&gt;
	local action = self._protectionObj.action&lt;br /&gt;
	local level = self._protectionObj.level&lt;br /&gt;
	local msg&lt;br /&gt;
	if imageLinks[action][level] then&lt;br /&gt;
		msg = imageLinks[action][level]&lt;br /&gt;
	elseif imageLinks[action].default then&lt;br /&gt;
		msg = imageLinks[action].default&lt;br /&gt;
	else&lt;br /&gt;
		msg = imageLinks.edit.default&lt;br /&gt;
	end&lt;br /&gt;
	return self:_substituteParameters(msg)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeIntroBlurbParameter()&lt;br /&gt;
	if self._protectionObj:isTemporary() then&lt;br /&gt;
		return self:_getExpandedMessage(&#039;intro-blurb-expiry&#039;)&lt;br /&gt;
	else&lt;br /&gt;
		return self:_getExpandedMessage(&#039;intro-blurb-noexpiry&#039;)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeIntroFragmentParameter()&lt;br /&gt;
	if self._protectionObj:isTemporary() then&lt;br /&gt;
		return self:_getExpandedMessage(&#039;intro-fragment-expiry&#039;)&lt;br /&gt;
	else&lt;br /&gt;
		return self:_getExpandedMessage(&#039;intro-fragment-noexpiry&#039;)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makePagetypeParameter()&lt;br /&gt;
	local pagetypes = self._cfg.pagetypes&lt;br /&gt;
	return pagetypes[self._protectionObj.title.namespace]&lt;br /&gt;
		or pagetypes.default&lt;br /&gt;
		or error(&#039;no default pagetype defined&#039;, 8)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeProtectionBlurbParameter()&lt;br /&gt;
	local protectionBlurbs = self._cfg.protectionBlurbs&lt;br /&gt;
	local action = self._protectionObj.action&lt;br /&gt;
	local level = self._protectionObj.level&lt;br /&gt;
	local msg&lt;br /&gt;
	if protectionBlurbs[action][level] then&lt;br /&gt;
		msg = protectionBlurbs[action][level]&lt;br /&gt;
	elseif protectionBlurbs[action].default then&lt;br /&gt;
		msg = protectionBlurbs[action].default&lt;br /&gt;
	elseif protectionBlurbs.edit.default then&lt;br /&gt;
		msg = protectionBlurbs.edit.default&lt;br /&gt;
	else&lt;br /&gt;
		error(&#039;no protection blurb defined for protectionBlurbs.edit.default&#039;, 8)&lt;br /&gt;
	end&lt;br /&gt;
	return self:_substituteParameters(msg)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeProtectionDateParameter()&lt;br /&gt;
	local protectionDate = self._protectionObj.protectionDate&lt;br /&gt;
	if type(protectionDate) == &#039;number&#039; then&lt;br /&gt;
		return self:_formatDate(protectionDate)&lt;br /&gt;
	else&lt;br /&gt;
		return protectionDate&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeProtectionLevelParameter()&lt;br /&gt;
	local protectionLevels = self._cfg.protectionLevels&lt;br /&gt;
	local action = self._protectionObj.action&lt;br /&gt;
	local level = self._protectionObj.level&lt;br /&gt;
	local msg&lt;br /&gt;
	if protectionLevels[action][level] then&lt;br /&gt;
		msg = protectionLevels[action][level]&lt;br /&gt;
	elseif protectionLevels[action].default then&lt;br /&gt;
		msg = protectionLevels[action].default&lt;br /&gt;
	elseif protectionLevels.edit.default then&lt;br /&gt;
		msg = protectionLevels.edit.default&lt;br /&gt;
	else&lt;br /&gt;
		error(&#039;no protection level defined for protectionLevels.edit.default&#039;, 8)&lt;br /&gt;
	end&lt;br /&gt;
	return self:_substituteParameters(msg)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeProtectionLogParameter()&lt;br /&gt;
	local pagename = self._protectionObj.title.prefixedText&lt;br /&gt;
	if self._protectionObj.action == &#039;autoreview&#039; then&lt;br /&gt;
		-- We need the pending changes log.&lt;br /&gt;
		return makeFullUrl(&lt;br /&gt;
			&#039;Special:Log&#039;,&lt;br /&gt;
			{type = &#039;stable&#039;, page = pagename},&lt;br /&gt;
			self:_getExpandedMessage(&#039;pc-log-display&#039;)&lt;br /&gt;
		)&lt;br /&gt;
	else&lt;br /&gt;
		-- We need the protection log.&lt;br /&gt;
		return makeFullUrl(&lt;br /&gt;
			&#039;Special:Log&#039;,&lt;br /&gt;
			{type = &#039;protect&#039;, page = pagename},&lt;br /&gt;
			self:_getExpandedMessage(&#039;protection-log-display&#039;)&lt;br /&gt;
		)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeTalkPageParameter()&lt;br /&gt;
	return string.format(&lt;br /&gt;
		&#039;[[%s:%s#%s|%s]]&#039;,&lt;br /&gt;
		mw.site.namespaces[self._protectionObj.title.namespace].talk.name,&lt;br /&gt;
		self._protectionObj.title.text,&lt;br /&gt;
		self._args.section or &#039;top&#039;,&lt;br /&gt;
		self:_getExpandedMessage(&#039;talk-page-link-display&#039;)&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeTooltipBlurbParameter()&lt;br /&gt;
	if self._protectionObj:isTemporary() then&lt;br /&gt;
		return self:_getExpandedMessage(&#039;tooltip-blurb-expiry&#039;)&lt;br /&gt;
	else&lt;br /&gt;
		return self:_getExpandedMessage(&#039;tooltip-blurb-noexpiry&#039;)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeTooltipFragmentParameter()&lt;br /&gt;
	if self._protectionObj:isTemporary() then&lt;br /&gt;
		return self:_getExpandedMessage(&#039;tooltip-fragment-expiry&#039;)&lt;br /&gt;
	else&lt;br /&gt;
		return self:_getExpandedMessage(&#039;tooltip-fragment-noexpiry&#039;)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Blurb:_makeVandalTemplateParameter()&lt;br /&gt;
	return mw.getCurrentFrame():expandTemplate{&lt;br /&gt;
		title=&amp;quot;vandal-m&amp;quot;,&lt;br /&gt;
		args={self._args.user or self._protectionObj.title.baseText}&lt;br /&gt;
	}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Public methods --&lt;br /&gt;
&lt;br /&gt;
function Blurb:makeBannerText(key)&lt;br /&gt;
	-- Validate input.&lt;br /&gt;
	if not key or not Blurb.bannerTextFields[key] then&lt;br /&gt;
		error(string.format(&lt;br /&gt;
			&#039;&amp;quot;%s&amp;quot; is not a valid banner config field&#039;,&lt;br /&gt;
			tostring(key)&lt;br /&gt;
		), 2)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Generate the text.&lt;br /&gt;
	local msg = self._protectionObj.bannerConfig[key]&lt;br /&gt;
	if type(msg) == &#039;string&#039; then&lt;br /&gt;
		return self:_substituteParameters(msg)&lt;br /&gt;
	elseif type(msg) == &#039;function&#039; then&lt;br /&gt;
		msg = msg(self._protectionObj, self._args)&lt;br /&gt;
		if type(msg) ~= &#039;string&#039; then&lt;br /&gt;
			error(string.format(&lt;br /&gt;
				&#039;bad output from banner config function with key &amp;quot;%s&amp;quot;&#039;&lt;br /&gt;
					.. &#039; (expected string, got %s)&#039;,&lt;br /&gt;
				tostring(key),&lt;br /&gt;
				type(msg)&lt;br /&gt;
			), 4)&lt;br /&gt;
		end&lt;br /&gt;
		return self:_substituteParameters(msg)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- BannerTemplate class&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local BannerTemplate = {}&lt;br /&gt;
BannerTemplate.__index = BannerTemplate&lt;br /&gt;
&lt;br /&gt;
function BannerTemplate.new(protectionObj, cfg)&lt;br /&gt;
	local obj = {}&lt;br /&gt;
	obj._cfg = cfg&lt;br /&gt;
&lt;br /&gt;
	-- Set the image filename.&lt;br /&gt;
	local imageFilename = protectionObj.bannerConfig.image&lt;br /&gt;
	if imageFilename then&lt;br /&gt;
		obj._imageFilename = imageFilename&lt;br /&gt;
	else&lt;br /&gt;
		-- If an image filename isn&#039;t specified explicitly in the banner config,&lt;br /&gt;
		-- generate it from the protection status and the namespace.&lt;br /&gt;
		local action = protectionObj.action&lt;br /&gt;
		local level = protectionObj.level&lt;br /&gt;
		local namespace = protectionObj.title.namespace&lt;br /&gt;
		local reason = protectionObj.reason&lt;br /&gt;
		&lt;br /&gt;
		-- Deal with special cases first.&lt;br /&gt;
		if (&lt;br /&gt;
			namespace == 10&lt;br /&gt;
			or namespace == 828&lt;br /&gt;
			or reason and obj._cfg.indefImageReasons[reason]&lt;br /&gt;
			)&lt;br /&gt;
			and action == &#039;edit&#039;&lt;br /&gt;
			and level == &#039;sysop&#039;&lt;br /&gt;
			and not protectionObj:isTemporary()&lt;br /&gt;
		then&lt;br /&gt;
			-- Fully protected modules and templates get the special red &amp;quot;indef&amp;quot;&lt;br /&gt;
			-- padlock.&lt;br /&gt;
			obj._imageFilename = obj._cfg.msg[&#039;image-filename-indef&#039;]&lt;br /&gt;
		else&lt;br /&gt;
			-- Deal with regular protection types.&lt;br /&gt;
			local images = obj._cfg.images&lt;br /&gt;
			if images[action] then&lt;br /&gt;
				if images[action][level] then&lt;br /&gt;
					obj._imageFilename = images[action][level]&lt;br /&gt;
				elseif images[action].default then&lt;br /&gt;
					obj._imageFilename = images[action].default&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return setmetatable(obj, BannerTemplate)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function BannerTemplate:renderImage()&lt;br /&gt;
	local filename = self._imageFilename&lt;br /&gt;
		or self._cfg.msg[&#039;image-filename-default&#039;]&lt;br /&gt;
		or &#039;Transparent.gif&#039;&lt;br /&gt;
	return makeFileLink{&lt;br /&gt;
		file = filename,&lt;br /&gt;
		size = (self.imageWidth or 20) .. &#039;px&#039;,&lt;br /&gt;
		alt = self._imageAlt,&lt;br /&gt;
		link = self._imageLink,&lt;br /&gt;
		caption = self.imageCaption&lt;br /&gt;
	}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Banner class&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local Banner = setmetatable({}, BannerTemplate)&lt;br /&gt;
Banner.__index = Banner&lt;br /&gt;
&lt;br /&gt;
function Banner.new(protectionObj, blurbObj, cfg)&lt;br /&gt;
	local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn&#039;t need the blurb.&lt;br /&gt;
	obj.imageWidth = 40&lt;br /&gt;
	obj.imageCaption = blurbObj:makeBannerText(&#039;alt&#039;) -- Large banners use the alt text for the tooltip.&lt;br /&gt;
	obj._reasonText = blurbObj:makeBannerText(&#039;text&#039;)&lt;br /&gt;
	obj._explanationText = blurbObj:makeBannerText(&#039;explanation&#039;)&lt;br /&gt;
	obj._page = protectionObj.title.prefixedText -- Only makes a difference in testing.&lt;br /&gt;
	return setmetatable(obj, Banner)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Banner:__tostring()&lt;br /&gt;
	-- Renders the banner.&lt;br /&gt;
	makeMessageBox = makeMessageBox or require(&#039;Module:Message box&#039;).main&lt;br /&gt;
	local reasonText = self._reasonText or error(&#039;no reason text set&#039;, 2)&lt;br /&gt;
	local explanationText = self._explanationText&lt;br /&gt;
	local mbargs = {&lt;br /&gt;
		page = self._page,&lt;br /&gt;
		type = &#039;protection&#039;,&lt;br /&gt;
		image = self:renderImage(),&lt;br /&gt;
		text = string.format(&lt;br /&gt;
			&amp;quot;&#039;&#039;&#039;%s&#039;&#039;&#039;%s&amp;quot;,&lt;br /&gt;
			reasonText,&lt;br /&gt;
			explanationText and &#039;&amp;lt;br /&amp;gt;&#039; .. explanationText or &#039;&#039;&lt;br /&gt;
		)&lt;br /&gt;
	}&lt;br /&gt;
	return makeMessageBox(&#039;mbox&#039;, mbargs)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Padlock class&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local Padlock = setmetatable({}, BannerTemplate)&lt;br /&gt;
Padlock.__index = Padlock&lt;br /&gt;
&lt;br /&gt;
function Padlock.new(protectionObj, blurbObj, cfg)&lt;br /&gt;
	local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn&#039;t need the blurb.&lt;br /&gt;
	obj.imageWidth = 20&lt;br /&gt;
	obj.imageCaption = blurbObj:makeBannerText(&#039;tooltip&#039;)&lt;br /&gt;
	obj._imageAlt = blurbObj:makeBannerText(&#039;alt&#039;)&lt;br /&gt;
	obj._imageLink = blurbObj:makeBannerText(&#039;link&#039;)&lt;br /&gt;
	obj._indicatorName = cfg.padlockIndicatorNames[protectionObj.action]&lt;br /&gt;
		or cfg.padlockIndicatorNames.default&lt;br /&gt;
		or &#039;pp-default&#039;&lt;br /&gt;
	return setmetatable(obj, Padlock)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Padlock:__tostring()&lt;br /&gt;
	local frame = mw.getCurrentFrame()&lt;br /&gt;
	-- The nowiki tag helps prevent whitespace at the top of articles.&lt;br /&gt;
	return frame:extensionTag{name = &#039;nowiki&#039;} .. frame:extensionTag{&lt;br /&gt;
		name = &#039;indicator&#039;,&lt;br /&gt;
		args = {name = self._indicatorName},&lt;br /&gt;
		content = self:renderImage()&lt;br /&gt;
	}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Exports&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p._exportClasses()&lt;br /&gt;
	-- This is used for testing purposes.&lt;br /&gt;
	return {&lt;br /&gt;
		Protection = Protection,&lt;br /&gt;
		Blurb = Blurb,&lt;br /&gt;
		BannerTemplate = BannerTemplate,&lt;br /&gt;
		Banner = Banner,&lt;br /&gt;
		Padlock = Padlock,&lt;br /&gt;
	}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args, cfg, title)&lt;br /&gt;
	args = args or {}&lt;br /&gt;
	cfg = cfg or require(CONFIG_MODULE)&lt;br /&gt;
&lt;br /&gt;
	local protectionObj = Protection.new(args, cfg, title)&lt;br /&gt;
&lt;br /&gt;
	local ret = {}&lt;br /&gt;
&lt;br /&gt;
	-- If a page&#039;s edit protection is equally or more restrictive than its&lt;br /&gt;
	-- protection from some other action, then don&#039;t bother displaying anything&lt;br /&gt;
	-- for the other action (except categories).&lt;br /&gt;
	if protectionObj.action == &#039;edit&#039; or&lt;br /&gt;
		args.demolevel or&lt;br /&gt;
		not getReachableNodes(&lt;br /&gt;
			cfg.hierarchy,&lt;br /&gt;
			protectionObj.level&lt;br /&gt;
		)[effectiveProtectionLevel(&#039;edit&#039;, protectionObj.title)]&lt;br /&gt;
	then&lt;br /&gt;
		-- Initialise the blurb object&lt;br /&gt;
		local blurbObj = Blurb.new(protectionObj, args, cfg)&lt;br /&gt;
	&lt;br /&gt;
		-- Render the banner&lt;br /&gt;
		if protectionObj:shouldShowLock() then&lt;br /&gt;
			ret[#ret + 1] = tostring(&lt;br /&gt;
				(yesno(args.small) and Padlock or Banner)&lt;br /&gt;
				.new(protectionObj, blurbObj, cfg)&lt;br /&gt;
			)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Render the categories&lt;br /&gt;
	if yesno(args.category) ~= false then&lt;br /&gt;
		ret[#ret + 1] = protectionObj:makeCategoryLinks()&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return table.concat(ret)	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame, cfg)&lt;br /&gt;
	cfg = cfg or require(CONFIG_MODULE)&lt;br /&gt;
&lt;br /&gt;
	-- Find default args, if any.&lt;br /&gt;
	local parent = frame.getParent and frame:getParent()&lt;br /&gt;
	local defaultArgs = parent and cfg.wrappers[parent:getTitle():gsub(&#039;/sandbox$&#039;, &#039;&#039;)]&lt;br /&gt;
&lt;br /&gt;
	-- Find user args, and use the parent frame if we are being called from a&lt;br /&gt;
	-- wrapper template.&lt;br /&gt;
	getArgs = getArgs or require(&#039;Module:Arguments&#039;).getArgs&lt;br /&gt;
	local userArgs = getArgs(frame, {&lt;br /&gt;
		parentOnly = defaultArgs,&lt;br /&gt;
		frameOnly = not defaultArgs&lt;br /&gt;
	})&lt;br /&gt;
&lt;br /&gt;
	-- Build the args table. User-specified args overwrite default args.&lt;br /&gt;
	local args = {}&lt;br /&gt;
	for k, v in pairs(defaultArgs or {}) do&lt;br /&gt;
		args[k] = v&lt;br /&gt;
	end&lt;br /&gt;
	for k, v in pairs(userArgs) do&lt;br /&gt;
		args[k] = v&lt;br /&gt;
	end&lt;br /&gt;
	return p._main(args, cfg)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:No_globals&amp;diff=637</id>
		<title>Module:No globals</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:No_globals&amp;diff=637"/>
		<updated>2021-04-26T10:44:14Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local mt = getmetatable(_G) or {}&lt;br /&gt;
function mt.__index (t, k)&lt;br /&gt;
	if k ~= &#039;arg&#039; then&lt;br /&gt;
		error(&#039;Tried to read nil global &#039; .. tostring(k), 2)&lt;br /&gt;
	end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
function mt.__newindex(t, k, v)&lt;br /&gt;
	if k ~= &#039;arg&#039; then&lt;br /&gt;
		error(&#039;Tried to write global &#039; .. tostring(k), 2)&lt;br /&gt;
	end&lt;br /&gt;
	rawset(t, k, v)&lt;br /&gt;
end&lt;br /&gt;
setmetatable(_G, mt)&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Message_box/configuration&amp;diff=635</id>
		<title>Module:Message box/configuration</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Message_box/configuration&amp;diff=635"/>
		<updated>2021-04-26T10:44:14Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--------------------------------------------------------------------------------&lt;br /&gt;
--                          Message box configuration                         --&lt;br /&gt;
--                                                                            --&lt;br /&gt;
-- This module contains configuration data for [[Module:Message box]].        --&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
return {&lt;br /&gt;
	ambox = {&lt;br /&gt;
		types = {&lt;br /&gt;
			speedy = {&lt;br /&gt;
				class = &#039;ambox-speedy&#039;,&lt;br /&gt;
				image = &#039;Ambox warning pn.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			delete = {&lt;br /&gt;
				class = &#039;ambox-delete&#039;,&lt;br /&gt;
				image = &#039;Ambox warning pn.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			content = {&lt;br /&gt;
				class = &#039;ambox-content&#039;,&lt;br /&gt;
				image = &#039;Ambox important.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			style = {&lt;br /&gt;
				class = &#039;ambox-style&#039;,&lt;br /&gt;
				image = &#039;Edit-clear.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			move = {&lt;br /&gt;
				class = &#039;ambox-move&#039;,&lt;br /&gt;
				image = &#039;Merge-split-transwiki default.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			protection = {&lt;br /&gt;
				class = &#039;ambox-protection&#039;,&lt;br /&gt;
				image = &#039;Semi-protection-shackle-keyhole.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			notice = {&lt;br /&gt;
				class = &#039;ambox-notice&#039;,&lt;br /&gt;
				image = &#039;Information icon4.svg&#039;&lt;br /&gt;
			}&lt;br /&gt;
		},&lt;br /&gt;
		default                     = &#039;notice&#039;,&lt;br /&gt;
		allowBlankParams            = {&#039;talk&#039;, &#039;sect&#039;, &#039;date&#039;, &#039;issue&#039;, &#039;fix&#039;, &#039;subst&#039;, &#039;hidden&#039;},&lt;br /&gt;
		allowSmall                  = true,&lt;br /&gt;
		smallParam                  = &#039;left&#039;,&lt;br /&gt;
		smallClass                  = &#039;mbox-small-left&#039;,&lt;br /&gt;
		substCheck                  = true,&lt;br /&gt;
		classes                     = {&#039;metadata&#039;, &#039;ambox&#039;},&lt;br /&gt;
		imageEmptyCell              = true,&lt;br /&gt;
		imageCheckBlank             = true,&lt;br /&gt;
		imageSmallSize              = &#039;20x20px&#039;,&lt;br /&gt;
		imageCellDiv                = true,&lt;br /&gt;
		useCollapsibleTextFields    = true,&lt;br /&gt;
		imageRightNone              = true,&lt;br /&gt;
		sectionDefault              = &#039;article&#039;,&lt;br /&gt;
		allowMainspaceCategories    = true,&lt;br /&gt;
		templateCategory            = &#039;Article message templates&#039;,&lt;br /&gt;
	        templateCategoryRequireName = true,&lt;br /&gt;
		templateErrorCategory       = &#039;Article message templates with missing parameters&#039;,&lt;br /&gt;
		templateErrorParamsToCheck  = {&#039;issue&#039;, &#039;fix&#039;, &#039;subst&#039;},&lt;br /&gt;
		removalNotice               = &#039;[[Help:Maintenance template removal|Learn how and when to remove this template message]]&#039;&lt;br /&gt;
	},&lt;br /&gt;
	&lt;br /&gt;
	cmbox = {&lt;br /&gt;
		types = {&lt;br /&gt;
			speedy = {&lt;br /&gt;
				class = &#039;cmbox-speedy&#039;,&lt;br /&gt;
				image = &#039;Ambox warning pn.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			delete = {&lt;br /&gt;
				class = &#039;cmbox-delete&#039;,&lt;br /&gt;
				image = &#039;Ambox warning pn.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			content = {&lt;br /&gt;
				class = &#039;cmbox-content&#039;,&lt;br /&gt;
				image = &#039;Ambox important.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			style = {&lt;br /&gt;
				class = &#039;cmbox-style&#039;,&lt;br /&gt;
				image = &#039;Edit-clear.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			move = {&lt;br /&gt;
				class = &#039;cmbox-move&#039;,&lt;br /&gt;
				image = &#039;Merge-split-transwiki default.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			protection = {&lt;br /&gt;
				class = &#039;cmbox-protection&#039;,&lt;br /&gt;
				image = &#039;Semi-protection-shackle-keyhole.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			notice = {&lt;br /&gt;
				class = &#039;cmbox-notice&#039;,&lt;br /&gt;
				image = &#039;Information icon4.svg&#039;&lt;br /&gt;
			}&lt;br /&gt;
		},&lt;br /&gt;
		default              = &#039;notice&#039;,&lt;br /&gt;
		showInvalidTypeError = true,&lt;br /&gt;
		classes              = {&#039;cmbox&#039;},&lt;br /&gt;
		imageEmptyCell       = true&lt;br /&gt;
	},&lt;br /&gt;
	&lt;br /&gt;
	fmbox = {&lt;br /&gt;
		types = {&lt;br /&gt;
			warning = {&lt;br /&gt;
				class = &#039;fmbox-warning&#039;,&lt;br /&gt;
				image = &#039;Ambox warning pn.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			editnotice = {&lt;br /&gt;
				class = &#039;fmbox-editnotice&#039;,&lt;br /&gt;
				image = &#039;Information icon4.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			system = {&lt;br /&gt;
				class = &#039;fmbox-system&#039;,&lt;br /&gt;
				image = &#039;Information icon4.svg&#039;&lt;br /&gt;
			}&lt;br /&gt;
		},&lt;br /&gt;
		default              = &#039;system&#039;,&lt;br /&gt;
		showInvalidTypeError = true,&lt;br /&gt;
		classes              = {&#039;fmbox&#039;},&lt;br /&gt;
		imageEmptyCell       = false,&lt;br /&gt;
		imageRightNone       = false&lt;br /&gt;
	},&lt;br /&gt;
	&lt;br /&gt;
	imbox = {&lt;br /&gt;
		types = {&lt;br /&gt;
			speedy = {&lt;br /&gt;
				class = &#039;imbox-speedy&#039;,&lt;br /&gt;
				image = &#039;Ambox warning pn.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			delete = {&lt;br /&gt;
				class = &#039;imbox-delete&#039;,&lt;br /&gt;
				image = &#039;Ambox warning pn.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			content = {&lt;br /&gt;
				class = &#039;imbox-content&#039;,&lt;br /&gt;
				image = &#039;Ambox important.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			style = {&lt;br /&gt;
				class = &#039;imbox-style&#039;,&lt;br /&gt;
				image = &#039;Edit-clear.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			move = {&lt;br /&gt;
				class = &#039;imbox-move&#039;,&lt;br /&gt;
				image = &#039;Merge-split-transwiki default.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			protection = {&lt;br /&gt;
				class = &#039;imbox-protection&#039;,&lt;br /&gt;
				image = &#039;Semi-protection-shackle-keyhole.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			license = {&lt;br /&gt;
				class = &#039;imbox-license licensetpl&#039;,&lt;br /&gt;
				image = &#039;Imbox license.png&#039; -- @todo We need an SVG version of this&lt;br /&gt;
			},&lt;br /&gt;
			featured = {&lt;br /&gt;
				class = &#039;imbox-featured&#039;,&lt;br /&gt;
				image = &#039;Cscr-featured.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			notice = {&lt;br /&gt;
				class = &#039;imbox-notice&#039;,&lt;br /&gt;
				image = &#039;Information icon4.svg&#039;&lt;br /&gt;
			}&lt;br /&gt;
		},&lt;br /&gt;
		default              = &#039;notice&#039;,&lt;br /&gt;
		showInvalidTypeError = true,&lt;br /&gt;
		classes              = {&#039;imbox&#039;},&lt;br /&gt;
		imageEmptyCell       = true,&lt;br /&gt;
		below                = true,&lt;br /&gt;
		templateCategory     = &#039;File message boxes&#039;&lt;br /&gt;
	},&lt;br /&gt;
	&lt;br /&gt;
	ombox = {&lt;br /&gt;
		types = {&lt;br /&gt;
			speedy = {&lt;br /&gt;
				class = &#039;ombox-speedy&#039;,&lt;br /&gt;
				image = &#039;Ambox warning pn.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			delete = {&lt;br /&gt;
				class = &#039;ombox-delete&#039;,&lt;br /&gt;
				image = &#039;Ambox warning pn.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			content = {&lt;br /&gt;
				class = &#039;ombox-content&#039;,&lt;br /&gt;
				image = &#039;Ambox important.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			style = {&lt;br /&gt;
				class = &#039;ombox-style&#039;,&lt;br /&gt;
				image = &#039;Edit-clear.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			move = {&lt;br /&gt;
				class = &#039;ombox-move&#039;,&lt;br /&gt;
				image = &#039;Merge-split-transwiki default.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			protection = {&lt;br /&gt;
				class = &#039;ombox-protection&#039;,&lt;br /&gt;
				image = &#039;Semi-protection-shackle-keyhole.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			notice = {&lt;br /&gt;
				class = &#039;ombox-notice&#039;,&lt;br /&gt;
				image = &#039;Information icon4.svg&#039;&lt;br /&gt;
			}&lt;br /&gt;
		},&lt;br /&gt;
		default              = &#039;notice&#039;,&lt;br /&gt;
		showInvalidTypeError = true,&lt;br /&gt;
		classes              = {&#039;ombox&#039;},&lt;br /&gt;
		allowSmall           = true,&lt;br /&gt;
		imageEmptyCell       = true,&lt;br /&gt;
		imageRightNone       = true&lt;br /&gt;
	},&lt;br /&gt;
	&lt;br /&gt;
	tmbox = {&lt;br /&gt;
		types = {&lt;br /&gt;
			speedy = {&lt;br /&gt;
				class = &#039;tmbox-speedy&#039;,&lt;br /&gt;
				image = &#039;Ambox warning pn.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			delete = {&lt;br /&gt;
				class = &#039;tmbox-delete&#039;,&lt;br /&gt;
				image = &#039;Ambox warning pn.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			content = {&lt;br /&gt;
				class = &#039;tmbox-content&#039;,&lt;br /&gt;
				image = &#039;Ambox important.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			style = {&lt;br /&gt;
				class = &#039;tmbox-style&#039;,&lt;br /&gt;
				image = &#039;Edit-clear.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			move = {&lt;br /&gt;
				class = &#039;tmbox-move&#039;,&lt;br /&gt;
				image = &#039;Merge-split-transwiki default.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			protection = {&lt;br /&gt;
				class = &#039;tmbox-protection&#039;,&lt;br /&gt;
				image = &#039;Semi-protection-shackle-keyhole.svg&#039;&lt;br /&gt;
			},&lt;br /&gt;
			notice = {&lt;br /&gt;
				class = &#039;tmbox-notice&#039;,&lt;br /&gt;
				image = &#039;Information icon4.svg&#039;&lt;br /&gt;
			}&lt;br /&gt;
		},&lt;br /&gt;
		default              = &#039;notice&#039;,&lt;br /&gt;
		showInvalidTypeError = true,&lt;br /&gt;
		classes              = {&#039;tmbox&#039;},&lt;br /&gt;
		allowSmall           = true,&lt;br /&gt;
		imageRightNone       = true,&lt;br /&gt;
		imageEmptyCell       = true,&lt;br /&gt;
		imageEmptyCellStyle  = true,&lt;br /&gt;
		templateCategory     = &#039;Talk message boxes&#039;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Message_box&amp;diff=633</id>
		<title>Module:Message box</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Message_box&amp;diff=633"/>
		<updated>2021-04-26T10:44:13Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;-- This is a meta-module for producing message box templates, including&lt;br /&gt;
-- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}.&lt;br /&gt;
&lt;br /&gt;
-- Load necessary modules.&lt;br /&gt;
require(&#039;Module:No globals&#039;)&lt;br /&gt;
local getArgs&lt;br /&gt;
local yesno = require(&#039;Module:Yesno&#039;)&lt;br /&gt;
&lt;br /&gt;
-- Get a language object for formatDate and ucfirst.&lt;br /&gt;
local lang = mw.language.getContentLanguage()&lt;br /&gt;
&lt;br /&gt;
-- Define constants&lt;br /&gt;
local CONFIG_MODULE = &#039;Module:Message box/configuration&#039;&lt;br /&gt;
local DEMOSPACES = {talk = &#039;tmbox&#039;, image = &#039;imbox&#039;, file = &#039;imbox&#039;, category = &#039;cmbox&#039;, article = &#039;ambox&#039;, main = &#039;ambox&#039;}&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Helper functions&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local function getTitleObject(...)&lt;br /&gt;
	-- Get the title object, passing the function through pcall&lt;br /&gt;
	-- in case we are over the expensive function count limit.&lt;br /&gt;
	local success, title = pcall(mw.title.new, ...)&lt;br /&gt;
	if success then&lt;br /&gt;
		return title&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function union(t1, t2)&lt;br /&gt;
	-- Returns the union of two arrays.&lt;br /&gt;
	local vals = {}&lt;br /&gt;
	for i, v in ipairs(t1) do&lt;br /&gt;
		vals[v] = true&lt;br /&gt;
	end&lt;br /&gt;
	for i, v in ipairs(t2) do&lt;br /&gt;
		vals[v] = true&lt;br /&gt;
	end&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	for k in pairs(vals) do&lt;br /&gt;
		table.insert(ret, k)&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(ret)&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getArgNums(args, prefix)&lt;br /&gt;
	local nums = {}&lt;br /&gt;
	for k, v in pairs(args) do&lt;br /&gt;
		local num = mw.ustring.match(tostring(k), &#039;^&#039; .. prefix .. &#039;([1-9]%d*)$&#039;)&lt;br /&gt;
		if num then&lt;br /&gt;
			table.insert(nums, tonumber(num))&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(nums)&lt;br /&gt;
	return nums&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Box class definition&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local MessageBox = {}&lt;br /&gt;
MessageBox.__index = MessageBox&lt;br /&gt;
&lt;br /&gt;
function MessageBox.new(boxType, args, cfg)&lt;br /&gt;
	args = args or {}&lt;br /&gt;
	local obj = {}&lt;br /&gt;
&lt;br /&gt;
	-- Set the title object and the namespace.&lt;br /&gt;
	obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()&lt;br /&gt;
&lt;br /&gt;
	-- Set the config for our box type.&lt;br /&gt;
	obj.cfg = cfg[boxType]&lt;br /&gt;
	if not obj.cfg then&lt;br /&gt;
		local ns = obj.title.namespace&lt;br /&gt;
		-- boxType is &amp;quot;mbox&amp;quot; or invalid input&lt;br /&gt;
		if args.demospace and args.demospace ~= &#039;&#039; then&lt;br /&gt;
			-- implement demospace parameter of mbox&lt;br /&gt;
			local demospace = string.lower(args.demospace)&lt;br /&gt;
			if DEMOSPACES[demospace] then&lt;br /&gt;
				-- use template from DEMOSPACES&lt;br /&gt;
				obj.cfg = cfg[DEMOSPACES[demospace]]&lt;br /&gt;
			elseif string.find( demospace, &#039;talk&#039; ) then&lt;br /&gt;
				-- demo as a talk page&lt;br /&gt;
				obj.cfg = cfg.tmbox&lt;br /&gt;
			else&lt;br /&gt;
				-- default to ombox&lt;br /&gt;
				obj.cfg = cfg.ombox&lt;br /&gt;
			end&lt;br /&gt;
		elseif ns == 0 then&lt;br /&gt;
			obj.cfg = cfg.ambox -- main namespace&lt;br /&gt;
		elseif ns == 6 then&lt;br /&gt;
			obj.cfg = cfg.imbox -- file namespace&lt;br /&gt;
		elseif ns == 14 then&lt;br /&gt;
			obj.cfg = cfg.cmbox -- category namespace&lt;br /&gt;
		else&lt;br /&gt;
			local nsTable = mw.site.namespaces[ns]&lt;br /&gt;
			if nsTable and nsTable.isTalk then&lt;br /&gt;
				obj.cfg = cfg.tmbox -- any talk namespace&lt;br /&gt;
			else&lt;br /&gt;
				obj.cfg = cfg.ombox -- other namespaces or invalid input&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Set the arguments, and remove all blank arguments except for the ones&lt;br /&gt;
	-- listed in cfg.allowBlankParams.&lt;br /&gt;
	do&lt;br /&gt;
		local newArgs = {}&lt;br /&gt;
		for k, v in pairs(args) do&lt;br /&gt;
			if v ~= &#039;&#039; then&lt;br /&gt;
				newArgs[k] = v&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		for i, param in ipairs(obj.cfg.allowBlankParams or {}) do&lt;br /&gt;
			newArgs[param] = args[param]&lt;br /&gt;
		end&lt;br /&gt;
		obj.args = newArgs&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Define internal data structure.&lt;br /&gt;
	obj.categories = {}&lt;br /&gt;
	obj.classes = {}&lt;br /&gt;
	-- For lazy loading of [[Module:Category handler]].&lt;br /&gt;
	obj.hasCategories = false&lt;br /&gt;
&lt;br /&gt;
	return setmetatable(obj, MessageBox)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function MessageBox:addCat(ns, cat, sort)&lt;br /&gt;
	if not cat then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	if sort then&lt;br /&gt;
		cat = string.format(&#039;[[Category:%s|%s]]&#039;, cat, sort)&lt;br /&gt;
	else&lt;br /&gt;
		cat = string.format(&#039;[[Category:%s]]&#039;, cat)&lt;br /&gt;
	end&lt;br /&gt;
	self.hasCategories = true&lt;br /&gt;
	self.categories[ns] = self.categories[ns] or {}&lt;br /&gt;
	table.insert(self.categories[ns], cat)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function MessageBox:addClass(class)&lt;br /&gt;
	if not class then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	table.insert(self.classes, class)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function MessageBox:setParameters()&lt;br /&gt;
	local args = self.args&lt;br /&gt;
	local cfg = self.cfg&lt;br /&gt;
&lt;br /&gt;
	-- Get type data.&lt;br /&gt;
	self.type = args.type&lt;br /&gt;
	local typeData = cfg.types[self.type]&lt;br /&gt;
	self.invalidTypeError = cfg.showInvalidTypeError&lt;br /&gt;
		and self.type&lt;br /&gt;
		and not typeData&lt;br /&gt;
	typeData = typeData or cfg.types[cfg.default]&lt;br /&gt;
	self.typeClass = typeData.class&lt;br /&gt;
	self.typeImage = typeData.image&lt;br /&gt;
&lt;br /&gt;
	-- Find if the box has been wrongly substituted.&lt;br /&gt;
	self.isSubstituted = cfg.substCheck and args.subst == &#039;SUBST&#039;&lt;br /&gt;
&lt;br /&gt;
	-- Find whether we are using a small message box.&lt;br /&gt;
	self.isSmall = cfg.allowSmall and (&lt;br /&gt;
		cfg.smallParam and args.small == cfg.smallParam&lt;br /&gt;
		or not cfg.smallParam and yesno(args.small)&lt;br /&gt;
	)&lt;br /&gt;
&lt;br /&gt;
	-- Add attributes, classes and styles.&lt;br /&gt;
	self.id = args.id&lt;br /&gt;
	self.name = args.name&lt;br /&gt;
	if self.name then&lt;br /&gt;
		self:addClass(&#039;box-&#039; .. string.gsub(self.name,&#039; &#039;,&#039;_&#039;))&lt;br /&gt;
	end&lt;br /&gt;
	if yesno(args.plainlinks) ~= false then&lt;br /&gt;
		self:addClass(&#039;plainlinks&#039;)&lt;br /&gt;
	end&lt;br /&gt;
	for _, class in ipairs(cfg.classes or {}) do&lt;br /&gt;
		self:addClass(class)&lt;br /&gt;
	end&lt;br /&gt;
	if self.isSmall then&lt;br /&gt;
		self:addClass(cfg.smallClass or &#039;mbox-small&#039;)&lt;br /&gt;
	end&lt;br /&gt;
	self:addClass(self.typeClass)&lt;br /&gt;
	self:addClass(args.class)&lt;br /&gt;
	self.style = args.style&lt;br /&gt;
	self.attrs = args.attrs&lt;br /&gt;
&lt;br /&gt;
	-- Set text style.&lt;br /&gt;
	self.textstyle = args.textstyle&lt;br /&gt;
&lt;br /&gt;
	-- Find if we are on the template page or not. This functionality is only&lt;br /&gt;
	-- used if useCollapsibleTextFields is set, or if both cfg.templateCategory&lt;br /&gt;
	-- and cfg.templateCategoryRequireName are set.&lt;br /&gt;
	self.useCollapsibleTextFields = cfg.useCollapsibleTextFields&lt;br /&gt;
	if self.useCollapsibleTextFields&lt;br /&gt;
		or cfg.templateCategory&lt;br /&gt;
		and cfg.templateCategoryRequireName&lt;br /&gt;
	then&lt;br /&gt;
		if self.name then&lt;br /&gt;
			local templateName = mw.ustring.match(&lt;br /&gt;
				self.name,&lt;br /&gt;
				&#039;^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$&#039;&lt;br /&gt;
			) or self.name&lt;br /&gt;
			templateName = &#039;Template:&#039; .. templateName&lt;br /&gt;
			self.templateTitle = getTitleObject(templateName)&lt;br /&gt;
		end&lt;br /&gt;
		self.isTemplatePage = self.templateTitle&lt;br /&gt;
			and mw.title.equals(self.title, self.templateTitle)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Process data for collapsible text fields. At the moment these are only&lt;br /&gt;
	-- used in {{ambox}}.&lt;br /&gt;
	if self.useCollapsibleTextFields then&lt;br /&gt;
		-- Get the self.issue value.&lt;br /&gt;
		if self.isSmall and args.smalltext then&lt;br /&gt;
			self.issue = args.smalltext&lt;br /&gt;
		else&lt;br /&gt;
			local sect&lt;br /&gt;
			if args.sect == &#039;&#039; then&lt;br /&gt;
				sect = &#039;This &#039; .. (cfg.sectionDefault or &#039;page&#039;)&lt;br /&gt;
			elseif type(args.sect) == &#039;string&#039; then&lt;br /&gt;
				sect = &#039;This &#039; .. args.sect&lt;br /&gt;
			end&lt;br /&gt;
			local issue = args.issue&lt;br /&gt;
			issue = type(issue) == &#039;string&#039; and issue ~= &#039;&#039; and issue or nil&lt;br /&gt;
			local text = args.text&lt;br /&gt;
			text = type(text) == &#039;string&#039; and text or nil&lt;br /&gt;
			local issues = {}&lt;br /&gt;
			table.insert(issues, sect)&lt;br /&gt;
			table.insert(issues, issue)&lt;br /&gt;
			table.insert(issues, text)&lt;br /&gt;
			self.issue = table.concat(issues, &#039; &#039;)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- Get the self.talk value.&lt;br /&gt;
		local talk = args.talk&lt;br /&gt;
		-- Show talk links on the template page or template subpages if the talk&lt;br /&gt;
		-- parameter is blank.&lt;br /&gt;
		if talk == &#039;&#039;&lt;br /&gt;
			and self.templateTitle&lt;br /&gt;
			and (&lt;br /&gt;
				mw.title.equals(self.templateTitle, self.title)&lt;br /&gt;
				or self.title:isSubpageOf(self.templateTitle)&lt;br /&gt;
			)&lt;br /&gt;
		then&lt;br /&gt;
			talk = &#039;#&#039;&lt;br /&gt;
		elseif talk == &#039;&#039; then&lt;br /&gt;
			talk = nil&lt;br /&gt;
		end&lt;br /&gt;
		if talk then&lt;br /&gt;
			-- If the talk value is a talk page, make a link to that page. Else&lt;br /&gt;
			-- assume that it&#039;s a section heading, and make a link to the talk&lt;br /&gt;
			-- page of the current page with that section heading.&lt;br /&gt;
			local talkTitle = getTitleObject(talk)&lt;br /&gt;
			local talkArgIsTalkPage = true&lt;br /&gt;
			if not talkTitle or not talkTitle.isTalkPage then&lt;br /&gt;
				talkArgIsTalkPage = false&lt;br /&gt;
				talkTitle = getTitleObject(&lt;br /&gt;
					self.title.text,&lt;br /&gt;
					mw.site.namespaces[self.title.namespace].talk.id&lt;br /&gt;
				)&lt;br /&gt;
			end&lt;br /&gt;
			if talkTitle and talkTitle.exists then&lt;br /&gt;
                local talkText&lt;br /&gt;
                if self.isSmall then&lt;br /&gt;
                    local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. &#039;#&#039; .. talk)&lt;br /&gt;
                    talkText = string.format(&#039;([[%s|talk]])&#039;, talkLink)&lt;br /&gt;
                else&lt;br /&gt;
                    talkText = &#039;Relevant discussion may be found on&#039;&lt;br /&gt;
                    if talkArgIsTalkPage then&lt;br /&gt;
                        talkText = string.format(&lt;br /&gt;
                            &#039;%s [[%s|%s]].&#039;,&lt;br /&gt;
                            talkText,&lt;br /&gt;
                            talk,&lt;br /&gt;
                            talkTitle.prefixedText&lt;br /&gt;
                        )&lt;br /&gt;
                    else&lt;br /&gt;
                        talkText = string.format(&lt;br /&gt;
                            &#039;%s the [[%s#%s|talk page]].&#039;,&lt;br /&gt;
                            talkText,&lt;br /&gt;
                            talkTitle.prefixedText,&lt;br /&gt;
                            talk&lt;br /&gt;
                        )&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
				self.talk = talkText&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- Get other values.&lt;br /&gt;
		self.fix = args.fix ~= &#039;&#039; and args.fix or nil&lt;br /&gt;
		local date&lt;br /&gt;
		if args.date and args.date ~= &#039;&#039; then&lt;br /&gt;
			date = args.date&lt;br /&gt;
		elseif args.date == &#039;&#039; and self.isTemplatePage then&lt;br /&gt;
			date = lang:formatDate(&#039;F Y&#039;)&lt;br /&gt;
		end&lt;br /&gt;
		if date then&lt;br /&gt;
			self.date = string.format(&amp;quot; &amp;lt;small class=&#039;date-container&#039;&amp;gt;&#039;&#039;(&amp;lt;span class=&#039;date&#039;&amp;gt;%s&amp;lt;/span&amp;gt;)&#039;&#039;&amp;lt;/small&amp;gt;&amp;quot;, date)&lt;br /&gt;
		end&lt;br /&gt;
		self.info = args.info&lt;br /&gt;
		if yesno(args.removalnotice) then&lt;br /&gt;
			self.removalNotice = cfg.removalNotice&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Set the non-collapsible text field. At the moment this is used by all box&lt;br /&gt;
	-- types other than ambox, and also by ambox when small=yes.&lt;br /&gt;
	if self.isSmall then&lt;br /&gt;
		self.text = args.smalltext or args.text&lt;br /&gt;
	else&lt;br /&gt;
		self.text = args.text&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Set the below row.&lt;br /&gt;
	self.below = cfg.below and args.below&lt;br /&gt;
&lt;br /&gt;
	-- General image settings.&lt;br /&gt;
	self.imageCellDiv = not self.isSmall and cfg.imageCellDiv&lt;br /&gt;
	self.imageEmptyCell = cfg.imageEmptyCell&lt;br /&gt;
	if cfg.imageEmptyCellStyle then&lt;br /&gt;
		self.imageEmptyCellStyle = &#039;border:none;padding:0px;width:1px&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Left image settings.&lt;br /&gt;
	local imageLeft = self.isSmall and args.smallimage or args.image&lt;br /&gt;
	if cfg.imageCheckBlank and imageLeft ~= &#039;blank&#039; and imageLeft ~= &#039;none&#039;&lt;br /&gt;
		or not cfg.imageCheckBlank and imageLeft ~= &#039;none&#039;&lt;br /&gt;
	then&lt;br /&gt;
		self.imageLeft = imageLeft&lt;br /&gt;
		if not imageLeft then&lt;br /&gt;
			local imageSize = self.isSmall&lt;br /&gt;
				and (cfg.imageSmallSize or &#039;30x30px&#039;)&lt;br /&gt;
				or &#039;40x40px&#039;&lt;br /&gt;
			self.imageLeft = string.format(&#039;[[File:%s|%s|link=|alt=]]&#039;, self.typeImage&lt;br /&gt;
				or &#039;Imbox notice.png&#039;, imageSize)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Right image settings.&lt;br /&gt;
	local imageRight = self.isSmall and args.smallimageright or args.imageright&lt;br /&gt;
	if not (cfg.imageRightNone and imageRight == &#039;none&#039;) then&lt;br /&gt;
		self.imageRight = imageRight&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function MessageBox:setMainspaceCategories()&lt;br /&gt;
	local args = self.args&lt;br /&gt;
	local cfg = self.cfg&lt;br /&gt;
&lt;br /&gt;
	if not cfg.allowMainspaceCategories then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local nums = {}&lt;br /&gt;
	for _, prefix in ipairs{&#039;cat&#039;, &#039;category&#039;, &#039;all&#039;} do&lt;br /&gt;
		args[prefix .. &#039;1&#039;] = args[prefix]&lt;br /&gt;
		nums = union(nums, getArgNums(args, prefix))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- The following is roughly equivalent to the old {{Ambox/category}}.&lt;br /&gt;
	local date = args.date&lt;br /&gt;
	date = type(date) == &#039;string&#039; and date&lt;br /&gt;
	local preposition = &#039;from&#039;&lt;br /&gt;
	for _, num in ipairs(nums) do&lt;br /&gt;
		local mainCat = args[&#039;cat&#039; .. tostring(num)]&lt;br /&gt;
			or args[&#039;category&#039; .. tostring(num)]&lt;br /&gt;
		local allCat = args[&#039;all&#039; .. tostring(num)]&lt;br /&gt;
		mainCat = type(mainCat) == &#039;string&#039; and mainCat&lt;br /&gt;
		allCat = type(allCat) == &#039;string&#039; and allCat&lt;br /&gt;
		if mainCat and date and date ~= &#039;&#039; then&lt;br /&gt;
			local catTitle = string.format(&#039;%s %s %s&#039;, mainCat, preposition, date)&lt;br /&gt;
			self:addCat(0, catTitle)&lt;br /&gt;
			catTitle = getTitleObject(&#039;Category:&#039; .. catTitle)&lt;br /&gt;
			if not catTitle or not catTitle.exists then&lt;br /&gt;
				self:addCat(0, &#039;Articles with invalid date parameter in template&#039;)&lt;br /&gt;
			end&lt;br /&gt;
		elseif mainCat and (not date or date == &#039;&#039;) then&lt;br /&gt;
			self:addCat(0, mainCat)&lt;br /&gt;
		end&lt;br /&gt;
		if allCat then&lt;br /&gt;
			self:addCat(0, allCat)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function MessageBox:setTemplateCategories()&lt;br /&gt;
	local args = self.args&lt;br /&gt;
	local cfg = self.cfg&lt;br /&gt;
&lt;br /&gt;
	-- Add template categories.&lt;br /&gt;
	if cfg.templateCategory then&lt;br /&gt;
		if cfg.templateCategoryRequireName then&lt;br /&gt;
			if self.isTemplatePage then&lt;br /&gt;
				self:addCat(10, cfg.templateCategory)&lt;br /&gt;
			end&lt;br /&gt;
		elseif not self.title.isSubpage then&lt;br /&gt;
			self:addCat(10, cfg.templateCategory)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Add template error categories.&lt;br /&gt;
	if cfg.templateErrorCategory then&lt;br /&gt;
		local templateErrorCategory = cfg.templateErrorCategory&lt;br /&gt;
		local templateCat, templateSort&lt;br /&gt;
		if not self.name and not self.title.isSubpage then&lt;br /&gt;
			templateCat = templateErrorCategory&lt;br /&gt;
		elseif self.isTemplatePage then&lt;br /&gt;
			local paramsToCheck = cfg.templateErrorParamsToCheck or {}&lt;br /&gt;
			local count = 0&lt;br /&gt;
			for i, param in ipairs(paramsToCheck) do&lt;br /&gt;
				if not args[param] then&lt;br /&gt;
					count = count + 1&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if count &amp;gt; 0 then&lt;br /&gt;
				templateCat = templateErrorCategory&lt;br /&gt;
				templateSort = tostring(count)&lt;br /&gt;
			end&lt;br /&gt;
			if self.categoryNums and #self.categoryNums &amp;gt; 0 then&lt;br /&gt;
				templateCat = templateErrorCategory&lt;br /&gt;
				templateSort = &#039;C&#039;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		self:addCat(10, templateCat, templateSort)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function MessageBox:setAllNamespaceCategories()&lt;br /&gt;
	-- Set categories for all namespaces.&lt;br /&gt;
	if self.invalidTypeError then&lt;br /&gt;
		local allSort = (self.title.namespace == 0 and &#039;Main:&#039; or &#039;&#039;) .. self.title.prefixedText&lt;br /&gt;
		self:addCat(&#039;all&#039;, &#039;Wikipedia message box parameter needs fixing&#039;, allSort)&lt;br /&gt;
	end&lt;br /&gt;
	if self.isSubstituted then&lt;br /&gt;
		self:addCat(&#039;all&#039;, &#039;Pages with incorrectly substituted templates&#039;)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function MessageBox:setCategories()&lt;br /&gt;
	if self.title.namespace == 0 then&lt;br /&gt;
		self:setMainspaceCategories()&lt;br /&gt;
	elseif self.title.namespace == 10 then&lt;br /&gt;
		self:setTemplateCategories()&lt;br /&gt;
	end&lt;br /&gt;
	self:setAllNamespaceCategories()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function MessageBox:renderCategories()&lt;br /&gt;
	if not self.hasCategories then&lt;br /&gt;
		-- No categories added, no need to pass them to Category handler so,&lt;br /&gt;
		-- if it was invoked, it would return the empty string.&lt;br /&gt;
		-- So we shortcut and return the empty string.&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	-- Convert category tables to strings and pass them through&lt;br /&gt;
	-- [[Module:Category handler]].&lt;br /&gt;
	return require(&#039;Module:Category handler&#039;)._main{&lt;br /&gt;
		main = table.concat(self.categories[0] or {}),&lt;br /&gt;
		template = table.concat(self.categories[10] or {}),&lt;br /&gt;
		all = table.concat(self.categories.all or {}),&lt;br /&gt;
		nocat = self.args.nocat,&lt;br /&gt;
		page = self.args.page&lt;br /&gt;
	}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function MessageBox:export()&lt;br /&gt;
	local root = mw.html.create()&lt;br /&gt;
&lt;br /&gt;
	-- Add the subst check error.&lt;br /&gt;
	if self.isSubstituted and self.name then&lt;br /&gt;
		root:tag(&#039;b&#039;)&lt;br /&gt;
			:addClass(&#039;error&#039;)&lt;br /&gt;
			:wikitext(string.format(&lt;br /&gt;
				&#039;Template &amp;lt;code&amp;gt;%s[[Template:%s|%s]]%s&amp;lt;/code&amp;gt; has been incorrectly substituted.&#039;,&lt;br /&gt;
				mw.text.nowiki(&#039;{{&#039;), self.name, self.name, mw.text.nowiki(&#039;}}&#039;)&lt;br /&gt;
			))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Create the box table.&lt;br /&gt;
	local boxTable = root:tag(&#039;table&#039;)&lt;br /&gt;
	boxTable:attr(&#039;id&#039;, self.id or nil)&lt;br /&gt;
	for i, class in ipairs(self.classes or {}) do&lt;br /&gt;
		boxTable:addClass(class or nil)&lt;br /&gt;
	end&lt;br /&gt;
	boxTable&lt;br /&gt;
		:cssText(self.style or nil)&lt;br /&gt;
		:attr(&#039;role&#039;, &#039;presentation&#039;)&lt;br /&gt;
&lt;br /&gt;
	if self.attrs then&lt;br /&gt;
		boxTable:attr(self.attrs)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Add the left-hand image.&lt;br /&gt;
	local row = boxTable:tag(&#039;tr&#039;)&lt;br /&gt;
	if self.imageLeft then&lt;br /&gt;
		local imageLeftCell = row:tag(&#039;td&#039;):addClass(&#039;mbox-image&#039;)&lt;br /&gt;
		if self.imageCellDiv then&lt;br /&gt;
			-- If we are using a div, redefine imageLeftCell so that the image&lt;br /&gt;
			-- is inside it. Divs use style=&amp;quot;width: 52px;&amp;quot;, which limits the&lt;br /&gt;
			-- image width to 52px. If any images in a div are wider than that,&lt;br /&gt;
			-- they may overlap with the text or cause other display problems.&lt;br /&gt;
			imageLeftCell = imageLeftCell:tag(&#039;div&#039;):css(&#039;width&#039;, &#039;52px&#039;)&lt;br /&gt;
		end&lt;br /&gt;
		imageLeftCell:wikitext(self.imageLeft or nil)&lt;br /&gt;
	elseif self.imageEmptyCell then&lt;br /&gt;
		-- Some message boxes define an empty cell if no image is specified, and&lt;br /&gt;
		-- some don&#039;t. The old template code in templates where empty cells are&lt;br /&gt;
		-- specified gives the following hint: &amp;quot;No image. Cell with some width&lt;br /&gt;
		-- or padding necessary for text cell to have 100% width.&amp;quot;&lt;br /&gt;
		row:tag(&#039;td&#039;)&lt;br /&gt;
			:addClass(&#039;mbox-empty-cell&#039;)&lt;br /&gt;
			:cssText(self.imageEmptyCellStyle or nil)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Add the text.&lt;br /&gt;
	local textCell = row:tag(&#039;td&#039;):addClass(&#039;mbox-text&#039;)&lt;br /&gt;
	if self.useCollapsibleTextFields then&lt;br /&gt;
		-- The message box uses advanced text parameters that allow things to be&lt;br /&gt;
		-- collapsible. At the moment, only ambox uses this.&lt;br /&gt;
		textCell:cssText(self.textstyle or nil)&lt;br /&gt;
		local textCellDiv = textCell:tag(&#039;div&#039;)&lt;br /&gt;
		textCellDiv&lt;br /&gt;
			:addClass(&#039;mbox-text-span&#039;)&lt;br /&gt;
			:wikitext(self.issue or nil)&lt;br /&gt;
		if (self.talk or self.fix) then&lt;br /&gt;
			textCellDiv:tag(&#039;span&#039;)&lt;br /&gt;
				:addClass(&#039;hide-when-compact&#039;)&lt;br /&gt;
				:wikitext(self.talk and (&#039; &#039; .. self.talk) or nil)&lt;br /&gt;
				:wikitext(self.fix and (&#039; &#039; .. self.fix) or nil)&lt;br /&gt;
		end&lt;br /&gt;
		textCellDiv:wikitext(self.date and (&#039; &#039; .. self.date) or nil)&lt;br /&gt;
		if self.info and not self.isSmall then&lt;br /&gt;
			textCellDiv&lt;br /&gt;
				:tag(&#039;span&#039;)&lt;br /&gt;
				:addClass(&#039;hide-when-compact&#039;)&lt;br /&gt;
				:wikitext(self.info and (&#039; &#039; .. self.info) or nil)&lt;br /&gt;
		end&lt;br /&gt;
		if self.removalNotice then&lt;br /&gt;
			textCellDiv:tag(&#039;small&#039;)&lt;br /&gt;
				:addClass(&#039;hide-when-compact&#039;)&lt;br /&gt;
				:tag(&#039;i&#039;)&lt;br /&gt;
					:wikitext(string.format(&amp;quot; (%s)&amp;quot;, self.removalNotice))&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		-- Default text formatting - anything goes.&lt;br /&gt;
		textCell&lt;br /&gt;
			:cssText(self.textstyle or nil)&lt;br /&gt;
			:wikitext(self.text or nil)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Add the right-hand image.&lt;br /&gt;
	if self.imageRight then&lt;br /&gt;
		local imageRightCell = row:tag(&#039;td&#039;):addClass(&#039;mbox-imageright&#039;)&lt;br /&gt;
		if self.imageCellDiv then&lt;br /&gt;
			-- If we are using a div, redefine imageRightCell so that the image&lt;br /&gt;
			-- is inside it.&lt;br /&gt;
			imageRightCell = imageRightCell:tag(&#039;div&#039;):css(&#039;width&#039;, &#039;52px&#039;)&lt;br /&gt;
		end&lt;br /&gt;
		imageRightCell&lt;br /&gt;
			:wikitext(self.imageRight or nil)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Add the below row.&lt;br /&gt;
	if self.below then&lt;br /&gt;
		boxTable:tag(&#039;tr&#039;)&lt;br /&gt;
			:tag(&#039;td&#039;)&lt;br /&gt;
				:attr(&#039;colspan&#039;, self.imageRight and &#039;3&#039; or &#039;2&#039;)&lt;br /&gt;
				:addClass(&#039;mbox-text&#039;)&lt;br /&gt;
				:cssText(self.textstyle or nil)&lt;br /&gt;
				:wikitext(self.below or nil)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Add error message for invalid type parameters.&lt;br /&gt;
	if self.invalidTypeError then&lt;br /&gt;
		root:tag(&#039;div&#039;)&lt;br /&gt;
			:css(&#039;text-align&#039;, &#039;center&#039;)&lt;br /&gt;
			:wikitext(string.format(&lt;br /&gt;
				&#039;This message box is using an invalid &amp;quot;type=%s&amp;quot; parameter and needs fixing.&#039;,&lt;br /&gt;
				self.type or &#039;&#039;&lt;br /&gt;
			))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Add categories.&lt;br /&gt;
	root:wikitext(self:renderCategories() or nil)&lt;br /&gt;
&lt;br /&gt;
	return tostring(root)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Exports&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local p, mt = {}, {}&lt;br /&gt;
&lt;br /&gt;
function p._exportClasses()&lt;br /&gt;
	-- For testing.&lt;br /&gt;
	return {&lt;br /&gt;
		MessageBox = MessageBox&lt;br /&gt;
	}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(boxType, args, cfgTables)&lt;br /&gt;
	local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE))&lt;br /&gt;
	box:setParameters()&lt;br /&gt;
	box:setCategories()&lt;br /&gt;
	return box:export()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function mt.__index(t, k)&lt;br /&gt;
	return function (frame)&lt;br /&gt;
		if not getArgs then&lt;br /&gt;
			getArgs = require(&#039;Module:Arguments&#039;).getArgs&lt;br /&gt;
		end&lt;br /&gt;
		return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return setmetatable(p, mt)&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:List&amp;diff=631</id>
		<title>Module:List</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:List&amp;diff=631"/>
		<updated>2021-04-26T10:44:13Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;-- This module outputs different kinds of lists. At the moment, bulleted,&lt;br /&gt;
-- unbulleted, horizontal, ordered, and horizontal ordered lists are supported.&lt;br /&gt;
&lt;br /&gt;
local libUtil = require(&#039;libraryUtil&#039;)&lt;br /&gt;
local checkType = libUtil.checkType&lt;br /&gt;
local mTableTools = require(&#039;Module:TableTools&#039;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local listTypes = {&lt;br /&gt;
	[&#039;bulleted&#039;] = true,&lt;br /&gt;
	[&#039;unbulleted&#039;] = true,&lt;br /&gt;
	[&#039;horizontal&#039;] = true,&lt;br /&gt;
	[&#039;ordered&#039;] = true,&lt;br /&gt;
	[&#039;horizontal_ordered&#039;] = true&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function p.makeListData(listType, args)&lt;br /&gt;
	-- Constructs a data table to be passed to p.renderList.&lt;br /&gt;
	local data = {}&lt;br /&gt;
&lt;br /&gt;
	-- Classes&lt;br /&gt;
	data.classes = {}&lt;br /&gt;
	if listType == &#039;horizontal&#039; or listType == &#039;horizontal_ordered&#039; then&lt;br /&gt;
		table.insert(data.classes, &#039;hlist hlist-separated&#039;)&lt;br /&gt;
	elseif listType == &#039;unbulleted&#039; then&lt;br /&gt;
		table.insert(data.classes, &#039;plainlist&#039;)&lt;br /&gt;
	end&lt;br /&gt;
	table.insert(data.classes, args.class)&lt;br /&gt;
&lt;br /&gt;
	-- Main div style&lt;br /&gt;
	data.style = args.style&lt;br /&gt;
&lt;br /&gt;
	-- Indent for horizontal lists&lt;br /&gt;
	if listType == &#039;horizontal&#039; or listType == &#039;horizontal_ordered&#039; then&lt;br /&gt;
		local indent = tonumber(args.indent)&lt;br /&gt;
		indent = indent and indent * 1.6 or 0&lt;br /&gt;
		if indent &amp;gt; 0 then&lt;br /&gt;
			data.marginLeft = indent .. &#039;em&#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- List style types for ordered lists&lt;br /&gt;
	-- This could be &amp;quot;1, 2, 3&amp;quot;, &amp;quot;a, b, c&amp;quot;, or a number of others. The list style&lt;br /&gt;
	-- type is either set by the &amp;quot;type&amp;quot; attribute or the &amp;quot;list-style-type&amp;quot; CSS&lt;br /&gt;
	-- property.&lt;br /&gt;
	if listType == &#039;ordered&#039; or listType == &#039;horizontal_ordered&#039; then &lt;br /&gt;
		data.listStyleType = args.list_style_type or args[&#039;list-style-type&#039;]&lt;br /&gt;
		data.type = args[&#039;type&#039;]&lt;br /&gt;
&lt;br /&gt;
		-- Detect invalid type attributes and attempt to convert them to&lt;br /&gt;
		-- list-style-type CSS properties.&lt;br /&gt;
		if data.type &lt;br /&gt;
			and not data.listStyleType&lt;br /&gt;
			and not tostring(data.type):find(&#039;^%s*[1AaIi]%s*$&#039;)&lt;br /&gt;
		then&lt;br /&gt;
			data.listStyleType = data.type&lt;br /&gt;
			data.type = nil&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- List tag type&lt;br /&gt;
	if listType == &#039;ordered&#039; or listType == &#039;horizontal_ordered&#039; then&lt;br /&gt;
		data.listTag = &#039;ol&#039;&lt;br /&gt;
	else&lt;br /&gt;
		data.listTag = &#039;ul&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Start number for ordered lists&lt;br /&gt;
	data.start = args.start&lt;br /&gt;
	if listType == &#039;horizontal_ordered&#039; then&lt;br /&gt;
		-- Apply fix to get start numbers working with horizontal ordered lists.&lt;br /&gt;
		local startNum = tonumber(data.start)&lt;br /&gt;
		if startNum then&lt;br /&gt;
			data.counterReset = &#039;listitem &#039; .. tostring(startNum - 1)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- List style&lt;br /&gt;
	 -- ul_style and ol_style are included for backwards compatibility. No&lt;br /&gt;
	 -- distinction is made for ordered or unordered lists.&lt;br /&gt;
	data.listStyle = args.list_style&lt;br /&gt;
&lt;br /&gt;
	-- List items&lt;br /&gt;
	-- li_style is included for backwards compatibility. item_style was included&lt;br /&gt;
	-- to be easier to understand for non-coders.&lt;br /&gt;
	data.itemStyle = args.item_style or args.li_style&lt;br /&gt;
	data.items = {}&lt;br /&gt;
	for i, num in ipairs(mTableTools.numKeys(args)) do&lt;br /&gt;
		local item = {}&lt;br /&gt;
		item.content = args[num]&lt;br /&gt;
		item.style = args[&#039;item&#039; .. tostring(num) .. &#039;_style&#039;]&lt;br /&gt;
			or args[&#039;item_style&#039; .. tostring(num)]&lt;br /&gt;
		item.value = args[&#039;item&#039; .. tostring(num) .. &#039;_value&#039;]&lt;br /&gt;
			or args[&#039;item_value&#039; .. tostring(num)]&lt;br /&gt;
		table.insert(data.items, item)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return data&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.renderList(data)&lt;br /&gt;
	-- Renders the list HTML.&lt;br /&gt;
	&lt;br /&gt;
	-- Return the blank string if there are no list items.&lt;br /&gt;
	if type(data.items) ~= &#039;table&#039; or #data.items &amp;lt; 1 then&lt;br /&gt;
		return &#039;&#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Render the main div tag.&lt;br /&gt;
	local root = mw.html.create(&#039;div&#039;)&lt;br /&gt;
	for i, class in ipairs(data.classes or {}) do&lt;br /&gt;
		root:addClass(class)&lt;br /&gt;
	end&lt;br /&gt;
	root:css{[&#039;margin-left&#039;] = data.marginLeft}&lt;br /&gt;
	if data.style then&lt;br /&gt;
		root:cssText(data.style)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Render the list tag.&lt;br /&gt;
	local list = root:tag(data.listTag or &#039;ul&#039;)&lt;br /&gt;
	list&lt;br /&gt;
		:attr{start = data.start, type = data.type}&lt;br /&gt;
		:css{&lt;br /&gt;
			[&#039;counter-reset&#039;] = data.counterReset,&lt;br /&gt;
			[&#039;list-style-type&#039;] = data.listStyleType&lt;br /&gt;
		}&lt;br /&gt;
	if data.listStyle then&lt;br /&gt;
		list:cssText(data.listStyle)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Render the list items&lt;br /&gt;
	for i, t in ipairs(data.items or {}) do&lt;br /&gt;
		local item = list:tag(&#039;li&#039;)&lt;br /&gt;
		if data.itemStyle then&lt;br /&gt;
			item:cssText(data.itemStyle)&lt;br /&gt;
		end&lt;br /&gt;
		if t.style then&lt;br /&gt;
			item:cssText(t.style)&lt;br /&gt;
		end&lt;br /&gt;
		item&lt;br /&gt;
			:attr{value = t.value}&lt;br /&gt;
			:wikitext(t.content)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return tostring(root)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.renderTrackingCategories(args)&lt;br /&gt;
	local isDeprecated = false -- Tracks deprecated parameters.&lt;br /&gt;
	for k, v in pairs(args) do&lt;br /&gt;
		k = tostring(k)&lt;br /&gt;
		if k:find(&#039;^item_style%d+$&#039;) or k:find(&#039;^item_value%d+$&#039;) then&lt;br /&gt;
			isDeprecated = true&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local ret = &#039;&#039;&lt;br /&gt;
	if isDeprecated then&lt;br /&gt;
		ret = ret .. &#039;[[Category:List templates with deprecated parameters]]&#039;&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.makeList(listType, args)&lt;br /&gt;
	if not listType or not listTypes[listType] then&lt;br /&gt;
		error(string.format(&lt;br /&gt;
			&amp;quot;bad argument #1 to &#039;makeList&#039; (&#039;%s&#039; is not a valid list type)&amp;quot;,&lt;br /&gt;
			tostring(listType)&lt;br /&gt;
		), 2)&lt;br /&gt;
	end&lt;br /&gt;
	checkType(&#039;makeList&#039;, 2, args, &#039;table&#039;)&lt;br /&gt;
	local data = p.makeListData(listType, args)&lt;br /&gt;
	local list = p.renderList(data)&lt;br /&gt;
	local trackingCategories = p.renderTrackingCategories(args)&lt;br /&gt;
	return list .. trackingCategories&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
for listType in pairs(listTypes) do&lt;br /&gt;
	p[listType] = function (frame)&lt;br /&gt;
		local mArguments = require(&#039;Module:Arguments&#039;)&lt;br /&gt;
		local origArgs = mArguments.getArgs(frame, {&lt;br /&gt;
			valueFunc = function (key, value)&lt;br /&gt;
			if not value or not mw.ustring.find(value, &#039;%S&#039;) then return nil end&lt;br /&gt;
			if mw.ustring.find(value, &#039;^%s*[%*#;:]&#039;) then&lt;br /&gt;
				return value&lt;br /&gt;
			else&lt;br /&gt;
				return value:match(&#039;^%s*(.-)%s*$&#039;)&lt;br /&gt;
			end&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
		})&lt;br /&gt;
		-- Copy all the arguments to a new table, for faster indexing.&lt;br /&gt;
		local args = {}&lt;br /&gt;
		for k, v in pairs(origArgs) do&lt;br /&gt;
			args[k] = v&lt;br /&gt;
		end&lt;br /&gt;
		return p.makeList(listType, args)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:High-use&amp;diff=629</id>
		<title>Module:High-use</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:High-use&amp;diff=629"/>
		<updated>2021-04-26T10:44:13Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
-- _fetch looks at the &amp;quot;demo&amp;quot; argument.&lt;br /&gt;
local _fetch = require(&#039;Module:Transclusion_count&#039;).fetch&lt;br /&gt;
&lt;br /&gt;
function p.num(frame, count)&lt;br /&gt;
	if count == nil then count = _fetch(frame) end&lt;br /&gt;
	&lt;br /&gt;
	-- Build output string&lt;br /&gt;
	local return_value = &amp;quot;&amp;quot;&lt;br /&gt;
	if count == nil then&lt;br /&gt;
		if frame.args[1] == &amp;quot;risk&amp;quot; then&lt;br /&gt;
			return_value = &amp;quot;a very large number of&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			return_value = &amp;quot;many&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		-- Use 2 significant figures for smaller numbers and 3 for larger ones&lt;br /&gt;
		local sigfig = 2&lt;br /&gt;
		if count &amp;gt;= 100000 then&lt;br /&gt;
			sigfig = 3&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		-- Prepare to round to appropriate number of sigfigs&lt;br /&gt;
		local f = math.floor(math.log10(count)) - sigfig + 1&lt;br /&gt;
		&lt;br /&gt;
		-- Round and insert &amp;quot;approximately&amp;quot; or &amp;quot;+&amp;quot; when appropriate&lt;br /&gt;
		if (frame.args[2] == &amp;quot;yes&amp;quot;) or (mw.ustring.sub(frame.args[1],-1) == &amp;quot;+&amp;quot;) then&lt;br /&gt;
			-- Round down&lt;br /&gt;
			return_value = string.format(&amp;quot;%s+&amp;quot;, mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) ) * (10^(f))) )&lt;br /&gt;
		else&lt;br /&gt;
			-- Round to nearest&lt;br /&gt;
			return_value = string.format(&amp;quot;approximately&amp;amp;#x20;%s&amp;quot;, mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) + 0.5) * (10^(f))) )&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		-- Insert percentage of pages if that is likely to be &amp;gt;= 1%&lt;br /&gt;
		if count and count &amp;gt; 250000 then&lt;br /&gt;
			local percent = math.floor( ( (count/frame:callParserFunction(&#039;NUMBEROFPAGES&#039;, &#039;R&#039;) ) * 100) + 0.5)&lt;br /&gt;
			if percent &amp;gt;= 1 then&lt;br /&gt;
				return_value = string.format(&amp;quot;%s&amp;amp;#x20;pages, or roughly %s%% of all&amp;quot;, return_value, percent)&lt;br /&gt;
			end&lt;br /&gt;
		end	&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return return_value&lt;br /&gt;
end&lt;br /&gt;
-- Actions if there is a large (greater than or equal to 100,000) transclusion count&lt;br /&gt;
function p.risk(frame)&lt;br /&gt;
	local return_value = &amp;quot;&amp;quot;&lt;br /&gt;
	if frame.args[1] == &amp;quot;risk&amp;quot; then&lt;br /&gt;
		return_value = &amp;quot;risk&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		local count = _fetch(frame)&lt;br /&gt;
		if count and count &amp;gt;= 100000 then return_value = &amp;quot;risk&amp;quot; end&lt;br /&gt;
	end&lt;br /&gt;
	return return_value&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.text(frame, count)&lt;br /&gt;
	-- Only show the information about how this template gets updated if someone&lt;br /&gt;
	-- is actually editing the page and maybe trying to update the count.&lt;br /&gt;
	local bot_text = (frame:preprocess(&amp;quot;{{REVISIONID}}&amp;quot;) == &amp;quot;&amp;quot;) and &amp;quot;\n\n----\n&#039;&#039;&#039;Preview message&#039;&#039;&#039;: Transclusion count updated automatically ([[Template:High-use/doc#Technical details|see documentation]]).&amp;quot; or &#039;&#039;&lt;br /&gt;
	&lt;br /&gt;
	if count == nil then count = _fetch(frame) end&lt;br /&gt;
	local title = mw.title.getCurrentTitle()&lt;br /&gt;
	if title.subpageText == &amp;quot;doc&amp;quot; or title.subpageText == &amp;quot;sandbox&amp;quot; then&lt;br /&gt;
		title = title.basePageTitle&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local systemMessages = frame.args[&#039;system&#039;]&lt;br /&gt;
	if frame.args[&#039;system&#039;] == &#039;&#039; then&lt;br /&gt;
		systemMessages = nil&lt;br /&gt;
	end&lt;br /&gt;
		&lt;br /&gt;
	local templateCount = (&#039;on [https://templatecount.toolforge.org/index.php?lang=en&amp;amp;namespace=%s&amp;amp;name=%s %s pages]&#039;):format(&lt;br /&gt;
		mw.title.getCurrentTitle().namespace, mw.uri.encode(title.text), p.num(frame, count))&lt;br /&gt;
	local used_on_text = &amp;quot;&#039;&#039;&#039;This &amp;quot; .. (mw.title.getCurrentTitle().namespace == 828 and &amp;quot;Lua module&amp;quot; or &amp;quot;template&amp;quot;) .. &#039; is used &#039;;&lt;br /&gt;
	if systemMessages then&lt;br /&gt;
		used_on_text = used_on_text .. systemMessages ..&lt;br /&gt;
			((count and count &amp;gt; 2000) and (&amp;quot;,&#039;&#039;&#039; and &amp;quot; .. templateCount) or (&amp;quot;.&#039;&#039;&#039;&amp;quot;))&lt;br /&gt;
	else&lt;br /&gt;
		used_on_text = used_on_text .. templateCount .. &amp;quot;&#039;&#039;&#039;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	local sandbox_text =  (&amp;quot;%s&#039;s [[%s/sandbox|/sandbox]] or [[%s/testcases|/testcases]] subpages, or in your own [[%s]]. &amp;quot;):format(&lt;br /&gt;
		(mw.title.getCurrentTitle().namespace == 828 and &amp;quot;module&amp;quot; or &amp;quot;template&amp;quot;),&lt;br /&gt;
		title.fullText, title.fullText,&lt;br /&gt;
		mw.title.getCurrentTitle().namespace == 828 and &amp;quot;Module:Sandbox|module sandbox&amp;quot; or &amp;quot;Wikipedia:User pages#SUB|user subpage&amp;quot;&lt;br /&gt;
	)&lt;br /&gt;
	&lt;br /&gt;
	if (systemMessages or frame.args[1] == &amp;quot;risk&amp;quot; or (count and count &amp;gt;= 100000) ) then&lt;br /&gt;
		local info = systemMessages and &#039;&amp;lt;br/&amp;gt;Changes to it can cause immediate changes to the Wikipedia user interface.&#039; or &#039;&#039;&lt;br /&gt;
		if frame.args[&amp;quot;info&amp;quot;] and frame.args[&amp;quot;info&amp;quot;] ~= &amp;quot;&amp;quot; then&lt;br /&gt;
			info = info .. &amp;quot;&amp;lt;br /&amp;gt;&amp;quot; .. frame.args[&amp;quot;info&amp;quot;]&lt;br /&gt;
		end&lt;br /&gt;
		sandbox_text = info .. &#039;&amp;lt;br /&amp;gt; To avoid major disruption&#039; ..&lt;br /&gt;
			(count and count &amp;gt;= 100000 and &#039; and server load&#039; or &#039;&#039;) ..&lt;br /&gt;
			&#039;, any changes should be tested in the &#039; .. sandbox_text ..&lt;br /&gt;
			&#039;The tested changes can be added to this page in a single edit. &#039;&lt;br /&gt;
	else&lt;br /&gt;
		sandbox_text = &#039; and changes may be widely noticed. Test changes in the &#039; .. sandbox_text&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	local discussion_text = systemMessages and &#039;Please discuss changes &#039; or &#039;Consider discussing changes &#039;&lt;br /&gt;
	if frame.args[&amp;quot;2&amp;quot;] and frame.args[&amp;quot;2&amp;quot;] ~= &amp;quot;&amp;quot; and frame.args[&amp;quot;2&amp;quot;] ~= &amp;quot;yes&amp;quot; then&lt;br /&gt;
		discussion_text = string.format(&amp;quot;%sat [[%s]]&amp;quot;, discussion_text, frame.args[&amp;quot;2&amp;quot;])&lt;br /&gt;
	else&lt;br /&gt;
		discussion_text = string.format(&amp;quot;%son the [[%s|talk page]]&amp;quot;, discussion_text, title.talkPageTitle.fullText )&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return used_on_text .. sandbox_text .. discussion_text .. &amp;quot; before implementing them.&amp;quot; .. bot_text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local count = _fetch(frame)&lt;br /&gt;
	local image = &amp;quot;[[File:Ambox warning yellow.svg|40px|alt=Warning|link=]]&amp;quot;&lt;br /&gt;
	local type_param = &amp;quot;style&amp;quot;&lt;br /&gt;
	local epilogue = &#039;&#039;&lt;br /&gt;
	if frame.args[&#039;system&#039;] and frame.args[&#039;system&#039;] ~= &#039;&#039; then&lt;br /&gt;
		image = &amp;quot;[[File:Ambox important.svg|40px|alt=Warning|link=]]&amp;quot;&lt;br /&gt;
		type_param = &amp;quot;content&amp;quot;&lt;br /&gt;
		local nocat = frame:getParent().args[&#039;nocat&#039;] or frame.args[&#039;nocat&#039;]&lt;br /&gt;
		local categorise = (nocat == &#039;&#039; or not require(&#039;Module:Yesno&#039;)(nocat))&lt;br /&gt;
		if categorise then&lt;br /&gt;
			epilogue = frame:preprocess(&#039;{{Sandbox other||{{#switch:{{#invoke:Effective protection level|{{#switch:{{NAMESPACE}}|File=upload|#default=edit}}|{{FULLPAGENAME}}}}|sysop|templateeditor|interfaceadmin=|#default=[[Category:Pages used in system messages needing protection]]}}}}&#039;)&lt;br /&gt;
		end&lt;br /&gt;
	elseif (frame.args[1] == &amp;quot;risk&amp;quot; or (count and count &amp;gt;= 100000)) then&lt;br /&gt;
		image = &amp;quot;[[File:Ambox warning orange.svg|40px|alt=Warning|link=]]&amp;quot;&lt;br /&gt;
		type_param = &amp;quot;content&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if frame.args[&amp;quot;form&amp;quot;] == &amp;quot;editnotice&amp;quot; then&lt;br /&gt;
		return frame:expandTemplate{&lt;br /&gt;
				title = &#039;editnotice&#039;,&lt;br /&gt;
				args = {&lt;br /&gt;
						[&amp;quot;image&amp;quot;] = image,&lt;br /&gt;
						[&amp;quot;text&amp;quot;] = p.text(frame, count),&lt;br /&gt;
						[&amp;quot;expiry&amp;quot;] = (frame.args[&amp;quot;expiry&amp;quot;] or &amp;quot;&amp;quot;)&lt;br /&gt;
				}&lt;br /&gt;
		} .. epilogue&lt;br /&gt;
	else&lt;br /&gt;
		return require(&#039;Module:Message box&#039;).main(&#039;ombox&#039;, {&lt;br /&gt;
			type = type_param,&lt;br /&gt;
			image = image,&lt;br /&gt;
			text = p.text(frame, count),&lt;br /&gt;
			expiry = (frame.args[&amp;quot;expiry&amp;quot;] or &amp;quot;&amp;quot;)&lt;br /&gt;
		}) .. epilogue&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:File_link&amp;diff=627</id>
		<title>Module:File link</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:File_link&amp;diff=627"/>
		<updated>2021-04-26T10:44:12Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;-- This module provides a library for formatting file wikilinks.&lt;br /&gt;
&lt;br /&gt;
local yesno = require(&#039;Module:Yesno&#039;)&lt;br /&gt;
local checkType = require(&#039;libraryUtil&#039;).checkType&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p._main(args)&lt;br /&gt;
	checkType(&#039;_main&#039;, 1, args, &#039;table&#039;)&lt;br /&gt;
&lt;br /&gt;
	-- This is basically libraryUtil.checkTypeForNamedArg, but we are rolling our&lt;br /&gt;
	-- own function to get the right error level.&lt;br /&gt;
	local function checkArg(key, val, level)&lt;br /&gt;
		if type(val) ~= &#039;string&#039; then&lt;br /&gt;
			error(string.format(&lt;br /&gt;
				&amp;quot;type error in &#039;%s&#039; parameter of &#039;_main&#039; (expected string, got %s)&amp;quot;,&lt;br /&gt;
				key, type(val)&lt;br /&gt;
			), level)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local ret = {}&lt;br /&gt;
&lt;br /&gt;
	-- Adds a positional parameter to the buffer.&lt;br /&gt;
	local function addPositional(key)&lt;br /&gt;
		local val = args[key]&lt;br /&gt;
		if not val then&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
		checkArg(key, val, 4)&lt;br /&gt;
		ret[#ret + 1] = val&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Adds a named parameter to the buffer. We assume that the parameter name&lt;br /&gt;
	-- is the same as the argument key.&lt;br /&gt;
	local function addNamed(key)&lt;br /&gt;
		local val = args[key]&lt;br /&gt;
		if not val then&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
		checkArg(key, val, 4)&lt;br /&gt;
		ret[#ret + 1] = key .. &#039;=&#039; .. val&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Filename&lt;br /&gt;
	checkArg(&#039;file&#039;, args.file, 3)&lt;br /&gt;
	ret[#ret + 1] = &#039;File:&#039; .. args.file&lt;br /&gt;
&lt;br /&gt;
	-- Format&lt;br /&gt;
	if args.format then&lt;br /&gt;
		checkArg(&#039;format&#039;, args.format)&lt;br /&gt;
		if args.formatfile then&lt;br /&gt;
			checkArg(&#039;formatfile&#039;, args.formatfile)&lt;br /&gt;
			ret[#ret + 1] = args.format .. &#039;=&#039; .. args.formatfile&lt;br /&gt;
		else&lt;br /&gt;
			ret[#ret + 1] = args.format&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Border&lt;br /&gt;
	if yesno(args.border) then&lt;br /&gt;
		ret[#ret + 1] = &#039;border&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	addPositional(&#039;location&#039;)&lt;br /&gt;
	addPositional(&#039;alignment&#039;)&lt;br /&gt;
	addPositional(&#039;size&#039;)&lt;br /&gt;
	addNamed(&#039;upright&#039;)&lt;br /&gt;
	addNamed(&#039;link&#039;)&lt;br /&gt;
	addNamed(&#039;alt&#039;)&lt;br /&gt;
	addNamed(&#039;page&#039;)&lt;br /&gt;
	addNamed(&#039;class&#039;)&lt;br /&gt;
	addNamed(&#039;lang&#039;)&lt;br /&gt;
	addNamed(&#039;start&#039;)&lt;br /&gt;
	addNamed(&#039;end&#039;)&lt;br /&gt;
	addNamed(&#039;thumbtime&#039;)&lt;br /&gt;
	addPositional(&#039;caption&#039;)&lt;br /&gt;
&lt;br /&gt;
	return string.format(&#039;[[%s]]&#039;, table.concat(ret, &#039;|&#039;))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local origArgs = require(&#039;Module:Arguments&#039;).getArgs(frame, {&lt;br /&gt;
		wrappers = &#039;Template:File link&#039;&lt;br /&gt;
	})&lt;br /&gt;
	if not origArgs.file then&lt;br /&gt;
		error(&amp;quot;&#039;file&#039; parameter missing from [[Template:File link]]&amp;quot;, 0)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Copy the arguments that were passed to a new table to avoid looking up&lt;br /&gt;
	-- every possible parameter in the frame object.&lt;br /&gt;
	local args = {}&lt;br /&gt;
	for k, v in pairs(origArgs) do&lt;br /&gt;
		-- Make _BLANK a special argument to add a blank parameter. For use in&lt;br /&gt;
		-- conditional templates etc. it is useful for blank arguments to be&lt;br /&gt;
		-- ignored, but we still need a way to specify them so that we can do&lt;br /&gt;
		-- things like [[File:Example.png|link=]].&lt;br /&gt;
		if v == &#039;_BLANK&#039; then&lt;br /&gt;
			v = &#039;&#039;&lt;br /&gt;
		end&lt;br /&gt;
		args[k] = v&lt;br /&gt;
	end&lt;br /&gt;
	return p._main(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Effective_protection_level&amp;diff=625</id>
		<title>Module:Effective protection level</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Effective_protection_level&amp;diff=625"/>
		<updated>2021-04-26T10:44:11Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
-- Returns the permission required to perform a given action on a given title.&lt;br /&gt;
-- If no title is specified, the title of the page being displayed is used.&lt;br /&gt;
function p._main(action, pagename)&lt;br /&gt;
	local title&lt;br /&gt;
	if type(pagename) == &#039;table&#039; and pagename.prefixedText then&lt;br /&gt;
		title = pagename&lt;br /&gt;
	elseif pagename then&lt;br /&gt;
		title = mw.title.new(pagename)&lt;br /&gt;
	else&lt;br /&gt;
		title = mw.title.getCurrentTitle()&lt;br /&gt;
	end&lt;br /&gt;
	pagename = title.prefixedText&lt;br /&gt;
	if action == &#039;autoreview&#039; then&lt;br /&gt;
		local level = mw.ext.FlaggedRevs.getStabilitySettings(title)&lt;br /&gt;
		level = level and level.autoreview&lt;br /&gt;
		if level == &#039;review&#039; then&lt;br /&gt;
			return &#039;reviewer&#039;&lt;br /&gt;
		elseif level ~= &#039;&#039; then&lt;br /&gt;
			return level&lt;br /&gt;
		else&lt;br /&gt;
			return nil -- not &#039;*&#039;. a page not being PC-protected is distinct from it being PC-protected with anyone able to review. also not &#039;&#039;, as that would mean PC-protected but nobody can review&lt;br /&gt;
		end&lt;br /&gt;
	elseif action ~= &#039;edit&#039; and action ~= &#039;move&#039; and action ~= &#039;create&#039; and action ~= &#039;upload&#039; and action ~= &#039;undelete&#039; then&lt;br /&gt;
		error( &#039;First parameter must be one of edit, move, create, upload, undelete, autoreview&#039;, 2 )&lt;br /&gt;
	end&lt;br /&gt;
	if title.namespace == 8 then -- MediaWiki namespace&lt;br /&gt;
		if title.text:sub(-3) == &#039;.js&#039; or title.text:sub(-4) == &#039;.css&#039; or title.contentModel == &#039;javascript&#039; or title.contentModel == &#039;css&#039; then -- site JS or CSS page&lt;br /&gt;
			return &#039;interfaceadmin&#039;&lt;br /&gt;
		else -- any non-JS/CSS MediaWiki page&lt;br /&gt;
			return &#039;sysop&#039;&lt;br /&gt;
		end&lt;br /&gt;
	elseif title.namespace == 2 and title.isSubpage then&lt;br /&gt;
		if title.contentModel == &#039;javascript&#039; or title.contentModel == &#039;css&#039; then -- user JS or CSS page&lt;br /&gt;
			return &#039;interfaceadmin&#039;&lt;br /&gt;
		elseif title.contentModel == &#039;json&#039; then -- user JSON page&lt;br /&gt;
			return &#039;sysop&#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if action == &#039;undelete&#039; then&lt;br /&gt;
		return &#039;sysop&#039;&lt;br /&gt;
	end&lt;br /&gt;
	local level = title.protectionLevels[action] and title.protectionLevels[action][1]&lt;br /&gt;
	if level == &#039;sysop&#039; or level == &#039;editprotected&#039; then&lt;br /&gt;
		return &#039;sysop&#039;&lt;br /&gt;
	elseif title.cascadingProtection.restrictions[action] and title.cascadingProtection.restrictions[action][1] then -- used by a cascading-protected page&lt;br /&gt;
		return &#039;sysop&#039;&lt;br /&gt;
	elseif level == &#039;templateeditor&#039; then&lt;br /&gt;
		return &#039;templateeditor&#039;&lt;br /&gt;
	elseif action == &#039;move&#039; then&lt;br /&gt;
		local blacklistentry = mw.ext.TitleBlacklist.test(&#039;edit&#039;, pagename) -- Testing action edit is correct, since this is for the source page. The target page name gets tested with action move.&lt;br /&gt;
		if blacklistentry and not blacklistentry.params.autoconfirmed then&lt;br /&gt;
			return &#039;templateeditor&#039;&lt;br /&gt;
		elseif title.namespace == 6 then&lt;br /&gt;
			return &#039;filemover&#039;&lt;br /&gt;
		elseif level == &#039;extendedconfirmed&#039; then&lt;br /&gt;
			return &#039;extendedconfirmed&#039;&lt;br /&gt;
		else&lt;br /&gt;
			return &#039;autoconfirmed&#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local blacklistentry = mw.ext.TitleBlacklist.test(action, pagename)&lt;br /&gt;
	if blacklistentry then&lt;br /&gt;
		if not blacklistentry.params.autoconfirmed then&lt;br /&gt;
			return &#039;templateeditor&#039;&lt;br /&gt;
		elseif level == &#039;extendedconfirmed&#039; then&lt;br /&gt;
			return &#039;extendedconfirmed&#039;&lt;br /&gt;
		else&lt;br /&gt;
			return &#039;autoconfirmed&#039;&lt;br /&gt;
		end&lt;br /&gt;
	elseif level == &#039;editsemiprotected&#039; then -- create-semiprotected pages return this for some reason&lt;br /&gt;
		return &#039;autoconfirmed&#039;&lt;br /&gt;
	elseif level then&lt;br /&gt;
		return level&lt;br /&gt;
	elseif action == &#039;upload&#039; then&lt;br /&gt;
		return &#039;autoconfirmed&#039;&lt;br /&gt;
	elseif action == &#039;create&#039; and title.namespace % 2 == 0 and title.namespace ~= 118 then -- You need to be registered, but not autoconfirmed, to create non-talk pages other than drafts&lt;br /&gt;
		return &#039;user&#039;&lt;br /&gt;
	else&lt;br /&gt;
		return &#039;*&#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
setmetatable(p, { __index = function(t, k)&lt;br /&gt;
	return function(frame)&lt;br /&gt;
		return t._main(k, frame.args[1])&lt;br /&gt;
	end&lt;br /&gt;
end })&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Effective_protection_expiry&amp;diff=623</id>
		<title>Module:Effective protection expiry</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Effective_protection_expiry&amp;diff=623"/>
		<updated>2021-04-26T10:44:10Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
-- Returns the expiry of a restriction of an action on a given title, or unknown if it cannot be known.&lt;br /&gt;
-- If no title is specified, the title of the page being displayed is used.&lt;br /&gt;
function p._main(action, pagename)&lt;br /&gt;
	local title&lt;br /&gt;
	if type(pagename) == &#039;table&#039; and pagename.prefixedText then&lt;br /&gt;
		title = pagename&lt;br /&gt;
	elseif pagename then&lt;br /&gt;
		title = mw.title.new(pagename)&lt;br /&gt;
	else&lt;br /&gt;
		title = mw.title.getCurrentTitle()&lt;br /&gt;
	end&lt;br /&gt;
	pagename = title.prefixedText&lt;br /&gt;
	if action == &#039;autoreview&#039; then&lt;br /&gt;
		local stabilitySettings = mw.ext.FlaggedRevs.getStabilitySettings(title)&lt;br /&gt;
		return stabilitySettings and stabilitySettings.expiry or &#039;unknown&#039;&lt;br /&gt;
	elseif action ~= &#039;edit&#039; and action ~= &#039;move&#039; and action ~= &#039;create&#039; and action ~= &#039;upload&#039; then&lt;br /&gt;
		error( &#039;First parameter must be one of edit, move, create, upload, autoreview&#039;, 2 )&lt;br /&gt;
	end&lt;br /&gt;
	local rawExpiry = mw.getCurrentFrame():callParserFunction(&#039;PROTECTIONEXPIRY&#039;, action, pagename)&lt;br /&gt;
	if rawExpiry == &#039;infinity&#039; then&lt;br /&gt;
		return &#039;infinity&#039;&lt;br /&gt;
	elseif rawExpiry == &#039;&#039; then&lt;br /&gt;
		return &#039;unknown&#039;&lt;br /&gt;
	else&lt;br /&gt;
		local year, month, day, hour, minute, second = rawExpiry:match(&lt;br /&gt;
			&#039;^(%d%d%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)$&#039;&lt;br /&gt;
		)&lt;br /&gt;
		if year then&lt;br /&gt;
			return string.format(&lt;br /&gt;
				&#039;%s-%s-%sT%s:%s:%s&#039;,&lt;br /&gt;
				year, month, day, hour, minute, second&lt;br /&gt;
			)&lt;br /&gt;
		else&lt;br /&gt;
			error(&#039;internal error in Module:Effective protection expiry; malformed expiry timestamp&#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
setmetatable(p, { __index = function(t, k)&lt;br /&gt;
	return function(frame)&lt;br /&gt;
		return t._main(k, frame.args[1])&lt;br /&gt;
	end&lt;br /&gt;
end })&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Documentation/styles.css&amp;diff=621</id>
		<title>Module:Documentation/styles.css</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Documentation/styles.css&amp;diff=621"/>
		<updated>2021-04-26T10:44:08Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;/* {{pp|small=yes}} */&lt;br /&gt;
.documentation,&lt;br /&gt;
.documentation-metadata {&lt;br /&gt;
	border: 1px solid #a2a9b1;&lt;br /&gt;
	background-color: #ecfcf4;&lt;br /&gt;
	clear: both;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.documentation {&lt;br /&gt;
	margin: 1em 0 0 0;&lt;br /&gt;
	padding: 1em;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.documentation-metadata {&lt;br /&gt;
	margin: 0.2em 0; /* same margin left-right as .documentation */&lt;br /&gt;
    font-style: italic;&lt;br /&gt;
    padding: 0.4em 1em; /* same padding left-right as .documentation */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.documentation-startbox {&lt;br /&gt;
	padding-bottom: 3px;&lt;br /&gt;
	border-bottom: 1px solid #aaa;&lt;br /&gt;
	margin-bottom: 1ex;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.documentation-heading {&lt;br /&gt;
	font-weight: bold;&lt;br /&gt;
	font-size: 125%;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.documentation-clear { /* Don&#039;t want things to stick out where they shouldn&#039;t. */&lt;br /&gt;
	clear: both;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.documentation-toolbar {&lt;br /&gt;
	font-style: normal;&lt;br /&gt;
	font-size: 85%;&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Documentation/config&amp;diff=619</id>
		<title>Module:Documentation/config</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Documentation/config&amp;diff=619"/>
		<updated>2021-04-26T10:44:08Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;----------------------------------------------------------------------------------------------------&lt;br /&gt;
--&lt;br /&gt;
--                               Configuration for Module:Documentation&lt;br /&gt;
--&lt;br /&gt;
-- Here you can set the values of the parameters and messages used in Module:Documentation to&lt;br /&gt;
-- localise it to your wiki and your language. Unless specified otherwise, values given here&lt;br /&gt;
-- should be string values.&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local cfg = {} -- Do not edit this line.&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
-- Protection template configuration&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;protection-reason-edit&#039;]&lt;br /&gt;
-- The protection reason for edit-protected templates to pass to&lt;br /&gt;
-- [[Module:Protection banner]].&lt;br /&gt;
cfg[&#039;protection-reason-edit&#039;] = &#039;template&#039;&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
-- Sandbox notice configuration&lt;br /&gt;
--&lt;br /&gt;
-- On sandbox pages the module can display a template notifying users that the current page is a&lt;br /&gt;
-- sandbox, and the location of test cases pages, etc. The module decides whether the page is a&lt;br /&gt;
-- sandbox or not based on the value of cfg[&#039;sandbox-subpage&#039;]. The following settings configure the&lt;br /&gt;
-- messages that the notices contains.&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;sandbox-notice-image&#039;]&lt;br /&gt;
-- The image displayed in the sandbox notice.&lt;br /&gt;
cfg[&#039;sandbox-notice-image&#039;] = &#039;[[File:Sandbox.svg|50px|alt=|link=]]&#039;&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- cfg[&#039;sandbox-notice-pagetype-template&#039;]&lt;br /&gt;
-- cfg[&#039;sandbox-notice-pagetype-module&#039;]&lt;br /&gt;
-- cfg[&#039;sandbox-notice-pagetype-other&#039;]&lt;br /&gt;
-- The page type of the sandbox page. The message that is displayed depends on the current subject&lt;br /&gt;
-- namespace. This message is used in either cfg[&#039;sandbox-notice-blurb&#039;] or&lt;br /&gt;
-- cfg[&#039;sandbox-notice-diff-blurb&#039;].&lt;br /&gt;
--]]&lt;br /&gt;
cfg[&#039;sandbox-notice-pagetype-template&#039;] = &#039;[[Wikipedia:Template test cases|template sandbox]] page&#039;&lt;br /&gt;
cfg[&#039;sandbox-notice-pagetype-module&#039;] = &#039;[[Wikipedia:Template test cases|module sandbox]] page&#039;&lt;br /&gt;
cfg[&#039;sandbox-notice-pagetype-other&#039;] = &#039;sandbox page&#039;&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- cfg[&#039;sandbox-notice-blurb&#039;]&lt;br /&gt;
-- cfg[&#039;sandbox-notice-diff-blurb&#039;]&lt;br /&gt;
-- cfg[&#039;sandbox-notice-diff-display&#039;]&lt;br /&gt;
-- Either cfg[&#039;sandbox-notice-blurb&#039;] or cfg[&#039;sandbox-notice-diff-blurb&#039;] is the opening sentence&lt;br /&gt;
-- of the sandbox notice. The latter has a diff link, but the former does not. $1 is the page&lt;br /&gt;
-- type, which is either cfg[&#039;sandbox-notice-pagetype-template&#039;],&lt;br /&gt;
-- cfg[&#039;sandbox-notice-pagetype-module&#039;] or cfg[&#039;sandbox-notice-pagetype-other&#039;] depending what&lt;br /&gt;
-- namespace we are in. $2 is a link to the main template page, and $3 is a diff link between&lt;br /&gt;
-- the sandbox and the main template. The display value of the diff link is set by &lt;br /&gt;
-- cfg[&#039;sandbox-notice-compare-link-display&#039;].&lt;br /&gt;
--]]&lt;br /&gt;
cfg[&#039;sandbox-notice-blurb&#039;] = &#039;This is the $1 for $2.&#039;&lt;br /&gt;
cfg[&#039;sandbox-notice-diff-blurb&#039;] = &#039;This is the $1 for $2 ($3).&#039;&lt;br /&gt;
cfg[&#039;sandbox-notice-compare-link-display&#039;] = &#039;diff&#039;&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- cfg[&#039;sandbox-notice-testcases-blurb&#039;]&lt;br /&gt;
-- cfg[&#039;sandbox-notice-testcases-link-display&#039;]&lt;br /&gt;
-- cfg[&#039;sandbox-notice-testcases-run-blurb&#039;]&lt;br /&gt;
-- cfg[&#039;sandbox-notice-testcases-run-link-display&#039;]&lt;br /&gt;
-- cfg[&#039;sandbox-notice-testcases-blurb&#039;] is a sentence notifying the user that there is a test cases page&lt;br /&gt;
-- corresponding to this sandbox that they can edit. $1 is a link to the test cases page.&lt;br /&gt;
-- cfg[&#039;sandbox-notice-testcases-link-display&#039;] is the display value for that link.&lt;br /&gt;
-- cfg[&#039;sandbox-notice-testcases-run-blurb&#039;] is a sentence notifying the user that there is a test cases page&lt;br /&gt;
-- corresponding to this sandbox that they can edit, along with a link to run it. $1 is a link to the test&lt;br /&gt;
-- cases page, and $2 is a link to the page to run it.&lt;br /&gt;
-- cfg[&#039;sandbox-notice-testcases-run-link-display&#039;] is the display value for the link to run the test&lt;br /&gt;
-- cases.&lt;br /&gt;
--]]&lt;br /&gt;
cfg[&#039;sandbox-notice-testcases-blurb&#039;] = &#039;See also the companion subpage for $1.&#039;&lt;br /&gt;
cfg[&#039;sandbox-notice-testcases-link-display&#039;] = &#039;test cases&#039;&lt;br /&gt;
cfg[&#039;sandbox-notice-testcases-run-blurb&#039;] = &#039;See also the companion subpage for $1 ($2).&#039;&lt;br /&gt;
cfg[&#039;sandbox-notice-testcases-run-link-display&#039;] = &#039;run&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;sandbox-category&#039;]&lt;br /&gt;
-- A category to add to all template sandboxes.&lt;br /&gt;
cfg[&#039;sandbox-category&#039;] = &#039;Template sandboxes&#039;&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
-- Start box configuration&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;documentation-icon-wikitext&#039;]&lt;br /&gt;
-- The wikitext for the icon shown at the top of the template.&lt;br /&gt;
cfg[&#039;documentation-icon-wikitext&#039;] = &#039;[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;template-namespace-heading&#039;]&lt;br /&gt;
-- The heading shown in the template namespace.&lt;br /&gt;
cfg[&#039;template-namespace-heading&#039;] = &#039;Template documentation&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;module-namespace-heading&#039;]&lt;br /&gt;
-- The heading shown in the module namespace.&lt;br /&gt;
cfg[&#039;module-namespace-heading&#039;] = &#039;Module documentation&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;file-namespace-heading&#039;]&lt;br /&gt;
-- The heading shown in the file namespace.&lt;br /&gt;
cfg[&#039;file-namespace-heading&#039;] = &#039;Summary&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;other-namespaces-heading&#039;]&lt;br /&gt;
-- The heading shown in other namespaces.&lt;br /&gt;
cfg[&#039;other-namespaces-heading&#039;] = &#039;Documentation&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;view-link-display&#039;]&lt;br /&gt;
-- The text to display for &amp;quot;view&amp;quot; links.&lt;br /&gt;
cfg[&#039;view-link-display&#039;] = &#039;view&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;edit-link-display&#039;]&lt;br /&gt;
-- The text to display for &amp;quot;edit&amp;quot; links.&lt;br /&gt;
cfg[&#039;edit-link-display&#039;] = &#039;edit&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;history-link-display&#039;]&lt;br /&gt;
-- The text to display for &amp;quot;history&amp;quot; links.&lt;br /&gt;
cfg[&#039;history-link-display&#039;] = &#039;history&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;purge-link-display&#039;]&lt;br /&gt;
-- The text to display for &amp;quot;purge&amp;quot; links.&lt;br /&gt;
cfg[&#039;purge-link-display&#039;] = &#039;purge&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;create-link-display&#039;]&lt;br /&gt;
-- The text to display for &amp;quot;create&amp;quot; links.&lt;br /&gt;
cfg[&#039;create-link-display&#039;] = &#039;create&#039;&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
-- Link box (end box) configuration&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;transcluded-from-blurb&#039;]&lt;br /&gt;
-- Notice displayed when the docs are transcluded from another page. $1 is a wikilink to that page.&lt;br /&gt;
cfg[&#039;transcluded-from-blurb&#039;] = &#039;The above [[Wikipedia:Template documentation|documentation]] is [[Wikipedia:Transclusion|transcluded]] from $1.&#039;&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- cfg[&#039;create-module-doc-blurb&#039;]&lt;br /&gt;
-- Notice displayed in the module namespace when the documentation subpage does not exist.&lt;br /&gt;
-- $1 is a link to create the documentation page with the preload cfg[&#039;module-preload&#039;] and the&lt;br /&gt;
-- display cfg[&#039;create-link-display&#039;].&lt;br /&gt;
--]]&lt;br /&gt;
cfg[&#039;create-module-doc-blurb&#039;] = &#039;You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].&#039;&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
-- Experiment blurb configuration&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- cfg[&#039;experiment-blurb-template&#039;]&lt;br /&gt;
-- cfg[&#039;experiment-blurb-module&#039;]&lt;br /&gt;
-- The experiment blurb is the text inviting editors to experiment in sandbox and test cases pages.&lt;br /&gt;
-- It is only shown in the template and module namespaces. With the default English settings, it&lt;br /&gt;
-- might look like this:&lt;br /&gt;
--&lt;br /&gt;
-- Editors can experiment in this template&#039;s sandbox (edit | diff) and testcases (edit) pages.&lt;br /&gt;
--&lt;br /&gt;
-- In this example, &amp;quot;sandbox&amp;quot;, &amp;quot;edit&amp;quot;, &amp;quot;diff&amp;quot;, &amp;quot;testcases&amp;quot;, and &amp;quot;edit&amp;quot; would all be links.&lt;br /&gt;
--&lt;br /&gt;
-- There are two versions, cfg[&#039;experiment-blurb-template&#039;] and cfg[&#039;experiment-blurb-module&#039;], depending&lt;br /&gt;
-- on what namespace we are in.&lt;br /&gt;
-- &lt;br /&gt;
-- Parameters:&lt;br /&gt;
--&lt;br /&gt;
-- $1 is a link to the sandbox page. If the sandbox exists, it is in the following format:&lt;br /&gt;
--&lt;br /&gt;
--     cfg[&#039;sandbox-link-display&#039;] (cfg[&#039;sandbox-edit-link-display&#039;] | cfg[&#039;compare-link-display&#039;])&lt;br /&gt;
-- &lt;br /&gt;
-- If the sandbox doesn&#039;t exist, it is in the format:&lt;br /&gt;
--&lt;br /&gt;
--     cfg[&#039;sandbox-link-display&#039;] (cfg[&#039;sandbox-create-link-display&#039;] | cfg[&#039;mirror-link-display&#039;])&lt;br /&gt;
-- &lt;br /&gt;
-- The link for cfg[&#039;sandbox-create-link-display&#039;] link preloads the page with cfg[&#039;template-sandbox-preload&#039;]&lt;br /&gt;
-- or cfg[&#039;module-sandbox-preload&#039;], depending on the current namespace. The link for cfg[&#039;mirror-link-display&#039;]&lt;br /&gt;
-- loads a default edit summary of cfg[&#039;mirror-edit-summary&#039;].&lt;br /&gt;
--&lt;br /&gt;
-- $2 is a link to the test cases page. If the test cases page exists, it is in the following format:&lt;br /&gt;
--&lt;br /&gt;
--     cfg[&#039;testcases-link-display&#039;] (cfg[&#039;testcases-edit-link-display&#039;] | cfg[&#039;testcases-run-link-display&#039;])&lt;br /&gt;
--&lt;br /&gt;
-- If the test cases page doesn&#039;t exist, it is in the format:&lt;br /&gt;
-- &lt;br /&gt;
--     cfg[&#039;testcases-link-display&#039;] (cfg[&#039;testcases-create-link-display&#039;])&lt;br /&gt;
--&lt;br /&gt;
-- If the test cases page doesn&#039;t exist, the link for cfg[&#039;testcases-create-link-display&#039;] preloads the&lt;br /&gt;
-- page with cfg[&#039;template-testcases-preload&#039;] or cfg[&#039;module-testcases-preload&#039;], depending on the current&lt;br /&gt;
-- namespace.&lt;br /&gt;
--]]&lt;br /&gt;
cfg[&#039;experiment-blurb-template&#039;] = &amp;quot;Editors can experiment in this template&#039;s $1 and $2 pages.&amp;quot;&lt;br /&gt;
cfg[&#039;experiment-blurb-module&#039;] = &amp;quot;Editors can experiment in this module&#039;s $1 and $2 pages.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
-- Sandbox link configuration&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;sandbox-subpage&#039;]&lt;br /&gt;
-- The name of the template subpage typically used for sandboxes.&lt;br /&gt;
cfg[&#039;sandbox-subpage&#039;] = &#039;sandbox&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;template-sandbox-preload&#039;]&lt;br /&gt;
-- Preload file for template sandbox pages.&lt;br /&gt;
cfg[&#039;template-sandbox-preload&#039;] = &#039;Template:Documentation/preload-sandbox&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;module-sandbox-preload&#039;]&lt;br /&gt;
-- Preload file for Lua module sandbox pages.&lt;br /&gt;
cfg[&#039;module-sandbox-preload&#039;] = &#039;Template:Documentation/preload-module-sandbox&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;sandbox-link-display&#039;]&lt;br /&gt;
-- The text to display for &amp;quot;sandbox&amp;quot; links.&lt;br /&gt;
cfg[&#039;sandbox-link-display&#039;] = &#039;sandbox&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;sandbox-edit-link-display&#039;]&lt;br /&gt;
-- The text to display for sandbox &amp;quot;edit&amp;quot; links.&lt;br /&gt;
cfg[&#039;sandbox-edit-link-display&#039;] = &#039;edit&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;sandbox-create-link-display&#039;]&lt;br /&gt;
-- The text to display for sandbox &amp;quot;create&amp;quot; links.&lt;br /&gt;
cfg[&#039;sandbox-create-link-display&#039;] = &#039;create&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;compare-link-display&#039;]&lt;br /&gt;
-- The text to display for &amp;quot;compare&amp;quot; links.&lt;br /&gt;
cfg[&#039;compare-link-display&#039;] = &#039;diff&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;mirror-edit-summary&#039;]&lt;br /&gt;
-- The default edit summary to use when a user clicks the &amp;quot;mirror&amp;quot; link. $1 is a wikilink to the&lt;br /&gt;
-- template page.&lt;br /&gt;
cfg[&#039;mirror-edit-summary&#039;] = &#039;Create sandbox version of $1&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;mirror-link-display&#039;]&lt;br /&gt;
-- The text to display for &amp;quot;mirror&amp;quot; links.&lt;br /&gt;
cfg[&#039;mirror-link-display&#039;] = &#039;mirror&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;mirror-link-preload&#039;]&lt;br /&gt;
-- The page to preload when a user clicks the &amp;quot;mirror&amp;quot; link.&lt;br /&gt;
cfg[&#039;mirror-link-preload&#039;] = &#039;Template:Documentation/mirror&#039;&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
-- Test cases link configuration&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;testcases-subpage&#039;]&lt;br /&gt;
-- The name of the template subpage typically used for test cases.&lt;br /&gt;
cfg[&#039;testcases-subpage&#039;] = &#039;testcases&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;template-testcases-preload&#039;]&lt;br /&gt;
-- Preload file for template test cases pages.&lt;br /&gt;
cfg[&#039;template-testcases-preload&#039;] = &#039;Template:Documentation/preload-testcases&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;module-testcases-preload&#039;]&lt;br /&gt;
-- Preload file for Lua module test cases pages.&lt;br /&gt;
cfg[&#039;module-testcases-preload&#039;] = &#039;Template:Documentation/preload-module-testcases&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;testcases-link-display&#039;]&lt;br /&gt;
-- The text to display for &amp;quot;testcases&amp;quot; links.&lt;br /&gt;
cfg[&#039;testcases-link-display&#039;] = &#039;testcases&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;testcases-edit-link-display&#039;]&lt;br /&gt;
-- The text to display for test cases &amp;quot;edit&amp;quot; links.&lt;br /&gt;
cfg[&#039;testcases-edit-link-display&#039;] = &#039;edit&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;testcases-run-link-display&#039;]&lt;br /&gt;
-- The text to display for test cases &amp;quot;run&amp;quot; links.&lt;br /&gt;
cfg[&#039;testcases-run-link-display&#039;] = &#039;run&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;testcases-create-link-display&#039;]&lt;br /&gt;
-- The text to display for test cases &amp;quot;create&amp;quot; links.&lt;br /&gt;
cfg[&#039;testcases-create-link-display&#039;] = &#039;create&#039;&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
-- Add categories blurb configuration&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- cfg[&#039;add-categories-blurb&#039;]&lt;br /&gt;
-- Text to direct users to add categories to the /doc subpage. Not used if the &amp;quot;content&amp;quot; or&lt;br /&gt;
-- &amp;quot;docname fed&amp;quot; arguments are set, as then it is not clear where to add the categories. $1 is a&lt;br /&gt;
-- link to the /doc subpage with a display value of cfg[&#039;doc-link-display&#039;].&lt;br /&gt;
--]]&lt;br /&gt;
cfg[&#039;add-categories-blurb&#039;] = &#039;Please add categories to the $1 subpage.&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;doc-link-display&#039;]&lt;br /&gt;
-- The text to display when linking to the /doc subpage.&lt;br /&gt;
cfg[&#039;doc-link-display&#039;] = &#039;/doc&#039;&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
-- Subpages link configuration&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- cfg[&#039;subpages-blurb&#039;]&lt;br /&gt;
-- The &amp;quot;Subpages of this template&amp;quot; blurb. $1 is a link to the main template&#039;s subpages with a&lt;br /&gt;
-- display value of cfg[&#039;subpages-link-display&#039;]. In the English version this blurb is simply&lt;br /&gt;
-- the link followed by a period, and the link display provides the actual text.&lt;br /&gt;
--]]&lt;br /&gt;
cfg[&#039;subpages-blurb&#039;] = &#039;$1.&#039;&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
-- cfg[&#039;subpages-link-display&#039;]&lt;br /&gt;
-- The text to display for the &amp;quot;subpages of this page&amp;quot; link. $1 is cfg[&#039;template-pagetype&#039;],&lt;br /&gt;
-- cfg[&#039;module-pagetype&#039;] or cfg[&#039;default-pagetype&#039;], depending on whether the current page is in&lt;br /&gt;
-- the template namespace, the module namespace, or another namespace.&lt;br /&gt;
--]]&lt;br /&gt;
cfg[&#039;subpages-link-display&#039;] = &#039;Subpages of this $1&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;template-pagetype&#039;]&lt;br /&gt;
-- The pagetype to display for template pages.&lt;br /&gt;
cfg[&#039;template-pagetype&#039;] = &#039;template&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;module-pagetype&#039;]&lt;br /&gt;
-- The pagetype to display for Lua module pages.&lt;br /&gt;
cfg[&#039;module-pagetype&#039;] = &#039;module&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;default-pagetype&#039;]&lt;br /&gt;
-- The pagetype to display for pages other than templates or Lua modules.&lt;br /&gt;
cfg[&#039;default-pagetype&#039;] = &#039;page&#039;&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
-- Doc link configuration&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;doc-subpage&#039;]&lt;br /&gt;
-- The name of the subpage typically used for documentation pages.&lt;br /&gt;
cfg[&#039;doc-subpage&#039;] = &#039;doc&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;file-docpage-preload&#039;]&lt;br /&gt;
-- Preload file for documentation page in the file namespace.&lt;br /&gt;
cfg[&#039;file-docpage-preload&#039;] = &#039;Template:Documentation/preload-filespace&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;docpage-preload&#039;]&lt;br /&gt;
-- Preload file for template documentation pages in all namespaces.&lt;br /&gt;
cfg[&#039;docpage-preload&#039;] = &#039;Template:Documentation/preload&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;module-preload&#039;]&lt;br /&gt;
-- Preload file for Lua module documentation pages.&lt;br /&gt;
cfg[&#039;module-preload&#039;] = &#039;Template:Documentation/preload-module-doc&#039;&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
-- Print version configuration&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;print-subpage&#039;]&lt;br /&gt;
-- The name of the template subpage used for print versions.&lt;br /&gt;
cfg[&#039;print-subpage&#039;] = &#039;Print&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;print-link-display&#039;]&lt;br /&gt;
-- The text to display when linking to the /Print subpage.&lt;br /&gt;
cfg[&#039;print-link-display&#039;] = &#039;/Print&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;print-blurb&#039;]&lt;br /&gt;
-- Text to display if a /Print subpage exists. $1 is a link to the subpage with&lt;br /&gt;
-- a display value of cfg[&#039;print-link-display&#039;].&lt;br /&gt;
cfg[&#039;print-blurb&#039;] = &#039;A [[Help:Books/for experts#Improving the book layout|print version]] of this template exists at $1.&#039;&lt;br /&gt;
	.. &#039; If you make a change to this template, please update the print version as well.&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;display-print-category&#039;]&lt;br /&gt;
-- Set to true to enable output of cfg[&#039;print-category&#039;] if a /Print subpage exists.&lt;br /&gt;
-- This should be a boolean value (either true or false).&lt;br /&gt;
cfg[&#039;display-print-category&#039;] = true&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;print-category&#039;]&lt;br /&gt;
-- Category to output if cfg[&#039;display-print-category&#039;] is set to true, and a /Print subpage exists.&lt;br /&gt;
cfg[&#039;print-category&#039;] = &#039;Templates with print versions&#039;&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
-- HTML and CSS configuration&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;templatestyles&#039;]&lt;br /&gt;
-- The name of the TemplateStyles page where CSS is kept.&lt;br /&gt;
-- Sandbox CSS will be at Module:Documentation/sandbox/styles.css when needed.&lt;br /&gt;
cfg[&#039;templatestyles&#039;] = &#039;Module:Documentation/styles.css&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;container&#039;]&lt;br /&gt;
-- Class which can be used to set flex or grid CSS on the&lt;br /&gt;
-- two child divs documentation and documentation-metadata&lt;br /&gt;
cfg[&#039;container&#039;] = &#039;documentation-container&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;main-div-classes&#039;]&lt;br /&gt;
-- Classes added to the main HTML &amp;quot;div&amp;quot; tag.&lt;br /&gt;
cfg[&#039;main-div-classes&#039;] = &#039;documentation&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;main-div-heading-class&#039;]&lt;br /&gt;
-- Class for the main heading for templates and modules and assoc. talk spaces&lt;br /&gt;
cfg[&#039;main-div-heading-class&#039;] = &#039;documentation-heading&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;start-box-class&#039;]&lt;br /&gt;
-- Class for the start box&lt;br /&gt;
cfg[&#039;start-box-class&#039;] = &#039;documentation-startbox&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;start-box-link-classes&#039;]&lt;br /&gt;
-- Classes used for the [view][edit][history] or [create] links in the start box.&lt;br /&gt;
-- mw-editsection-like is per [[Wikipedia:Village pump (technical)/Archive 117]]&lt;br /&gt;
cfg[&#039;start-box-link-classes&#039;] = &#039;mw-editsection-like plainlinks&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;end-box-class&#039;]&lt;br /&gt;
-- Class for the end box.&lt;br /&gt;
cfg[&#039;end-box-class&#039;] = &#039;documentation-metadata&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;end-box-plainlinks&#039;]&lt;br /&gt;
-- Plainlinks&lt;br /&gt;
cfg[&#039;end-box-plainlinks&#039;] = &#039;plainlinks&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;toolbar-class&#039;]&lt;br /&gt;
-- Class added for toolbar links.&lt;br /&gt;
cfg[&#039;toolbar-class&#039;] = &#039;documentation-toolbar&#039;&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;clear&#039;]&lt;br /&gt;
-- Just used to clear things.&lt;br /&gt;
cfg[&#039;clear&#039;] = &#039;documentation-clear&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
-- Tracking category configuration&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;display-strange-usage-category&#039;]&lt;br /&gt;
-- Set to true to enable output of cfg[&#039;strange-usage-category&#039;] if the module is used on a /doc subpage&lt;br /&gt;
-- or a /testcases subpage. This should be a boolean value (either true or false).&lt;br /&gt;
cfg[&#039;display-strange-usage-category&#039;] = true&lt;br /&gt;
&lt;br /&gt;
-- cfg[&#039;strange-usage-category&#039;]&lt;br /&gt;
-- Category to output if cfg[&#039;display-strange-usage-category&#039;] is set to true and the module is used on a&lt;br /&gt;
-- /doc subpage or a /testcases subpage.&lt;br /&gt;
cfg[&#039;strange-usage-category&#039;] = &#039;Wikipedia pages with strange ((documentation)) usage&#039;&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
-- End configuration&lt;br /&gt;
--&lt;br /&gt;
-- Don&#039;t edit anything below this line.&lt;br /&gt;
----------------------------------------------------------------------------------------------------&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
return cfg&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Documentation&amp;diff=617</id>
		<title>Module:Documentation</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Documentation&amp;diff=617"/>
		<updated>2021-04-26T10:44:08Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;-- This module implements {{documentation}}.&lt;br /&gt;
&lt;br /&gt;
-- Get required modules.&lt;br /&gt;
local getArgs = require(&#039;Module:Arguments&#039;).getArgs&lt;br /&gt;
&lt;br /&gt;
-- Get the config table.&lt;br /&gt;
local cfg = mw.loadData(&#039;Module:Documentation/config&#039;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- Often-used functions.&lt;br /&gt;
local ugsub = mw.ustring.gsub&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
-- Helper functions&lt;br /&gt;
--&lt;br /&gt;
-- These are defined as local functions, but are made available in the p&lt;br /&gt;
-- table for testing purposes.&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local function message(cfgKey, valArray, expectType)&lt;br /&gt;
	--[[&lt;br /&gt;
	-- Gets a message from the cfg table and formats it if appropriate.&lt;br /&gt;
	-- The function raises an error if the value from the cfg table is not&lt;br /&gt;
	-- of the type expectType. The default type for expectType is &#039;string&#039;.&lt;br /&gt;
	-- If the table valArray is present, strings such as $1, $2 etc. in the&lt;br /&gt;
	-- message are substituted with values from the table keys [1], [2] etc.&lt;br /&gt;
	-- For example, if the message &amp;quot;foo-message&amp;quot; had the value &#039;Foo $2 bar $1.&#039;,&lt;br /&gt;
	-- message(&#039;foo-message&#039;, {&#039;baz&#039;, &#039;qux&#039;}) would return &amp;quot;Foo qux bar baz.&amp;quot;&lt;br /&gt;
	--]]&lt;br /&gt;
	local msg = cfg[cfgKey]&lt;br /&gt;
	expectType = expectType or &#039;string&#039;&lt;br /&gt;
	if type(msg) ~= expectType then&lt;br /&gt;
		error(&#039;message: type error in message cfg.&#039; .. cfgKey .. &#039; (&#039; .. expectType .. &#039; expected, got &#039; .. type(msg) .. &#039;)&#039;, 2)&lt;br /&gt;
	end&lt;br /&gt;
	if not valArray then&lt;br /&gt;
		return msg&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local function getMessageVal(match)&lt;br /&gt;
		match = tonumber(match)&lt;br /&gt;
		return valArray[match] or error(&#039;message: no value found for key $&#039; .. match .. &#039; in message cfg.&#039; .. cfgKey, 4)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return ugsub(msg, &#039;$([1-9][0-9]*)&#039;, getMessageVal)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.message = message&lt;br /&gt;
&lt;br /&gt;
local function makeWikilink(page, display)&lt;br /&gt;
	if display then&lt;br /&gt;
		return mw.ustring.format(&#039;[[%s|%s]]&#039;, page, display)&lt;br /&gt;
	else&lt;br /&gt;
		return mw.ustring.format(&#039;[[%s]]&#039;, page)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.makeWikilink = makeWikilink&lt;br /&gt;
&lt;br /&gt;
local function makeCategoryLink(cat, sort)&lt;br /&gt;
	local catns = mw.site.namespaces[14].name&lt;br /&gt;
	return makeWikilink(catns .. &#039;:&#039; .. cat, sort)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.makeCategoryLink = makeCategoryLink&lt;br /&gt;
&lt;br /&gt;
local function makeUrlLink(url, display)&lt;br /&gt;
	return mw.ustring.format(&#039;[%s %s]&#039;, url, display)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.makeUrlLink = makeUrlLink&lt;br /&gt;
&lt;br /&gt;
local function makeToolbar(...)&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	local lim = select(&#039;#&#039;, ...)&lt;br /&gt;
	if lim &amp;lt; 1 then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	for i = 1, lim do&lt;br /&gt;
		ret[#ret + 1] = select(i, ...)&lt;br /&gt;
	end&lt;br /&gt;
	-- &#039;documentation-toolbar&#039;&lt;br /&gt;
	return &#039;&amp;lt;span class=&amp;quot;&#039; .. message(&#039;toolbar-class&#039;) .. &#039;&amp;quot;&amp;gt;(&#039;&lt;br /&gt;
		.. table.concat(ret, &#039; &amp;amp;#124; &#039;) .. &#039;)&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
end	&lt;br /&gt;
&lt;br /&gt;
p.makeToolbar = makeToolbar&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
-- Argument processing&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
local function makeInvokeFunc(funcName)&lt;br /&gt;
	return function (frame)&lt;br /&gt;
		local args = getArgs(frame, {&lt;br /&gt;
			valueFunc = function (key, value)&lt;br /&gt;
				if type(value) == &#039;string&#039; then&lt;br /&gt;
					value = value:match(&#039;^%s*(.-)%s*$&#039;) -- Remove whitespace.&lt;br /&gt;
					if key == &#039;heading&#039; or value ~= &#039;&#039; then&lt;br /&gt;
						return value&lt;br /&gt;
					else&lt;br /&gt;
						return nil&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					return value&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		})&lt;br /&gt;
		return p[funcName](args)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
-- Entry points&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function p.nonexistent(frame)&lt;br /&gt;
	if mw.title.getCurrentTitle().subpageText == &#039;testcases&#039; then&lt;br /&gt;
		return frame:expandTemplate{title = &#039;module test cases notice&#039;}&lt;br /&gt;
	else&lt;br /&gt;
		return p.main(frame)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.main = makeInvokeFunc(&#039;_main&#039;)&lt;br /&gt;
&lt;br /&gt;
function p._main(args)&lt;br /&gt;
	--[[&lt;br /&gt;
	-- This function defines logic flow for the module.&lt;br /&gt;
	-- @args - table of arguments passed by the user&lt;br /&gt;
	--]]&lt;br /&gt;
	local env = p.getEnvironment(args)&lt;br /&gt;
	local root = mw.html.create()&lt;br /&gt;
	root&lt;br /&gt;
		:wikitext(p._getModuleWikitext(args, env))&lt;br /&gt;
		:wikitext(p.protectionTemplate(env))&lt;br /&gt;
		:wikitext(p.sandboxNotice(args, env))&lt;br /&gt;
		:tag(&#039;div&#039;)&lt;br /&gt;
			-- &#039;documentation-container&#039;&lt;br /&gt;
			:addClass(message(&#039;container&#039;))&lt;br /&gt;
			:newline()&lt;br /&gt;
			:tag(&#039;div&#039;)&lt;br /&gt;
				-- &#039;documentation&#039;&lt;br /&gt;
				:addClass(message(&#039;main-div-classes&#039;))&lt;br /&gt;
				:newline()&lt;br /&gt;
				:wikitext(p._startBox(args, env))&lt;br /&gt;
				:wikitext(p._content(args, env))&lt;br /&gt;
				:tag(&#039;div&#039;)&lt;br /&gt;
					-- &#039;documentation-clear&#039;&lt;br /&gt;
					:addClass(message(&#039;clear&#039;))&lt;br /&gt;
					:done()&lt;br /&gt;
				:newline()&lt;br /&gt;
				:done()&lt;br /&gt;
			:wikitext(p._endBox(args, env))&lt;br /&gt;
			:done()&lt;br /&gt;
		:wikitext(p.addTrackingCategories(env))&lt;br /&gt;
	-- &#039;Module:Documentation/styles.css&#039;&lt;br /&gt;
	return mw.getCurrentFrame():extensionTag (&lt;br /&gt;
		&#039;templatestyles&#039;, &#039;&#039;, {src=cfg[&#039;templatestyles&#039;]&lt;br /&gt;
	}) .. tostring(root)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
-- Environment settings&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function p.getEnvironment(args)&lt;br /&gt;
	--[[&lt;br /&gt;
	-- Returns a table with information about the environment, including title&lt;br /&gt;
	-- objects and other namespace- or path-related data.&lt;br /&gt;
	-- @args - table of arguments passed by the user&lt;br /&gt;
	--&lt;br /&gt;
	-- Title objects include:&lt;br /&gt;
	-- env.title - the page we are making documentation for (usually the current title)&lt;br /&gt;
	-- env.templateTitle - the template (or module, file, etc.)&lt;br /&gt;
	-- env.docTitle - the /doc subpage.&lt;br /&gt;
	-- env.sandboxTitle - the /sandbox subpage.&lt;br /&gt;
	-- env.testcasesTitle - the /testcases subpage.&lt;br /&gt;
	-- env.printTitle - the print version of the template, located at the /Print subpage.&lt;br /&gt;
	--&lt;br /&gt;
	-- Data includes:&lt;br /&gt;
	-- env.protectionLevels - the protection levels table of the title object.&lt;br /&gt;
	-- env.subjectSpace - the number of the title&#039;s subject namespace.&lt;br /&gt;
	-- env.docSpace - the number of the namespace the title puts its documentation in.&lt;br /&gt;
	-- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace.&lt;br /&gt;
	-- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template.&lt;br /&gt;
	-- &lt;br /&gt;
	-- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value&lt;br /&gt;
	-- returned will be nil.&lt;br /&gt;
	--]]&lt;br /&gt;
	&lt;br /&gt;
	local env, envFuncs = {}, {}&lt;br /&gt;
&lt;br /&gt;
	-- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value&lt;br /&gt;
	-- returned by that function is memoized in the env table so that we don&#039;t call any of the functions&lt;br /&gt;
	-- more than once. (Nils won&#039;t be memoized.)&lt;br /&gt;
	setmetatable(env, {&lt;br /&gt;
		__index = function (t, key)&lt;br /&gt;
			local envFunc = envFuncs[key]&lt;br /&gt;
			if envFunc then&lt;br /&gt;
				local success, val = pcall(envFunc)&lt;br /&gt;
				if success then&lt;br /&gt;
					env[key] = val -- Memoise the value.&lt;br /&gt;
					return val&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
	})	&lt;br /&gt;
&lt;br /&gt;
	function envFuncs.title()&lt;br /&gt;
		-- The title object for the current page, or a test page passed with args.page.&lt;br /&gt;
		local title&lt;br /&gt;
		local titleArg = args.page&lt;br /&gt;
		if titleArg then&lt;br /&gt;
			title = mw.title.new(titleArg)&lt;br /&gt;
		else&lt;br /&gt;
			title = mw.title.getCurrentTitle()&lt;br /&gt;
		end&lt;br /&gt;
		return title&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	function envFuncs.templateTitle()&lt;br /&gt;
		--[[&lt;br /&gt;
		-- The template (or module, etc.) title object.&lt;br /&gt;
		-- Messages:&lt;br /&gt;
		-- &#039;sandbox-subpage&#039; --&amp;gt; &#039;sandbox&#039;&lt;br /&gt;
		-- &#039;testcases-subpage&#039; --&amp;gt; &#039;testcases&#039;&lt;br /&gt;
		--]]&lt;br /&gt;
		local subjectSpace = env.subjectSpace&lt;br /&gt;
		local title = env.title&lt;br /&gt;
		local subpage = title.subpageText&lt;br /&gt;
		if subpage == message(&#039;sandbox-subpage&#039;) or subpage == message(&#039;testcases-subpage&#039;) then&lt;br /&gt;
			return mw.title.makeTitle(subjectSpace, title.baseText)&lt;br /&gt;
		else&lt;br /&gt;
			return mw.title.makeTitle(subjectSpace, title.text)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	function envFuncs.docTitle()&lt;br /&gt;
		--[[&lt;br /&gt;
		-- Title object of the /doc subpage.&lt;br /&gt;
		-- Messages:&lt;br /&gt;
		-- &#039;doc-subpage&#039; --&amp;gt; &#039;doc&#039;&lt;br /&gt;
		--]]&lt;br /&gt;
		local title = env.title&lt;br /&gt;
		local docname = args[1] -- User-specified doc page.&lt;br /&gt;
		local docpage&lt;br /&gt;
		if docname then&lt;br /&gt;
			docpage = docname&lt;br /&gt;
		else&lt;br /&gt;
			docpage = env.docpageBase .. &#039;/&#039; .. message(&#039;doc-subpage&#039;)&lt;br /&gt;
		end&lt;br /&gt;
		return mw.title.new(docpage)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	function envFuncs.sandboxTitle()&lt;br /&gt;
		--[[&lt;br /&gt;
		-- Title object for the /sandbox subpage.&lt;br /&gt;
		-- Messages:&lt;br /&gt;
		-- &#039;sandbox-subpage&#039; --&amp;gt; &#039;sandbox&#039;&lt;br /&gt;
		--]]&lt;br /&gt;
		return mw.title.new(env.docpageBase .. &#039;/&#039; .. message(&#039;sandbox-subpage&#039;))&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	function envFuncs.testcasesTitle()&lt;br /&gt;
		--[[&lt;br /&gt;
		-- Title object for the /testcases subpage.&lt;br /&gt;
		-- Messages:&lt;br /&gt;
		-- &#039;testcases-subpage&#039; --&amp;gt; &#039;testcases&#039;&lt;br /&gt;
		--]]&lt;br /&gt;
		return mw.title.new(env.docpageBase .. &#039;/&#039; .. message(&#039;testcases-subpage&#039;))&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	function envFuncs.printTitle()&lt;br /&gt;
		--[[&lt;br /&gt;
		-- Title object for the /Print subpage.&lt;br /&gt;
		-- Messages:&lt;br /&gt;
		-- &#039;print-subpage&#039; --&amp;gt; &#039;Print&#039;&lt;br /&gt;
		--]]&lt;br /&gt;
		return env.templateTitle:subPageTitle(message(&#039;print-subpage&#039;))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	function envFuncs.protectionLevels()&lt;br /&gt;
		-- The protection levels table of the title object.&lt;br /&gt;
		return env.title.protectionLevels&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	function envFuncs.subjectSpace()&lt;br /&gt;
		-- The subject namespace number.&lt;br /&gt;
		return mw.site.namespaces[env.title.namespace].subject.id&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	function envFuncs.docSpace()&lt;br /&gt;
		-- The documentation namespace number. For most namespaces this is the&lt;br /&gt;
		-- same as the subject namespace. However, pages in the Article, File,&lt;br /&gt;
		-- MediaWiki or Category namespaces must have their /doc, /sandbox and&lt;br /&gt;
		-- /testcases pages in talk space.&lt;br /&gt;
		local subjectSpace = env.subjectSpace&lt;br /&gt;
		if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then&lt;br /&gt;
			return subjectSpace + 1&lt;br /&gt;
		else&lt;br /&gt;
			return subjectSpace&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	function envFuncs.docpageBase()&lt;br /&gt;
		-- The base page of the /doc, /sandbox, and /testcases subpages.&lt;br /&gt;
		-- For some namespaces this is the talk page, rather than the template page.&lt;br /&gt;
		local templateTitle = env.templateTitle&lt;br /&gt;
		local docSpace = env.docSpace&lt;br /&gt;
		local docSpaceText = mw.site.namespaces[docSpace].name&lt;br /&gt;
		-- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon.&lt;br /&gt;
		return docSpaceText .. &#039;:&#039; .. templateTitle.text&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	function envFuncs.compareUrl()&lt;br /&gt;
		-- Diff link between the sandbox and the main template using [[Special:ComparePages]].&lt;br /&gt;
		local templateTitle = env.templateTitle&lt;br /&gt;
		local sandboxTitle = env.sandboxTitle&lt;br /&gt;
		if templateTitle.exists and sandboxTitle.exists then&lt;br /&gt;
			local compareUrl = mw.uri.fullUrl(&lt;br /&gt;
				&#039;Special:ComparePages&#039;,&lt;br /&gt;
				{ page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}&lt;br /&gt;
			)&lt;br /&gt;
			return tostring(compareUrl)&lt;br /&gt;
		else&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
	end		&lt;br /&gt;
&lt;br /&gt;
	return env&lt;br /&gt;
end	&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
-- Auxiliary templates&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
p.getModuleWikitext = makeInvokeFunc(&#039;_getModuleWikitext&#039;)&lt;br /&gt;
&lt;br /&gt;
function p._getModuleWikitext(args, env)&lt;br /&gt;
	local currentTitle = mw.title.getCurrentTitle()&lt;br /&gt;
	if currentTitle.contentModel ~= &#039;Scribunto&#039; then return end&lt;br /&gt;
	pcall(require, currentTitle.prefixedText) -- if it fails, we don&#039;t care&lt;br /&gt;
	local moduleWikitext =  package.loaded[&amp;quot;Module:Module wikitext&amp;quot;]&lt;br /&gt;
	if moduleWikitext then&lt;br /&gt;
		return moduleWikitext.main()&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.sandboxNotice(args, env)&lt;br /&gt;
	--[=[&lt;br /&gt;
	-- Generates a sandbox notice for display above sandbox pages.&lt;br /&gt;
	-- @args - a table of arguments passed by the user&lt;br /&gt;
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment&lt;br /&gt;
	-- &lt;br /&gt;
	-- Messages:&lt;br /&gt;
	-- &#039;sandbox-notice-image&#039; --&amp;gt; &#039;[[Image:Sandbox.svg|50px|alt=|link=]]&#039;&lt;br /&gt;
	-- &#039;sandbox-notice-blurb&#039; --&amp;gt; &#039;This is the $1 for $2.&#039;&lt;br /&gt;
	-- &#039;sandbox-notice-diff-blurb&#039; --&amp;gt; &#039;This is the $1 for $2 ($3).&#039;&lt;br /&gt;
	-- &#039;sandbox-notice-pagetype-template&#039; --&amp;gt; &#039;[[Wikipedia:Template test cases|template sandbox]] page&#039;&lt;br /&gt;
	-- &#039;sandbox-notice-pagetype-module&#039; --&amp;gt; &#039;[[Wikipedia:Template test cases|module sandbox]] page&#039;&lt;br /&gt;
	-- &#039;sandbox-notice-pagetype-other&#039; --&amp;gt; &#039;sandbox page&#039;&lt;br /&gt;
	-- &#039;sandbox-notice-compare-link-display&#039; --&amp;gt; &#039;diff&#039;&lt;br /&gt;
	-- &#039;sandbox-notice-testcases-blurb&#039; --&amp;gt; &#039;See also the companion subpage for $1.&#039;&lt;br /&gt;
	-- &#039;sandbox-notice-testcases-link-display&#039; --&amp;gt; &#039;test cases&#039;&lt;br /&gt;
	-- &#039;sandbox-category&#039; --&amp;gt; &#039;Template sandboxes&#039;&lt;br /&gt;
	--]=]&lt;br /&gt;
	local title = env.title&lt;br /&gt;
	local sandboxTitle = env.sandboxTitle&lt;br /&gt;
	local templateTitle = env.templateTitle&lt;br /&gt;
	local subjectSpace = env.subjectSpace&lt;br /&gt;
	if not (subjectSpace and title and sandboxTitle and templateTitle&lt;br /&gt;
		and mw.title.equals(title, sandboxTitle)) then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	-- Build the table of arguments to pass to {{ombox}}. We need just two fields, &amp;quot;image&amp;quot; and &amp;quot;text&amp;quot;.&lt;br /&gt;
	local omargs = {}&lt;br /&gt;
	omargs.image = message(&#039;sandbox-notice-image&#039;)&lt;br /&gt;
	-- Get the text. We start with the opening blurb, which is something like&lt;br /&gt;
	-- &amp;quot;This is the template sandbox for [[Template:Foo]] (diff).&amp;quot;&lt;br /&gt;
	local text = &#039;&#039;&lt;br /&gt;
	local pagetype&lt;br /&gt;
	if subjectSpace == 10 then&lt;br /&gt;
		pagetype = message(&#039;sandbox-notice-pagetype-template&#039;)&lt;br /&gt;
	elseif subjectSpace == 828 then&lt;br /&gt;
		pagetype = message(&#039;sandbox-notice-pagetype-module&#039;)&lt;br /&gt;
	else&lt;br /&gt;
		pagetype = message(&#039;sandbox-notice-pagetype-other&#039;)&lt;br /&gt;
	end&lt;br /&gt;
	local templateLink = makeWikilink(templateTitle.prefixedText)&lt;br /&gt;
	local compareUrl = env.compareUrl&lt;br /&gt;
	if compareUrl then&lt;br /&gt;
		local compareDisplay = message(&#039;sandbox-notice-compare-link-display&#039;)&lt;br /&gt;
		local compareLink = makeUrlLink(compareUrl, compareDisplay)&lt;br /&gt;
		text = text .. message(&#039;sandbox-notice-diff-blurb&#039;, {pagetype, templateLink, compareLink})&lt;br /&gt;
	else&lt;br /&gt;
		text = text .. message(&#039;sandbox-notice-blurb&#039;, {pagetype, templateLink})&lt;br /&gt;
	end&lt;br /&gt;
	-- Get the test cases page blurb if the page exists. This is something like&lt;br /&gt;
	-- &amp;quot;See also the companion subpage for [[Template:Foo/testcases|test cases]].&amp;quot;&lt;br /&gt;
	local testcasesTitle = env.testcasesTitle&lt;br /&gt;
	if testcasesTitle and testcasesTitle.exists then&lt;br /&gt;
		if testcasesTitle.contentModel == &amp;quot;Scribunto&amp;quot; then&lt;br /&gt;
			local testcasesLinkDisplay = message(&#039;sandbox-notice-testcases-link-display&#039;)&lt;br /&gt;
			local testcasesRunLinkDisplay = message(&#039;sandbox-notice-testcases-run-link-display&#039;)&lt;br /&gt;
			local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)&lt;br /&gt;
			local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)&lt;br /&gt;
			text = text .. &#039;&amp;lt;br /&amp;gt;&#039; .. message(&#039;sandbox-notice-testcases-run-blurb&#039;, {testcasesLink, testcasesRunLink})&lt;br /&gt;
		else&lt;br /&gt;
			local testcasesLinkDisplay = message(&#039;sandbox-notice-testcases-link-display&#039;)&lt;br /&gt;
			local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)&lt;br /&gt;
			text = text .. &#039;&amp;lt;br /&amp;gt;&#039; .. message(&#039;sandbox-notice-testcases-blurb&#039;, {testcasesLink})&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- Add the sandbox to the sandbox category.&lt;br /&gt;
	omargs.text = text .. makeCategoryLink(message(&#039;sandbox-category&#039;))&lt;br /&gt;
&lt;br /&gt;
	-- &#039;documentation-clear&#039;&lt;br /&gt;
	return &#039;&amp;lt;div class=&amp;quot;&#039; .. message(&#039;clear&#039;) .. &#039;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;&lt;br /&gt;
		.. require(&#039;Module:Message box&#039;).main(&#039;ombox&#039;, omargs)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.protectionTemplate(env)&lt;br /&gt;
	-- Generates the padlock icon in the top right.&lt;br /&gt;
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment&lt;br /&gt;
	-- Messages:&lt;br /&gt;
	-- &#039;protection-template&#039; --&amp;gt; &#039;pp-template&#039;&lt;br /&gt;
	-- &#039;protection-template-args&#039; --&amp;gt; {docusage = &#039;yes&#039;}&lt;br /&gt;
	local protectionLevels = env.protectionLevels&lt;br /&gt;
	if not protectionLevels then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local editProt = protectionLevels.edit and protectionLevels.edit[1]&lt;br /&gt;
	local moveProt = protectionLevels.move and protectionLevels.move[1]&lt;br /&gt;
	if editProt then&lt;br /&gt;
		-- The page is edit-protected.&lt;br /&gt;
		return require(&#039;Module:Protection banner&#039;)._main{&lt;br /&gt;
			message(&#039;protection-reason-edit&#039;), small = true&lt;br /&gt;
		}&lt;br /&gt;
	elseif moveProt and moveProt ~= &#039;autoconfirmed&#039; then&lt;br /&gt;
		-- The page is move-protected but not edit-protected. Exclude move&lt;br /&gt;
		-- protection with the level &amp;quot;autoconfirmed&amp;quot;, as this is equivalent to&lt;br /&gt;
		-- no move protection at all.&lt;br /&gt;
		return require(&#039;Module:Protection banner&#039;)._main{&lt;br /&gt;
			action = &#039;move&#039;, small = true&lt;br /&gt;
		}&lt;br /&gt;
	else&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
-- Start box&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
p.startBox = makeInvokeFunc(&#039;_startBox&#039;)&lt;br /&gt;
&lt;br /&gt;
function p._startBox(args, env)&lt;br /&gt;
	--[[&lt;br /&gt;
	-- This function generates the start box.&lt;br /&gt;
	-- @args - a table of arguments passed by the user&lt;br /&gt;
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment&lt;br /&gt;
	-- &lt;br /&gt;
	-- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make&lt;br /&gt;
	-- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox&lt;br /&gt;
	-- which generate the box HTML.&lt;br /&gt;
	--]]&lt;br /&gt;
	env = env or p.getEnvironment(args)&lt;br /&gt;
	local links&lt;br /&gt;
	local content = args.content&lt;br /&gt;
	if not content or args[1] then&lt;br /&gt;
		-- No need to include the links if the documentation is on the template page itself.&lt;br /&gt;
		local linksData = p.makeStartBoxLinksData(args, env)&lt;br /&gt;
		if linksData then&lt;br /&gt;
			links = p.renderStartBoxLinks(linksData)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- Generate the start box html.&lt;br /&gt;
	local data = p.makeStartBoxData(args, env, links)&lt;br /&gt;
	if data then&lt;br /&gt;
		return p.renderStartBox(data)&lt;br /&gt;
	else&lt;br /&gt;
		-- User specified no heading.&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.makeStartBoxLinksData(args, env)&lt;br /&gt;
	--[[&lt;br /&gt;
	-- Does initial processing of data to make the [view] [edit] [history] [purge] links.&lt;br /&gt;
	-- @args - a table of arguments passed by the user&lt;br /&gt;
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment&lt;br /&gt;
	-- &lt;br /&gt;
	-- Messages:&lt;br /&gt;
	-- &#039;view-link-display&#039; --&amp;gt; &#039;view&#039;&lt;br /&gt;
	-- &#039;edit-link-display&#039; --&amp;gt; &#039;edit&#039;&lt;br /&gt;
	-- &#039;history-link-display&#039; --&amp;gt; &#039;history&#039;&lt;br /&gt;
	-- &#039;purge-link-display&#039; --&amp;gt; &#039;purge&#039;&lt;br /&gt;
	-- &#039;file-docpage-preload&#039; --&amp;gt; &#039;Template:Documentation/preload-filespace&#039;&lt;br /&gt;
	-- &#039;module-preload&#039; --&amp;gt; &#039;Template:Documentation/preload-module-doc&#039;&lt;br /&gt;
	-- &#039;docpage-preload&#039; --&amp;gt; &#039;Template:Documentation/preload&#039;&lt;br /&gt;
	-- &#039;create-link-display&#039; --&amp;gt; &#039;create&#039;&lt;br /&gt;
	--]]&lt;br /&gt;
	local subjectSpace = env.subjectSpace&lt;br /&gt;
	local title = env.title&lt;br /&gt;
	local docTitle = env.docTitle&lt;br /&gt;
	if not title or not docTitle then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	if docTitle.isRedirect then &lt;br /&gt;
		docTitle = docTitle.redirectTarget&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local data = {}&lt;br /&gt;
	data.title = title&lt;br /&gt;
	data.docTitle = docTitle&lt;br /&gt;
	-- View, display, edit, and purge links if /doc exists.&lt;br /&gt;
	data.viewLinkDisplay = message(&#039;view-link-display&#039;)&lt;br /&gt;
	data.editLinkDisplay = message(&#039;edit-link-display&#039;)&lt;br /&gt;
	data.historyLinkDisplay = message(&#039;history-link-display&#039;)&lt;br /&gt;
	data.purgeLinkDisplay = message(&#039;purge-link-display&#039;)&lt;br /&gt;
	-- Create link if /doc doesn&#039;t exist.&lt;br /&gt;
	local preload = args.preload&lt;br /&gt;
	if not preload then&lt;br /&gt;
		if subjectSpace == 6 then -- File namespace&lt;br /&gt;
			preload = message(&#039;file-docpage-preload&#039;)&lt;br /&gt;
		elseif subjectSpace == 828 then -- Module namespace&lt;br /&gt;
			preload = message(&#039;module-preload&#039;)&lt;br /&gt;
		else&lt;br /&gt;
			preload = message(&#039;docpage-preload&#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	data.preload = preload&lt;br /&gt;
	data.createLinkDisplay = message(&#039;create-link-display&#039;)&lt;br /&gt;
	return data&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.renderStartBoxLinks(data)&lt;br /&gt;
	--[[&lt;br /&gt;
	-- Generates the [view][edit][history][purge] or [create] links from the data table.&lt;br /&gt;
	-- @data - a table of data generated by p.makeStartBoxLinksData&lt;br /&gt;
	--]]&lt;br /&gt;
	&lt;br /&gt;
	local function escapeBrackets(s)&lt;br /&gt;
		-- Escapes square brackets with HTML entities.&lt;br /&gt;
		s = s:gsub(&#039;%[&#039;, &#039;&amp;amp;#91;&#039;) -- Replace square brackets with HTML entities.&lt;br /&gt;
		s = s:gsub(&#039;%]&#039;, &#039;&amp;amp;#93;&#039;)&lt;br /&gt;
		return s&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local ret&lt;br /&gt;
	local docTitle = data.docTitle&lt;br /&gt;
	local title = data.title&lt;br /&gt;
	if docTitle.exists then&lt;br /&gt;
		local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)&lt;br /&gt;
		local editLink = makeUrlLink(docTitle:fullUrl{action = &#039;edit&#039;}, data.editLinkDisplay)&lt;br /&gt;
		local historyLink = makeUrlLink(docTitle:fullUrl{action = &#039;history&#039;}, data.historyLinkDisplay)&lt;br /&gt;
		local purgeLink = makeUrlLink(title:fullUrl{action = &#039;purge&#039;}, data.purgeLinkDisplay)&lt;br /&gt;
		ret = &#039;[%s] [%s] [%s] [%s]&#039;&lt;br /&gt;
		ret = escapeBrackets(ret)&lt;br /&gt;
		ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink)&lt;br /&gt;
	else&lt;br /&gt;
		local createLink = makeUrlLink(docTitle:fullUrl{action = &#039;edit&#039;, preload = data.preload}, data.createLinkDisplay)&lt;br /&gt;
		ret = &#039;[%s]&#039;&lt;br /&gt;
		ret = escapeBrackets(ret)&lt;br /&gt;
		ret = mw.ustring.format(ret, createLink)&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.makeStartBoxData(args, env, links)&lt;br /&gt;
	--[=[&lt;br /&gt;
	-- Does initial processing of data to pass to the start-box render function, p.renderStartBox.&lt;br /&gt;
	-- @args - a table of arguments passed by the user&lt;br /&gt;
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment&lt;br /&gt;
	-- @links - a string containing the [view][edit][history][purge] links - could be nil if there&#039;s an error.&lt;br /&gt;
	--&lt;br /&gt;
	-- Messages:&lt;br /&gt;
	-- &#039;documentation-icon-wikitext&#039; --&amp;gt; &#039;[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]&#039;&lt;br /&gt;
	-- &#039;template-namespace-heading&#039; --&amp;gt; &#039;Template documentation&#039;&lt;br /&gt;
	-- &#039;module-namespace-heading&#039; --&amp;gt; &#039;Module documentation&#039;&lt;br /&gt;
	-- &#039;file-namespace-heading&#039; --&amp;gt; &#039;Summary&#039;&lt;br /&gt;
	-- &#039;other-namespaces-heading&#039; --&amp;gt; &#039;Documentation&#039;&lt;br /&gt;
	-- &#039;testcases-create-link-display&#039; --&amp;gt; &#039;create&#039;&lt;br /&gt;
	--]=]&lt;br /&gt;
	local subjectSpace = env.subjectSpace&lt;br /&gt;
	if not subjectSpace then&lt;br /&gt;
		-- Default to an &amp;quot;other namespaces&amp;quot; namespace, so that we get at least some output&lt;br /&gt;
		-- if an error occurs.&lt;br /&gt;
		subjectSpace = 2&lt;br /&gt;
	end&lt;br /&gt;
	local data = {}&lt;br /&gt;
	&lt;br /&gt;
	-- Heading&lt;br /&gt;
	local heading = args.heading -- Blank values are not removed.&lt;br /&gt;
	if heading == &#039;&#039; then&lt;br /&gt;
		-- Don&#039;t display the start box if the heading arg is defined but blank.&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	if heading then&lt;br /&gt;
		data.heading = heading&lt;br /&gt;
	elseif subjectSpace == 10 then -- Template namespace&lt;br /&gt;
		data.heading = message(&#039;documentation-icon-wikitext&#039;) .. &#039; &#039; .. message(&#039;template-namespace-heading&#039;)&lt;br /&gt;
	elseif subjectSpace == 828 then -- Module namespace&lt;br /&gt;
		data.heading = message(&#039;documentation-icon-wikitext&#039;) .. &#039; &#039; .. message(&#039;module-namespace-heading&#039;)&lt;br /&gt;
	elseif subjectSpace == 6 then -- File namespace&lt;br /&gt;
		data.heading = message(&#039;file-namespace-heading&#039;)&lt;br /&gt;
	else&lt;br /&gt;
		data.heading = message(&#039;other-namespaces-heading&#039;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Heading CSS&lt;br /&gt;
	local headingStyle = args[&#039;heading-style&#039;]&lt;br /&gt;
	if headingStyle then&lt;br /&gt;
		data.headingStyleText = headingStyle&lt;br /&gt;
	else&lt;br /&gt;
		-- &#039;documentation-heading&#039;&lt;br /&gt;
		data.headingClass = message(&#039;main-div-heading-class&#039;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Data for the [view][edit][history][purge] or [create] links.&lt;br /&gt;
	if links then&lt;br /&gt;
		-- &#039;mw-editsection-like plainlinks&#039;&lt;br /&gt;
		data.linksClass = message(&#039;start-box-link-classes&#039;)&lt;br /&gt;
		data.links = links&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return data&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.renderStartBox(data)&lt;br /&gt;
	-- Renders the start box html.&lt;br /&gt;
	-- @data - a table of data generated by p.makeStartBoxData.&lt;br /&gt;
	local sbox = mw.html.create(&#039;div&#039;)&lt;br /&gt;
	sbox&lt;br /&gt;
		-- &#039;documentation-startbox&#039;&lt;br /&gt;
		:addClass(message(&#039;start-box-class&#039;))&lt;br /&gt;
		:newline()&lt;br /&gt;
		:tag(&#039;span&#039;)&lt;br /&gt;
			:addClass(data.headingClass)&lt;br /&gt;
			:cssText(data.headingStyleText)&lt;br /&gt;
			:wikitext(data.heading)&lt;br /&gt;
	local links = data.links&lt;br /&gt;
	if links then&lt;br /&gt;
		sbox:tag(&#039;span&#039;)&lt;br /&gt;
			:addClass(data.linksClass)&lt;br /&gt;
			:attr(&#039;id&#039;, data.linksId)&lt;br /&gt;
			:wikitext(links)&lt;br /&gt;
	end&lt;br /&gt;
	return tostring(sbox)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
-- Documentation content&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
p.content = makeInvokeFunc(&#039;_content&#039;)&lt;br /&gt;
&lt;br /&gt;
function p._content(args, env)&lt;br /&gt;
	-- Displays the documentation contents&lt;br /&gt;
	-- @args - a table of arguments passed by the user&lt;br /&gt;
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment&lt;br /&gt;
	env = env or p.getEnvironment(args)&lt;br /&gt;
	local docTitle = env.docTitle&lt;br /&gt;
	local content = args.content&lt;br /&gt;
	if not content and docTitle and docTitle.exists then&lt;br /&gt;
		content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}&lt;br /&gt;
	end&lt;br /&gt;
	-- The line breaks below are necessary so that &amp;quot;=== Headings ===&amp;quot; at the start and end&lt;br /&gt;
	-- of docs are interpreted correctly.&lt;br /&gt;
	return &#039;\n&#039; .. (content or &#039;&#039;) .. &#039;\n&#039; &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.contentTitle = makeInvokeFunc(&#039;_contentTitle&#039;)&lt;br /&gt;
&lt;br /&gt;
function p._contentTitle(args, env)&lt;br /&gt;
	env = env or p.getEnvironment(args)&lt;br /&gt;
	local docTitle = env.docTitle&lt;br /&gt;
	if not args.content and docTitle and docTitle.exists then&lt;br /&gt;
		return docTitle.prefixedText&lt;br /&gt;
	else&lt;br /&gt;
		return &#039;&#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
-- End box&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
p.endBox = makeInvokeFunc(&#039;_endBox&#039;)&lt;br /&gt;
&lt;br /&gt;
function p._endBox(args, env)&lt;br /&gt;
	--[=[&lt;br /&gt;
	-- This function generates the end box (also known as the link box).&lt;br /&gt;
	-- @args - a table of arguments passed by the user&lt;br /&gt;
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment&lt;br /&gt;
	-- &lt;br /&gt;
	--]=]&lt;br /&gt;
	&lt;br /&gt;
	-- Get environment data.&lt;br /&gt;
	env = env or p.getEnvironment(args)&lt;br /&gt;
	local subjectSpace = env.subjectSpace&lt;br /&gt;
	local docTitle = env.docTitle&lt;br /&gt;
	if not subjectSpace or not docTitle then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
		&lt;br /&gt;
	-- Check whether we should output the end box at all. Add the end&lt;br /&gt;
	-- box by default if the documentation exists or if we are in the&lt;br /&gt;
	-- user, module or template namespaces.&lt;br /&gt;
	local linkBox = args[&#039;link box&#039;]&lt;br /&gt;
	if linkBox == &#039;off&#039;&lt;br /&gt;
		or not (&lt;br /&gt;
			docTitle.exists&lt;br /&gt;
			or subjectSpace == 2&lt;br /&gt;
			or subjectSpace == 828&lt;br /&gt;
			or subjectSpace == 10&lt;br /&gt;
		)&lt;br /&gt;
	then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Assemble the link box.&lt;br /&gt;
	local text = &#039;&#039;&lt;br /&gt;
	if linkBox then&lt;br /&gt;
		text = text .. linkBox&lt;br /&gt;
	else&lt;br /&gt;
		text = text .. (p.makeDocPageBlurb(args, env) or &#039;&#039;) -- &amp;quot;This documentation is transcluded from [[Foo]].&amp;quot; &lt;br /&gt;
		if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then&lt;br /&gt;
			-- We are in the user, template or module namespaces.&lt;br /&gt;
			-- Add sandbox and testcases links.&lt;br /&gt;
			-- &amp;quot;Editors can experiment in this template&#039;s sandbox and testcases pages.&amp;quot;&lt;br /&gt;
			text = text .. (p.makeExperimentBlurb(args, env) or &#039;&#039;) .. &#039;&amp;lt;br /&amp;gt;&#039;&lt;br /&gt;
			if not args.content and not args[1] then&lt;br /&gt;
				-- &amp;quot;Please add categories to the /doc subpage.&amp;quot;&lt;br /&gt;
				-- Don&#039;t show this message with inline docs or with an explicitly specified doc page,&lt;br /&gt;
				-- as then it is unclear where to add the categories.&lt;br /&gt;
				text = text .. (p.makeCategoriesBlurb(args, env) or &#039;&#039;)&lt;br /&gt;
			end&lt;br /&gt;
			text = text .. &#039; &#039; .. (p.makeSubpagesBlurb(args, env) or &#039;&#039;) --&amp;quot;Subpages of this template&amp;quot;&lt;br /&gt;
			local printBlurb = p.makePrintBlurb(args, env) -- Two-line blurb about print versions of templates.&lt;br /&gt;
			if printBlurb then&lt;br /&gt;
				text = text .. &#039;&amp;lt;br /&amp;gt;&#039; .. printBlurb&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local box = mw.html.create(&#039;div&#039;)&lt;br /&gt;
	-- &#039;documentation-metadata&#039;&lt;br /&gt;
	box:attr(&#039;role&#039;, &#039;note&#039;)&lt;br /&gt;
		:addClass(message(&#039;end-box-class&#039;))&lt;br /&gt;
		-- &#039;plainlinks&#039;&lt;br /&gt;
		:addClass(message(&#039;end-box-plainlinks&#039;))&lt;br /&gt;
		:wikitext(text)&lt;br /&gt;
		:done()&lt;br /&gt;
&lt;br /&gt;
	return &#039;\n&#039; .. tostring(box)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.makeDocPageBlurb(args, env)&lt;br /&gt;
	--[=[&lt;br /&gt;
	-- Makes the blurb &amp;quot;This documentation is transcluded from [[Template:Foo]] (edit, history)&amp;quot;.&lt;br /&gt;
	-- @args - a table of arguments passed by the user&lt;br /&gt;
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment&lt;br /&gt;
	-- &lt;br /&gt;
	-- Messages:&lt;br /&gt;
	-- &#039;edit-link-display&#039; --&amp;gt; &#039;edit&#039;&lt;br /&gt;
	-- &#039;history-link-display&#039; --&amp;gt; &#039;history&#039;&lt;br /&gt;
	-- &#039;transcluded-from-blurb&#039; --&amp;gt; &lt;br /&gt;
	-- &#039;The above [[Wikipedia:Template documentation|documentation]] &lt;br /&gt;
	-- is [[Help:Transclusion|transcluded]] from $1.&#039;&lt;br /&gt;
	-- &#039;module-preload&#039; --&amp;gt; &#039;Template:Documentation/preload-module-doc&#039;&lt;br /&gt;
	-- &#039;create-link-display&#039; --&amp;gt; &#039;create&#039;&lt;br /&gt;
	-- &#039;create-module-doc-blurb&#039; --&amp;gt;&lt;br /&gt;
	-- &#039;You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].&#039;&lt;br /&gt;
	--]=]&lt;br /&gt;
	local docTitle = env.docTitle&lt;br /&gt;
	if not docTitle then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local ret&lt;br /&gt;
	if docTitle.exists then&lt;br /&gt;
		-- /doc exists; link to it.&lt;br /&gt;
		local docLink = makeWikilink(docTitle.prefixedText)&lt;br /&gt;
		local editUrl = docTitle:fullUrl{action = &#039;edit&#039;}&lt;br /&gt;
		local editDisplay = message(&#039;edit-link-display&#039;)&lt;br /&gt;
		local editLink = makeUrlLink(editUrl, editDisplay)&lt;br /&gt;
		local historyUrl = docTitle:fullUrl{action = &#039;history&#039;}&lt;br /&gt;
		local historyDisplay = message(&#039;history-link-display&#039;)&lt;br /&gt;
		local historyLink = makeUrlLink(historyUrl, historyDisplay)&lt;br /&gt;
		ret = message(&#039;transcluded-from-blurb&#039;, {docLink})&lt;br /&gt;
			.. &#039; &#039;&lt;br /&gt;
			.. makeToolbar(editLink, historyLink)&lt;br /&gt;
			.. &#039;&amp;lt;br /&amp;gt;&#039;&lt;br /&gt;
	elseif env.subjectSpace == 828 then&lt;br /&gt;
		-- /doc does not exist; ask to create it.&lt;br /&gt;
		local createUrl = docTitle:fullUrl{action = &#039;edit&#039;, preload = message(&#039;module-preload&#039;)}&lt;br /&gt;
		local createDisplay = message(&#039;create-link-display&#039;)&lt;br /&gt;
		local createLink = makeUrlLink(createUrl, createDisplay)&lt;br /&gt;
		ret = message(&#039;create-module-doc-blurb&#039;, {createLink})&lt;br /&gt;
			.. &#039;&amp;lt;br /&amp;gt;&#039;&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.makeExperimentBlurb(args, env)&lt;br /&gt;
	--[[&lt;br /&gt;
	-- Renders the text &amp;quot;Editors can experiment in this template&#039;s sandbox (edit | diff) and testcases (edit) pages.&amp;quot;&lt;br /&gt;
	-- @args - a table of arguments passed by the user&lt;br /&gt;
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment&lt;br /&gt;
	-- &lt;br /&gt;
	-- Messages:&lt;br /&gt;
	-- &#039;sandbox-link-display&#039; --&amp;gt; &#039;sandbox&#039;&lt;br /&gt;
	-- &#039;sandbox-edit-link-display&#039; --&amp;gt; &#039;edit&#039;&lt;br /&gt;
	-- &#039;compare-link-display&#039; --&amp;gt; &#039;diff&#039;&lt;br /&gt;
	-- &#039;module-sandbox-preload&#039; --&amp;gt; &#039;Template:Documentation/preload-module-sandbox&#039;&lt;br /&gt;
	-- &#039;template-sandbox-preload&#039; --&amp;gt; &#039;Template:Documentation/preload-sandbox&#039;&lt;br /&gt;
	-- &#039;sandbox-create-link-display&#039; --&amp;gt; &#039;create&#039;&lt;br /&gt;
	-- &#039;mirror-edit-summary&#039; --&amp;gt; &#039;Create sandbox version of $1&#039;&lt;br /&gt;
	-- &#039;mirror-link-display&#039; --&amp;gt; &#039;mirror&#039;&lt;br /&gt;
	-- &#039;mirror-link-preload&#039; --&amp;gt; &#039;Template:Documentation/mirror&#039;&lt;br /&gt;
	-- &#039;sandbox-link-display&#039; --&amp;gt; &#039;sandbox&#039;&lt;br /&gt;
	-- &#039;testcases-link-display&#039; --&amp;gt; &#039;testcases&#039;&lt;br /&gt;
	-- &#039;testcases-edit-link-display&#039;--&amp;gt; &#039;edit&#039;&lt;br /&gt;
	-- &#039;template-sandbox-preload&#039; --&amp;gt; &#039;Template:Documentation/preload-sandbox&#039;&lt;br /&gt;
	-- &#039;testcases-create-link-display&#039; --&amp;gt; &#039;create&#039;&lt;br /&gt;
	-- &#039;testcases-link-display&#039; --&amp;gt; &#039;testcases&#039;&lt;br /&gt;
	-- &#039;testcases-edit-link-display&#039; --&amp;gt; &#039;edit&#039;&lt;br /&gt;
	-- &#039;module-testcases-preload&#039; --&amp;gt; &#039;Template:Documentation/preload-module-testcases&#039;&lt;br /&gt;
	-- &#039;template-testcases-preload&#039; --&amp;gt; &#039;Template:Documentation/preload-testcases&#039;&lt;br /&gt;
	-- &#039;experiment-blurb-module&#039; --&amp;gt; &#039;Editors can experiment in this module&#039;s $1 and $2 pages.&#039;&lt;br /&gt;
	-- &#039;experiment-blurb-template&#039; --&amp;gt; &#039;Editors can experiment in this template&#039;s $1 and $2 pages.&#039;&lt;br /&gt;
	--]]&lt;br /&gt;
	local subjectSpace = env.subjectSpace&lt;br /&gt;
	local templateTitle = env.templateTitle&lt;br /&gt;
	local sandboxTitle = env.sandboxTitle&lt;br /&gt;
	local testcasesTitle = env.testcasesTitle&lt;br /&gt;
	local templatePage = templateTitle.prefixedText&lt;br /&gt;
	if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	-- Make links.&lt;br /&gt;
	local sandboxLinks, testcasesLinks&lt;br /&gt;
	if sandboxTitle.exists then&lt;br /&gt;
		local sandboxPage = sandboxTitle.prefixedText&lt;br /&gt;
		local sandboxDisplay = message(&#039;sandbox-link-display&#039;)&lt;br /&gt;
		local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)&lt;br /&gt;
		local sandboxEditUrl = sandboxTitle:fullUrl{action = &#039;edit&#039;}&lt;br /&gt;
		local sandboxEditDisplay = message(&#039;sandbox-edit-link-display&#039;)&lt;br /&gt;
		local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay)&lt;br /&gt;
		local compareUrl = env.compareUrl&lt;br /&gt;
		local compareLink&lt;br /&gt;
		if compareUrl then&lt;br /&gt;
			local compareDisplay = message(&#039;compare-link-display&#039;)&lt;br /&gt;
			compareLink = makeUrlLink(compareUrl, compareDisplay)&lt;br /&gt;
		end&lt;br /&gt;
		sandboxLinks = sandboxLink .. &#039; &#039; .. makeToolbar(sandboxEditLink, compareLink)&lt;br /&gt;
	else&lt;br /&gt;
		local sandboxPreload&lt;br /&gt;
		if subjectSpace == 828 then&lt;br /&gt;
			sandboxPreload = message(&#039;module-sandbox-preload&#039;)&lt;br /&gt;
		else&lt;br /&gt;
			sandboxPreload = message(&#039;template-sandbox-preload&#039;)&lt;br /&gt;
		end&lt;br /&gt;
		local sandboxCreateUrl = sandboxTitle:fullUrl{action = &#039;edit&#039;, preload = sandboxPreload}&lt;br /&gt;
		local sandboxCreateDisplay = message(&#039;sandbox-create-link-display&#039;)&lt;br /&gt;
		local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)&lt;br /&gt;
		local mirrorSummary = message(&#039;mirror-edit-summary&#039;, {makeWikilink(templatePage)})&lt;br /&gt;
		local mirrorPreload = message(&#039;mirror-link-preload&#039;)&lt;br /&gt;
		local mirrorUrl = sandboxTitle:fullUrl{action = &#039;edit&#039;, preload = mirrorPreload, summary = mirrorSummary}&lt;br /&gt;
		if subjectSpace == 828 then&lt;br /&gt;
			mirrorUrl = sandboxTitle:fullUrl{action = &#039;edit&#039;, preload = templateTitle.prefixedText, summary = mirrorSummary}&lt;br /&gt;
		end&lt;br /&gt;
		local mirrorDisplay = message(&#039;mirror-link-display&#039;)&lt;br /&gt;
		local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)&lt;br /&gt;
		sandboxLinks = message(&#039;sandbox-link-display&#039;) .. &#039; &#039; .. makeToolbar(sandboxCreateLink, mirrorLink)&lt;br /&gt;
	end&lt;br /&gt;
	if testcasesTitle.exists then&lt;br /&gt;
		local testcasesPage = testcasesTitle.prefixedText&lt;br /&gt;
		local testcasesDisplay = message(&#039;testcases-link-display&#039;)&lt;br /&gt;
		local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)&lt;br /&gt;
		local testcasesEditUrl = testcasesTitle:fullUrl{action = &#039;edit&#039;}&lt;br /&gt;
		local testcasesEditDisplay = message(&#039;testcases-edit-link-display&#039;)&lt;br /&gt;
		local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)&lt;br /&gt;
		-- for Modules, add testcases run link if exists&lt;br /&gt;
		if testcasesTitle.contentModel == &amp;quot;Scribunto&amp;quot;  and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then&lt;br /&gt;
			local testcasesRunLinkDisplay = message(&#039;testcases-run-link-display&#039;)&lt;br /&gt;
			local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)&lt;br /&gt;
			testcasesLinks = testcasesLink .. &#039; &#039; .. makeToolbar(testcasesEditLink, testcasesRunLink)&lt;br /&gt;
		else&lt;br /&gt;
			testcasesLinks = testcasesLink .. &#039; &#039; .. makeToolbar(testcasesEditLink)&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		local testcasesPreload&lt;br /&gt;
		if subjectSpace == 828 then&lt;br /&gt;
			testcasesPreload = message(&#039;module-testcases-preload&#039;)&lt;br /&gt;
		else&lt;br /&gt;
			testcasesPreload = message(&#039;template-testcases-preload&#039;)&lt;br /&gt;
		end&lt;br /&gt;
		local testcasesCreateUrl = testcasesTitle:fullUrl{action = &#039;edit&#039;, preload = testcasesPreload}&lt;br /&gt;
		local testcasesCreateDisplay = message(&#039;testcases-create-link-display&#039;)&lt;br /&gt;
		local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)&lt;br /&gt;
		testcasesLinks = message(&#039;testcases-link-display&#039;) .. &#039; &#039; .. makeToolbar(testcasesCreateLink)&lt;br /&gt;
	end&lt;br /&gt;
	local messageName&lt;br /&gt;
	if subjectSpace == 828 then&lt;br /&gt;
		messageName = &#039;experiment-blurb-module&#039;&lt;br /&gt;
	else&lt;br /&gt;
		messageName = &#039;experiment-blurb-template&#039;&lt;br /&gt;
	end&lt;br /&gt;
	return message(messageName, {sandboxLinks, testcasesLinks})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.makeCategoriesBlurb(args, env)&lt;br /&gt;
	--[[&lt;br /&gt;
	-- Generates the text &amp;quot;Please add categories to the /doc subpage.&amp;quot;&lt;br /&gt;
	-- @args - a table of arguments passed by the user&lt;br /&gt;
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment&lt;br /&gt;
	-- Messages:&lt;br /&gt;
	-- &#039;doc-link-display&#039; --&amp;gt; &#039;/doc&#039;&lt;br /&gt;
	-- &#039;add-categories-blurb&#039; --&amp;gt; &#039;Please add categories to the $1 subpage.&#039;&lt;br /&gt;
	--]]&lt;br /&gt;
	local docTitle = env.docTitle&lt;br /&gt;
	if not docTitle then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local docPathLink = makeWikilink(docTitle.prefixedText, message(&#039;doc-link-display&#039;))&lt;br /&gt;
	return message(&#039;add-categories-blurb&#039;, {docPathLink})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.makeSubpagesBlurb(args, env)&lt;br /&gt;
	--[[&lt;br /&gt;
	-- Generates the &amp;quot;Subpages of this template&amp;quot; link.&lt;br /&gt;
	-- @args - a table of arguments passed by the user&lt;br /&gt;
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment&lt;br /&gt;
	&lt;br /&gt;
	-- Messages:&lt;br /&gt;
	-- &#039;template-pagetype&#039; --&amp;gt; &#039;template&#039;&lt;br /&gt;
	-- &#039;module-pagetype&#039; --&amp;gt; &#039;module&#039;&lt;br /&gt;
	-- &#039;default-pagetype&#039; --&amp;gt; &#039;page&#039;&lt;br /&gt;
	-- &#039;subpages-link-display&#039; --&amp;gt; &#039;Subpages of this $1&#039;&lt;br /&gt;
	--]]&lt;br /&gt;
	local subjectSpace = env.subjectSpace&lt;br /&gt;
	local templateTitle = env.templateTitle&lt;br /&gt;
	if not subjectSpace or not templateTitle then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local pagetype&lt;br /&gt;
	if subjectSpace == 10 then&lt;br /&gt;
		pagetype = message(&#039;template-pagetype&#039;)&lt;br /&gt;
	elseif subjectSpace == 828 then&lt;br /&gt;
		pagetype = message(&#039;module-pagetype&#039;)&lt;br /&gt;
	else&lt;br /&gt;
		pagetype = message(&#039;default-pagetype&#039;)&lt;br /&gt;
	end&lt;br /&gt;
	local subpagesLink = makeWikilink(&lt;br /&gt;
		&#039;Special:PrefixIndex/&#039; .. templateTitle.prefixedText .. &#039;/&#039;,&lt;br /&gt;
		message(&#039;subpages-link-display&#039;, {pagetype})&lt;br /&gt;
	)&lt;br /&gt;
	return message(&#039;subpages-blurb&#039;, {subpagesLink})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.makePrintBlurb(args, env)&lt;br /&gt;
	--[=[&lt;br /&gt;
	-- Generates the blurb displayed when there is a print version of the template available.&lt;br /&gt;
	-- @args - a table of arguments passed by the user&lt;br /&gt;
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment&lt;br /&gt;
	--&lt;br /&gt;
	-- Messages:&lt;br /&gt;
	-- &#039;print-link-display&#039; --&amp;gt; &#039;/Print&#039;&lt;br /&gt;
	-- &#039;print-blurb&#039; --&amp;gt; &#039;A [[Help:Books/for experts#Improving the book layout|print version]]&#039;&lt;br /&gt;
	--		.. &#039; of this template exists at $1.&#039;&lt;br /&gt;
	--		.. &#039; If you make a change to this template, please update the print version as well.&#039;&lt;br /&gt;
	-- &#039;display-print-category&#039; --&amp;gt; true&lt;br /&gt;
	-- &#039;print-category&#039; --&amp;gt; &#039;Templates with print versions&#039;&lt;br /&gt;
	--]=]&lt;br /&gt;
	local printTitle = env.printTitle&lt;br /&gt;
	if not printTitle then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local ret&lt;br /&gt;
	if printTitle.exists then&lt;br /&gt;
		local printLink = makeWikilink(printTitle.prefixedText, message(&#039;print-link-display&#039;))&lt;br /&gt;
		ret = message(&#039;print-blurb&#039;, {printLink})&lt;br /&gt;
		local displayPrintCategory = message(&#039;display-print-category&#039;, nil, &#039;boolean&#039;)&lt;br /&gt;
		if displayPrintCategory then&lt;br /&gt;
			ret = ret .. makeCategoryLink(message(&#039;print-category&#039;))&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
-- Tracking categories&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function p.addTrackingCategories(env)&lt;br /&gt;
	--[[&lt;br /&gt;
	-- Check if {{documentation}} is transcluded on a /doc or /testcases page.&lt;br /&gt;
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment&lt;br /&gt;
	&lt;br /&gt;
	-- Messages:&lt;br /&gt;
	-- &#039;display-strange-usage-category&#039; --&amp;gt; true&lt;br /&gt;
	-- &#039;doc-subpage&#039; --&amp;gt; &#039;doc&#039;&lt;br /&gt;
	-- &#039;testcases-subpage&#039; --&amp;gt; &#039;testcases&#039;&lt;br /&gt;
	-- &#039;strange-usage-category&#039; --&amp;gt; &#039;Wikipedia pages with strange ((documentation)) usage&#039;&lt;br /&gt;
	-- &lt;br /&gt;
	-- /testcases pages in the module namespace are not categorised, as they may have&lt;br /&gt;
	-- {{documentation}} transcluded automatically.&lt;br /&gt;
	--]]&lt;br /&gt;
	local title = env.title&lt;br /&gt;
	local subjectSpace = env.subjectSpace&lt;br /&gt;
	if not title or not subjectSpace then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local subpage = title.subpageText&lt;br /&gt;
	local ret = &#039;&#039;&lt;br /&gt;
	if message(&#039;display-strange-usage-category&#039;, nil, &#039;boolean&#039;)&lt;br /&gt;
		and (&lt;br /&gt;
			subpage == message(&#039;doc-subpage&#039;)&lt;br /&gt;
			or subjectSpace ~= 828 and subpage == message(&#039;testcases-subpage&#039;)&lt;br /&gt;
		)&lt;br /&gt;
	then&lt;br /&gt;
		ret = ret .. makeCategoryLink(message(&#039;strange-usage-category&#039;))&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Citation/CS1/styles.css&amp;diff=615</id>
		<title>Module:Citation/CS1/styles.css</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Citation/CS1/styles.css&amp;diff=615"/>
		<updated>2021-04-26T10:44:08Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;/* Protection icon&lt;br /&gt;
the following line controls the page-protection icon in the upper right corner&lt;br /&gt;
it must remain within this comment&lt;br /&gt;
	{{sandbox other||{{pp-template}}}}&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
/* Overrides&lt;br /&gt;
Some wikis do not override user agent default styles for HTML &amp;lt;cite&amp;gt; and &amp;lt;q&amp;gt;,&lt;br /&gt;
unlike en.wp. On en.wp, keep these the same as [[MediaWiki:Common.css]]&lt;br /&gt;
*/&lt;br /&gt;
cite.citation {&lt;br /&gt;
	font-style: inherit; /* Remove italics for &amp;lt;cite&amp;gt; */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.citation q {&lt;br /&gt;
	quotes: &#039;&amp;quot;&#039; &#039;&amp;quot;&#039; &amp;quot;&#039;&amp;quot; &amp;quot;&#039;&amp;quot;; /* Straight quote marks for &amp;lt;q&amp;gt; */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* ID and URL access&lt;br /&gt;
Both core and Common.css have selector .mw-parser-output a[href$=&amp;quot;.pdf&amp;quot;].external&lt;br /&gt;
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need&lt;br /&gt;
to have specificity equal to a[href$=&amp;quot;.pdf&amp;quot;].external for locks to override PDF icon.&lt;br /&gt;
&lt;br /&gt;
the .id-lock-... selectors are for use by non-citation templates like {{Catalog lookup link}}&lt;br /&gt;
*/&lt;br /&gt;
.id-lock-free a,&lt;br /&gt;
.citation .cs1-lock-free a {&lt;br /&gt;
	background: linear-gradient(transparent, transparent),&lt;br /&gt;
		url(//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg)&lt;br /&gt;
		right 0.1em center/9px no-repeat;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.id-lock-limited a,&lt;br /&gt;
.id-lock-registration a,&lt;br /&gt;
.citation .cs1-lock-limited a,&lt;br /&gt;
.citation .cs1-lock-registration a {&lt;br /&gt;
	background: linear-gradient(transparent, transparent),&lt;br /&gt;
		url(//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg)&lt;br /&gt;
		right 0.1em center/9px no-repeat;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.id-lock-subscription a,&lt;br /&gt;
.citation .cs1-lock-subscription a {&lt;br /&gt;
	background: linear-gradient(transparent, transparent),&lt;br /&gt;
		url(//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg)&lt;br /&gt;
		right 0.1em center/9px no-repeat;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.cs1-subscription,&lt;br /&gt;
.cs1-registration {&lt;br /&gt;
	color: #555;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.cs1-subscription span,&lt;br /&gt;
.cs1-registration span {&lt;br /&gt;
	border-bottom: 1px dotted;&lt;br /&gt;
	cursor: help;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Wikisource&lt;br /&gt;
Wikisource icon when |chapter= or |title= is wikilinked to Wikisource&lt;br /&gt;
as in cite wikisource&lt;br /&gt;
*/&lt;br /&gt;
.cs1-ws-icon a {&lt;br /&gt;
	background: linear-gradient(transparent, transparent),&lt;br /&gt;
		url(//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg)&lt;br /&gt;
		right 0.1em center/12px no-repeat;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Errors and maintenance */&lt;br /&gt;
code.cs1-code {&lt;br /&gt;
	/* &amp;lt;code&amp;gt;...&amp;lt;/code&amp;gt; style override: mediawiki&#039;s css definition is specified here:&lt;br /&gt;
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/&lt;br /&gt;
		69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199&lt;br /&gt;
	*/&lt;br /&gt;
	color: inherit;&lt;br /&gt;
	background: inherit;&lt;br /&gt;
	border: none; /* this maybe can be inherit. MDN says yes, code editor says no */&lt;br /&gt;
	padding: inherit;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.cs1-hidden-error {&lt;br /&gt;
	display: none;&lt;br /&gt;
	font-size: 100%;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.cs1-visible-error {&lt;br /&gt;
	font-size: 100%;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.cs1-maint {&lt;br /&gt;
	display: none;&lt;br /&gt;
	color: #33aa33;&lt;br /&gt;
	margin-left: 0.3em;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Small text size&lt;br /&gt;
Set small text size in one place. 0.95 (here) * 0.9 (from references list) is&lt;br /&gt;
~0.85, which is the lower bound for size for accessibility. Old styling for this&lt;br /&gt;
was just 0.85. We could write the rule so that when this template is inside&lt;br /&gt;
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */&lt;br /&gt;
.cs1-format {&lt;br /&gt;
	font-size: 95%;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* kerning */&lt;br /&gt;
.cs1-kern-left,&lt;br /&gt;
.cs1-kern-wl-left {&lt;br /&gt;
	padding-left: 0.2em;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.cs1-kern-right,&lt;br /&gt;
.cs1-kern-wl-right {&lt;br /&gt;
	padding-right: 0.2em;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* selflinks – avoid bold font style when cs1|2 template links to the current page */&lt;br /&gt;
.citation .mw-selflink {&lt;br /&gt;
	font-weight: inherit;&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Citation/CS1/doc&amp;diff=613</id>
		<title>Module:Citation/CS1/doc</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Citation/CS1/doc&amp;diff=613"/>
		<updated>2021-04-26T10:44:07Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;section begin=header /&amp;gt;&lt;br /&gt;
{{sandbox other||&lt;br /&gt;
{{#switch:{{FULLPAGENAME}}&lt;br /&gt;
|Module:Citation/CS1={{high-risk}} {{Uses TemplateStyles|Module:Citation/CS1/styles.css}}&lt;br /&gt;
|Module:Citation/CS1/Configuration={{high-risk}}&lt;br /&gt;
|Module:Citation/CS1/Whitelist={{high-risk}}&lt;br /&gt;
|Module:Citation/CS1/Date validation={{high-risk}}&lt;br /&gt;
|Module:Citation/CS1/Identifiers={{high-risk}}&lt;br /&gt;
|Module:Citation/CS1/Utilities={{high-risk}}&lt;br /&gt;
|Module:Citation/CS1/COinS={{high-risk}}&lt;br /&gt;
|Module:Citation/CS1/Suggestions={{high-use}}&lt;br /&gt;
}}&lt;br /&gt;
{{Module rating|p}}}}&amp;lt;!-- if pagename does not contain sandbox --&amp;gt;&lt;br /&gt;
&amp;lt;section end=header /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This module and associated sub-modules support the {{cs1}} and {{cs2}} citation templates.  In general, it is not intended to be called directly, but is called by one of the core CS1 and CS2 templates.&lt;br /&gt;
&amp;lt;section begin=module_components_table /&amp;gt;&lt;br /&gt;
These files comprise the module support for CS1|2 citation templates:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin: 1em auto 1em auto;&amp;quot;&lt;br /&gt;
|+CS1 {{pipe}} CS2 modules&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|live!!colspan=&amp;quot;2&amp;quot;|sandbox!!diff!!description&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;8&amp;quot;| [[File:Full-protection-shackle.svg|20px|alt=Gold padlock|link=|sysop]] || [[Module:Citation/CS1]] || [[Module:Citation/CS1/sandbox]] || {{Plain link|url=https://en.wikipedia.org/w/index.php?title=Module:Citation/CS1/sandbox&amp;amp;action=edit|name=[edit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;}} ||[https://en.wikipedia.org/wiki/Special:ComparePages?page1=Module%3ACitation%2FCS1&amp;amp;rev1=&amp;amp;page2=Module%3ACitation%2FCS1%2Fsandbox&amp;amp;rev2=&amp;amp;action=&amp;amp;diffonly=&amp;amp;unhide= diff]|| Rendering and support functions&lt;br /&gt;
|-&lt;br /&gt;
| [[Module:Citation/CS1/Configuration]] || [[Module:Citation/CS1/Configuration/sandbox]] || {{Plain link|url=https://en.wikipedia.org/w/index.php?title=Module:Citation/CS1/Configuration/sandbox&amp;amp;action=edit|name=[edit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;}} ||[https://en.wikipedia.org/wiki/Special:ComparePages?page1=Module%3ACitation%2FCS1%2FConfiguration&amp;amp;rev1=&amp;amp;page2=Module%3ACitation%2FCS1%2FConfiguration%2Fsandbox&amp;amp;rev2=&amp;amp;action=&amp;amp;diffonly=&amp;amp;unhide= diff]|| Translation tables; error and identifier handlers&lt;br /&gt;
|-&lt;br /&gt;
| [[Module:Citation/CS1/Whitelist]] || [[Module:Citation/CS1/Whitelist/sandbox]] || {{Plain link|url=https://en.wikipedia.org/w/index.php?title=Module:Citation/CS1/Whitelist/sandbox&amp;amp;action=edit|name=[edit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;}} ||[https://en.wikipedia.org/wiki/Special:ComparePages?page1=Module%3ACitation%2FCS1%2FWhitelist&amp;amp;rev1=&amp;amp;page2=Module%3ACitation%2FCS1%2FWhitelist%2Fsandbox&amp;amp;rev2=&amp;amp;action=&amp;amp;diffonly=&amp;amp;unhide= diff]|| List of active and deprecated CS1{{pipe}}2 parameters&lt;br /&gt;
|-&lt;br /&gt;
| [[Module:Citation/CS1/Date validation]] || [[Module:Citation/CS1/Date validation/sandbox]] || {{Plain link|url=https://en.wikipedia.org/w/index.php?title=Module:Citation/CS1/Date_validation/sandbox&amp;amp;action=edit|name=[edit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;}} ||[https://en.wikipedia.org/wiki/Special:ComparePages?page1=Module%3ACitation%2FCS1%2FDate+validation&amp;amp;rev1=&amp;amp;page2=Module%3ACitation%2FCS1%2FDate+validation%2Fsandbox&amp;amp;rev2=&amp;amp;action=&amp;amp;diffonly=&amp;amp;unhide= diff] || Date format validation functions&lt;br /&gt;
|-&lt;br /&gt;
| [[Module:Citation/CS1/Identifiers]] || [[Module:Citation/CS1/Identifiers/sandbox]] || {{Plain link|url=https://en.wikipedia.org/w/index.php?title=Module:Citation/CS1/Identifiers/sandbox&amp;amp;action=edit|name=[edit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;}} ||[https://en.wikipedia.org/wiki/Special:ComparePages?page1=Module%3ACitation%2FCS1%2FIdentifiers&amp;amp;rev1=&amp;amp;page2=Module%3ACitation%2FCS1%2FIdentifiers%2Fsandbox&amp;amp;rev2=&amp;amp;action=&amp;amp;diffonly=&amp;amp;unhide= diff]|| Functions that support the named identifiers (ISBN, DOI, PMID, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| [[Module:Citation/CS1/Utilities]] || [[Module:Citation/CS1/Utilities/sandbox]] || {{Plain link|url=https://en.wikipedia.org/w/index.php?title=Module:Citation/CS1/Utilities/sandbox&amp;amp;action=edit|name=[edit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;}} ||[https://en.wikipedia.org/wiki/Special:ComparePages?page1=Module%3ACitation%2FCS1%2FUtilities&amp;amp;rev1=&amp;amp;page2=Module%3ACitation%2FCS1%2FUtilities%2Fsandbox&amp;amp;rev2=&amp;amp;action=&amp;amp;diffonly=&amp;amp;unhide= diff]|| Common functions and tables&lt;br /&gt;
|-&lt;br /&gt;
| [[Module:Citation/CS1/COinS]] || [[Module:Citation/CS1/COinS/sandbox]] || {{Plain link|url=https://en.wikipedia.org/w/index.php?title=Module:Citation/CS1/COinS/sandbox&amp;amp;action=edit|name=[edit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;}} ||[https://en.wikipedia.org/wiki/Special:ComparePages?page1=Module%3ACitation%2FCS1%2FCOinS&amp;amp;rev1=&amp;amp;page2=Module%3ACitation%2FCS1%2FCOinS%2Fsandbox&amp;amp;rev2=&amp;amp;action=&amp;amp;diffonly=&amp;amp;unhide= diff]|| Functions that render a CS1{{pipe}}2 template&#039;s metadata&lt;br /&gt;
|-&lt;br /&gt;
| [[Module:Citation/CS1/styles.css]] || [[Module:Citation/CS1/sandbox/styles.css]] || {{Plain link|url=https://en.wikipedia.org/w/index.php?title=Module:Citation/CS1/sandbox/styles.css&amp;amp;action=edit|name=[edit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;}} ||[https://en.wikipedia.org/wiki/Special:ComparePages?page1=Module%3ACitation%2FCS1%2Fstyles.css&amp;amp;rev1=&amp;amp;page2=Module%3ACitation%2FCS1%2Fsandbox%2Fstyles.css&amp;amp;rev2=&amp;amp;action=&amp;amp;diffonly=&amp;amp;unhide= diff]|| [[CSS]] styles applied to the CS1{{pipe}}2 templates&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Semi-protection-shackle.svg|20px|alt=Silver padlock|link=|auto confirmed]] || [[Module:Citation/CS1/Suggestions]] || [[Module:Citation/CS1/Suggestions/sandbox]] || {{Plain link|url=https://en.wikipedia.org/w/index.php?title=Module:Citation/CS1/Suggestions/sandbox&amp;amp;action=edit|name=[edit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;}} ||[https://en.wikipedia.org/wiki/Special:ComparePages?page1=Module%3ACitation%2FCS1%2FSuggestions&amp;amp;rev1=&amp;amp;page2=Module%3ACitation%2FCS1%2FSuggestions%2Fsandbox&amp;amp;rev2=&amp;amp;action=&amp;amp;diffonly=&amp;amp;unhide= diff]|| List that maps common erroneous parameter names to valid parameter names&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;section end=module_components_table /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other documentation:&lt;br /&gt;
* [[Module talk:Citation/CS1/Feature requests]]&lt;br /&gt;
* [[Module talk:Citation/CS1/COinS]]&lt;br /&gt;
* [[Module:Cs1 documentation support]] – a set of functions (some experimental) that extract information from the module suite for the purpose of documenting CS1|2&lt;br /&gt;
** [[Module:Citation/CS1/doc/Category list]] – lists of category names taken directly from [[Module:Citation/CS1/Configuration]] and [[Module:Citation/CS1/Configuration/sandbox]]&lt;br /&gt;
testcases&lt;br /&gt;
*[[Module:Citation/CS1/testcases]] ([[Module talk:Citation/CS1/testcases|run]])&lt;br /&gt;
*[[Module:Citation/CS1/testcases/errors]] ([[Module talk:Citation/CS1/testcases/errors|run]]) – error and maintenance messaging&lt;br /&gt;
*[[Module:Citation/CS1/testcases/dates]] ([[Module talk:Citation/CS1/testcases/dates|run]]) – date validation&lt;br /&gt;
*[[Module:Citation/CS1/testcases/identifiers]] ([[Module talk:Citation/CS1/testcases/identifiers|run]]) – identifiers&lt;br /&gt;
*[[Module:Citation/CS1/testcases/anchor]] ([[Module talk:Citation/CS1/testcases/anchor|run]]) – CITEREF anchors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{sandbox other||&lt;br /&gt;
[[Category:Modules that add a tracking category]]&lt;br /&gt;
{{#ifeq:{{SUBPAGENAME}}|Identifiers|[[Category:Modules using data from Wikidata]]}}&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Arguments&amp;diff=611</id>
		<title>Module:Arguments</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Arguments&amp;diff=611"/>
		<updated>2021-04-26T10:44:04Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;-- This module provides easy processing of arguments passed to Scribunto from&lt;br /&gt;
-- #invoke. It is intended for use by other Lua modules, and should not be&lt;br /&gt;
-- called from #invoke directly.&lt;br /&gt;
&lt;br /&gt;
local libraryUtil = require(&#039;libraryUtil&#039;)&lt;br /&gt;
local checkType = libraryUtil.checkType&lt;br /&gt;
&lt;br /&gt;
local arguments = {}&lt;br /&gt;
&lt;br /&gt;
-- Generate four different tidyVal functions, so that we don&#039;t have to check the&lt;br /&gt;
-- options every time we call it.&lt;br /&gt;
&lt;br /&gt;
local function tidyValDefault(key, val)&lt;br /&gt;
	if type(val) == &#039;string&#039; then&lt;br /&gt;
		val = val:match(&#039;^%s*(.-)%s*$&#039;)&lt;br /&gt;
		if val == &#039;&#039; then&lt;br /&gt;
			return nil&lt;br /&gt;
		else&lt;br /&gt;
			return val&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return val&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function tidyValTrimOnly(key, val)&lt;br /&gt;
	if type(val) == &#039;string&#039; then&lt;br /&gt;
		return val:match(&#039;^%s*(.-)%s*$&#039;)&lt;br /&gt;
	else&lt;br /&gt;
		return val&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function tidyValRemoveBlanksOnly(key, val)&lt;br /&gt;
	if type(val) == &#039;string&#039; then&lt;br /&gt;
		if val:find(&#039;%S&#039;) then&lt;br /&gt;
			return val&lt;br /&gt;
		else&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return val&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function tidyValNoChange(key, val)&lt;br /&gt;
	return val&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function matchesTitle(given, title)&lt;br /&gt;
	local tp = type( given )&lt;br /&gt;
	return (tp == &#039;string&#039; or tp == &#039;number&#039;) and mw.title.new( given ).prefixedText == title&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local translate_mt = { __index = function(t, k) return k end }&lt;br /&gt;
&lt;br /&gt;
function arguments.getArgs(frame, options)&lt;br /&gt;
	checkType(&#039;getArgs&#039;, 1, frame, &#039;table&#039;, true)&lt;br /&gt;
	checkType(&#039;getArgs&#039;, 2, options, &#039;table&#039;, true)&lt;br /&gt;
	frame = frame or {}&lt;br /&gt;
	options = options or {}&lt;br /&gt;
&lt;br /&gt;
	--[[&lt;br /&gt;
	-- Set up argument translation.&lt;br /&gt;
	--]]&lt;br /&gt;
	options.translate = options.translate or {}&lt;br /&gt;
	if getmetatable(options.translate) == nil then&lt;br /&gt;
		setmetatable(options.translate, translate_mt)&lt;br /&gt;
	end&lt;br /&gt;
	if options.backtranslate == nil then&lt;br /&gt;
		options.backtranslate = {}&lt;br /&gt;
		for k,v in pairs(options.translate) do&lt;br /&gt;
			options.backtranslate[v] = k&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if options.backtranslate and getmetatable(options.backtranslate) == nil then&lt;br /&gt;
		setmetatable(options.backtranslate, {&lt;br /&gt;
			__index = function(t, k)&lt;br /&gt;
				if options.translate[k] ~= k then&lt;br /&gt;
					return nil&lt;br /&gt;
				else&lt;br /&gt;
					return k&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		})&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	--[[&lt;br /&gt;
	-- Get the argument tables. If we were passed a valid frame object, get the&lt;br /&gt;
	-- frame arguments (fargs) and the parent frame arguments (pargs), depending&lt;br /&gt;
	-- on the options set and on the parent frame&#039;s availability. If we weren&#039;t&lt;br /&gt;
	-- passed a valid frame object, we are being called from another Lua module&lt;br /&gt;
	-- or from the debug console, so assume that we were passed a table of args&lt;br /&gt;
	-- directly, and assign it to a new variable (luaArgs).&lt;br /&gt;
	--]]&lt;br /&gt;
	local fargs, pargs, luaArgs&lt;br /&gt;
	if type(frame.args) == &#039;table&#039; and type(frame.getParent) == &#039;function&#039; then&lt;br /&gt;
		if options.wrappers then&lt;br /&gt;
			--[[&lt;br /&gt;
			-- The wrappers option makes Module:Arguments look up arguments in&lt;br /&gt;
			-- either the frame argument table or the parent argument table, but&lt;br /&gt;
			-- not both. This means that users can use either the #invoke syntax&lt;br /&gt;
			-- or a wrapper template without the loss of performance associated&lt;br /&gt;
			-- with looking arguments up in both the frame and the parent frame.&lt;br /&gt;
			-- Module:Arguments will look up arguments in the parent frame&lt;br /&gt;
			-- if it finds the parent frame&#039;s title in options.wrapper;&lt;br /&gt;
			-- otherwise it will look up arguments in the frame object passed&lt;br /&gt;
			-- to getArgs.&lt;br /&gt;
			--]]&lt;br /&gt;
			local parent = frame:getParent()&lt;br /&gt;
			if not parent then&lt;br /&gt;
				fargs = frame.args&lt;br /&gt;
			else&lt;br /&gt;
				local title = parent:getTitle():gsub(&#039;/sandbox$&#039;, &#039;&#039;)&lt;br /&gt;
				local found = false&lt;br /&gt;
				if matchesTitle(options.wrappers, title) then&lt;br /&gt;
					found = true&lt;br /&gt;
				elseif type(options.wrappers) == &#039;table&#039; then&lt;br /&gt;
					for _,v in pairs(options.wrappers) do&lt;br /&gt;
						if matchesTitle(v, title) then&lt;br /&gt;
							found = true&lt;br /&gt;
							break&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				-- We test for false specifically here so that nil (the default) acts like true.&lt;br /&gt;
				if found or options.frameOnly == false then&lt;br /&gt;
					pargs = parent.args&lt;br /&gt;
				end&lt;br /&gt;
				if not found or options.parentOnly == false then&lt;br /&gt;
					fargs = frame.args&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			-- options.wrapper isn&#039;t set, so check the other options.&lt;br /&gt;
			if not options.parentOnly then&lt;br /&gt;
				fargs = frame.args&lt;br /&gt;
			end&lt;br /&gt;
			if not options.frameOnly then&lt;br /&gt;
				local parent = frame:getParent()&lt;br /&gt;
				pargs = parent and parent.args or nil&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if options.parentFirst then&lt;br /&gt;
			fargs, pargs = pargs, fargs&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		luaArgs = frame&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Set the order of precedence of the argument tables. If the variables are&lt;br /&gt;
	-- nil, nothing will be added to the table, which is how we avoid clashes&lt;br /&gt;
	-- between the frame/parent args and the Lua args.&lt;br /&gt;
	local argTables = {fargs}&lt;br /&gt;
	argTables[#argTables + 1] = pargs&lt;br /&gt;
	argTables[#argTables + 1] = luaArgs&lt;br /&gt;
&lt;br /&gt;
	--[[&lt;br /&gt;
	-- Generate the tidyVal function. If it has been specified by the user, we&lt;br /&gt;
	-- use that; if not, we choose one of four functions depending on the&lt;br /&gt;
	-- options chosen. This is so that we don&#039;t have to call the options table&lt;br /&gt;
	-- every time the function is called.&lt;br /&gt;
	--]]&lt;br /&gt;
	local tidyVal = options.valueFunc&lt;br /&gt;
	if tidyVal then&lt;br /&gt;
		if type(tidyVal) ~= &#039;function&#039; then&lt;br /&gt;
			error(&lt;br /&gt;
				&amp;quot;bad value assigned to option &#039;valueFunc&#039;&amp;quot;&lt;br /&gt;
					.. &#039;(function expected, got &#039;&lt;br /&gt;
					.. type(tidyVal)&lt;br /&gt;
					.. &#039;)&#039;,&lt;br /&gt;
				2&lt;br /&gt;
			)&lt;br /&gt;
		end&lt;br /&gt;
	elseif options.trim ~= false then&lt;br /&gt;
		if options.removeBlanks ~= false then&lt;br /&gt;
			tidyVal = tidyValDefault&lt;br /&gt;
		else&lt;br /&gt;
			tidyVal = tidyValTrimOnly&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		if options.removeBlanks ~= false then&lt;br /&gt;
			tidyVal = tidyValRemoveBlanksOnly&lt;br /&gt;
		else&lt;br /&gt;
			tidyVal = tidyValNoChange&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	--[[&lt;br /&gt;
	-- Set up the args, metaArgs and nilArgs tables. args will be the one&lt;br /&gt;
	-- accessed from functions, and metaArgs will hold the actual arguments. Nil&lt;br /&gt;
	-- arguments are memoized in nilArgs, and the metatable connects all of them&lt;br /&gt;
	-- together.&lt;br /&gt;
	--]]&lt;br /&gt;
	local args, metaArgs, nilArgs, metatable = {}, {}, {}, {}&lt;br /&gt;
	setmetatable(args, metatable)&lt;br /&gt;
&lt;br /&gt;
	local function mergeArgs(tables)&lt;br /&gt;
		--[[&lt;br /&gt;
		-- Accepts multiple tables as input and merges their keys and values&lt;br /&gt;
		-- into one table. If a value is already present it is not overwritten;&lt;br /&gt;
		-- tables listed earlier have precedence. We are also memoizing nil&lt;br /&gt;
		-- values, which can be overwritten if they are &#039;s&#039; (soft).&lt;br /&gt;
		--]]&lt;br /&gt;
		for _, t in ipairs(tables) do&lt;br /&gt;
			for key, val in pairs(t) do&lt;br /&gt;
				if metaArgs[key] == nil and nilArgs[key] ~= &#039;h&#039; then&lt;br /&gt;
					local tidiedVal = tidyVal(key, val)&lt;br /&gt;
					if tidiedVal == nil then&lt;br /&gt;
						nilArgs[key] = &#039;s&#039;&lt;br /&gt;
					else&lt;br /&gt;
						metaArgs[key] = tidiedVal&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	--[[&lt;br /&gt;
	-- Define metatable behaviour. Arguments are memoized in the metaArgs table,&lt;br /&gt;
	-- and are only fetched from the argument tables once. Fetching arguments&lt;br /&gt;
	-- from the argument tables is the most resource-intensive step in this&lt;br /&gt;
	-- module, so we try and avoid it where possible. For this reason, nil&lt;br /&gt;
	-- arguments are also memoized, in the nilArgs table. Also, we keep a record&lt;br /&gt;
	-- in the metatable of when pairs and ipairs have been called, so we do not&lt;br /&gt;
	-- run pairs and ipairs on the argument tables more than once. We also do&lt;br /&gt;
	-- not run ipairs on fargs and pargs if pairs has already been run, as all&lt;br /&gt;
	-- the arguments will already have been copied over.&lt;br /&gt;
	--]]&lt;br /&gt;
&lt;br /&gt;
	metatable.__index = function (t, key)&lt;br /&gt;
		--[[&lt;br /&gt;
		-- Fetches an argument when the args table is indexed. First we check&lt;br /&gt;
		-- to see if the value is memoized, and if not we try and fetch it from&lt;br /&gt;
		-- the argument tables. When we check memoization, we need to check&lt;br /&gt;
		-- metaArgs before nilArgs, as both can be non-nil at the same time.&lt;br /&gt;
		-- If the argument is not present in metaArgs, we also check whether&lt;br /&gt;
		-- pairs has been run yet. If pairs has already been run, we return nil.&lt;br /&gt;
		-- This is because all the arguments will have already been copied into&lt;br /&gt;
		-- metaArgs by the mergeArgs function, meaning that any other arguments&lt;br /&gt;
		-- must be nil.&lt;br /&gt;
		--]]&lt;br /&gt;
		if type(key) == &#039;string&#039; then&lt;br /&gt;
			key = options.translate[key]&lt;br /&gt;
		end&lt;br /&gt;
		local val = metaArgs[key]&lt;br /&gt;
		if val ~= nil then&lt;br /&gt;
			return val&lt;br /&gt;
		elseif metatable.donePairs or nilArgs[key] then&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
		for _, argTable in ipairs(argTables) do&lt;br /&gt;
			local argTableVal = tidyVal(key, argTable[key])&lt;br /&gt;
			if argTableVal ~= nil then&lt;br /&gt;
				metaArgs[key] = argTableVal&lt;br /&gt;
				return argTableVal&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		nilArgs[key] = &#039;h&#039;&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	metatable.__newindex = function (t, key, val)&lt;br /&gt;
		-- This function is called when a module tries to add a new value to the&lt;br /&gt;
		-- args table, or tries to change an existing value.&lt;br /&gt;
		if type(key) == &#039;string&#039; then&lt;br /&gt;
			key = options.translate[key]&lt;br /&gt;
		end&lt;br /&gt;
		if options.readOnly then&lt;br /&gt;
			error(&lt;br /&gt;
				&#039;could not write to argument table key &amp;quot;&#039;&lt;br /&gt;
					.. tostring(key)&lt;br /&gt;
					.. &#039;&amp;quot;; the table is read-only&#039;,&lt;br /&gt;
				2&lt;br /&gt;
			)&lt;br /&gt;
		elseif options.noOverwrite and args[key] ~= nil then&lt;br /&gt;
			error(&lt;br /&gt;
				&#039;could not write to argument table key &amp;quot;&#039;&lt;br /&gt;
					.. tostring(key)&lt;br /&gt;
					.. &#039;&amp;quot;; overwriting existing arguments is not permitted&#039;,&lt;br /&gt;
				2&lt;br /&gt;
			)&lt;br /&gt;
		elseif val == nil then&lt;br /&gt;
			--[[&lt;br /&gt;
			-- If the argument is to be overwritten with nil, we need to erase&lt;br /&gt;
			-- the value in metaArgs, so that __index, __pairs and __ipairs do&lt;br /&gt;
			-- not use a previous existing value, if present; and we also need&lt;br /&gt;
			-- to memoize the nil in nilArgs, so that the value isn&#039;t looked&lt;br /&gt;
			-- up in the argument tables if it is accessed again.&lt;br /&gt;
			--]]&lt;br /&gt;
			metaArgs[key] = nil&lt;br /&gt;
			nilArgs[key] = &#039;h&#039;&lt;br /&gt;
		else&lt;br /&gt;
			metaArgs[key] = val&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local function translatenext(invariant)&lt;br /&gt;
		local k, v = next(invariant.t, invariant.k)&lt;br /&gt;
		invariant.k = k&lt;br /&gt;
		if k == nil then&lt;br /&gt;
			return nil&lt;br /&gt;
		elseif type(k) ~= &#039;string&#039; or not options.backtranslate then&lt;br /&gt;
			return k, v&lt;br /&gt;
		else&lt;br /&gt;
			local backtranslate = options.backtranslate[k]&lt;br /&gt;
			if backtranslate == nil then&lt;br /&gt;
				-- Skip this one. This is a tail call, so this won&#039;t cause stack overflow&lt;br /&gt;
				return translatenext(invariant)&lt;br /&gt;
			else&lt;br /&gt;
				return backtranslate, v&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	metatable.__pairs = function ()&lt;br /&gt;
		-- Called when pairs is run on the args table.&lt;br /&gt;
		if not metatable.donePairs then&lt;br /&gt;
			mergeArgs(argTables)&lt;br /&gt;
			metatable.donePairs = true&lt;br /&gt;
		end&lt;br /&gt;
		return translatenext, { t = metaArgs }&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local function inext(t, i)&lt;br /&gt;
		-- This uses our __index metamethod&lt;br /&gt;
		local v = t[i + 1]&lt;br /&gt;
		if v ~= nil then&lt;br /&gt;
			return i + 1, v&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	metatable.__ipairs = function (t)&lt;br /&gt;
		-- Called when ipairs is run on the args table.&lt;br /&gt;
		return inext, t, 0&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return args&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return arguments&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Uses_TemplateStyles&amp;diff=609</id>
		<title>Template:Uses TemplateStyles</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Uses_TemplateStyles&amp;diff=609"/>
		<updated>2021-04-26T10:44:04Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;includeonly&amp;gt;{{#invoke:Uses TemplateStyles|main}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;&lt;br /&gt;
{{Uses TemplateStyles|Template:Uses TemplateStyles/example.css|nocat=true}}&lt;br /&gt;
{{documentation}}&lt;br /&gt;
&amp;lt;!-- Categories go on the /doc subpage and interwikis go on Wikidata. --&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Sandbox_other&amp;diff=607</id>
		<title>Template:Sandbox other</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Sandbox_other&amp;diff=607"/>
		<updated>2021-04-26T10:44:04Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#if:{{#ifeq:{{#invoke:String|sublength|s={{SUBPAGENAME}}|i=0|len=7}}|sandbox|1}}{{#ifeq:{{SUBPAGENAME}}|doc|1}}{{#invoke:String|match|{{PAGENAME}}|/sandbox/styles.css$|plain=false|nomatch=}}|{{{1|}}}|{{{2|}}}}}&amp;lt;!--&lt;br /&gt;
--&amp;gt;&amp;lt;noinclude&amp;gt;{{documentation}}&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Plain_link&amp;diff=605</id>
		<title>Template:Plain link</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Plain_link&amp;diff=605"/>
		<updated>2021-04-26T10:44:04Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt;{{SAFESUBST:&amp;lt;noinclude /&amp;gt;#if:{{{2|{{{NAME|{{{name|}}}}}}}}}&lt;br /&gt;
 |[{{{1|{{{URL|{{{url}}}}}}}}} {{{2|{{{NAME|{{{name|}}}}}}}}}]&lt;br /&gt;
 |[{{{1|{{{URL|{{{url}}}}}}}}}]&lt;br /&gt;
}}&amp;lt;/span&amp;gt;&amp;lt;noinclude&amp;gt;&lt;br /&gt;
{{documentation}}&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Pipe&amp;diff=603</id>
		<title>Template:Pipe</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Pipe&amp;diff=603"/>
		<updated>2021-04-26T10:44:04Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;amp;#124;&amp;lt;noinclude&amp;gt;&lt;br /&gt;
{{documentation}}&lt;br /&gt;
&amp;lt;!-- Add categories and interwikis to the /doc subpage, not here! --&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Ombox&amp;diff=601</id>
		<title>Template:Ombox</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Ombox&amp;diff=601"/>
		<updated>2021-04-26T10:44:04Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#invoke:Message box|ombox}}&amp;lt;noinclude&amp;gt;&lt;br /&gt;
{{documentation}}&lt;br /&gt;
&amp;lt;!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Module_rating&amp;diff=599</id>
		<title>Template:Module rating</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Module_rating&amp;diff=599"/>
		<updated>2021-04-26T10:44:04Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;includeonly&amp;gt;{{Module other|{{ombox&lt;br /&gt;
 | type      = notice&lt;br /&gt;
 | image     = {{#switch: {{{1|}}}&lt;br /&gt;
   | pre-alpha | prealpha | pa = [[File:Ambox warning blue construction.svg|40x40px|link=|alt=Pre-alpha]]&lt;br /&gt;
   | alpha | a                 = [[File:Alpha lowercase.svg|26x26px|link=|alt=Alpha]]&lt;br /&gt;
   | beta | b                  = [[File:Greek lc beta.svg|40x40px|link=|alt=Beta]]&lt;br /&gt;
   | release | r | general | g = [[File:Green check.svg|40x40px|link=|alt=Ready for use]]&lt;br /&gt;
   | protected | protect | p   = [[File:{{#switch:{{#invoke:Effective protection level|edit|{{#switch:{{SUBPAGENAME}}|doc|sandbox={{FULLBASEPAGENAME}}|{{FULLPAGENAME}}}}}}|autoconfirmed=Semi|extendedconfirmed=Extended|accountcreator|templateeditor=Template|#default=Full}}-protection-shackle.svg|40x40px|link=|alt=Protected]]&lt;br /&gt;
   | semiprotected | semiprotect | semi =[[File:Semi-protection-shackle.svg|40x40px|link=|alt=Semi-protected]]&lt;br /&gt;
  }}&lt;br /&gt;
 | style     = &lt;br /&gt;
 | textstyle = &lt;br /&gt;
 | text      = {{#switch: {{{1|}}}&lt;br /&gt;
   | pre-alpha | prealpha | pa = This module is rated as [[:Category:Modules in pre-alpha development|pre-alpha]]. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure.&amp;lt;!--&lt;br /&gt;
   --&amp;gt;{{#switch: {{SUBPAGENAME}}|doc|sandbox=&amp;lt;!-- No category for /doc or /sandbox subpages --&amp;gt;&lt;br /&gt;
       | {{#ifeq: {{{nocat|}}} | true | &amp;lt;!-- No category if user sets nocat=true --&amp;gt; | [[Category:Modules in pre-alpha development|{{PAGENAME}}]] }}&lt;br /&gt;
      }}&lt;br /&gt;
   | alpha | a                 = This module is rated as [[:Category:Modules in alpha|alpha]]. It is ready for third-party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome.&amp;lt;!--&lt;br /&gt;
   --&amp;gt;{{#switch: {{SUBPAGENAME}}|doc|sandbox=&amp;lt;!-- No category for /doc or /sandbox subpages --&amp;gt;&lt;br /&gt;
       | {{#ifeq: {{{nocat|}}} | true | &amp;lt;!-- No category if user sets nocat=true --&amp;gt; | [[Category:Modules in alpha|{{PAGENAME}}]] }}&lt;br /&gt;
      }}&lt;br /&gt;
   | beta | b                  = This module is rated as [[:Category:Modules in beta|beta]], and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected.&amp;lt;!--&lt;br /&gt;
   --&amp;gt;{{#switch: {{SUBPAGENAME}}|doc|sandbox=&amp;lt;!-- No category for /doc or /sandbox subpages --&amp;gt;&lt;br /&gt;
       | {{#ifeq: {{{nocat|}}} | true | &amp;lt;!-- No category if user sets nocat=true --&amp;gt; | [[Category:Modules in beta|{{PAGENAME}}]] }}&lt;br /&gt;
      }}&lt;br /&gt;
   | release | r | general | g = This module is rated as [[:Category:Modules for general use|ready for general use]]. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by [[Wikipedia:Template sandbox and test cases|sandbox testing]] rather than repeated trial-and-error editing.&amp;lt;!--&lt;br /&gt;
   --&amp;gt;{{#switch: {{SUBPAGENAME}}|doc|sandbox=&amp;lt;!-- No category for /doc or /sandbox subpages --&amp;gt;&lt;br /&gt;
       | {{#ifeq: {{{nocat|}}} | true | &amp;lt;!-- No category if user sets nocat=true --&amp;gt; | [[Category:Modules for general use|{{PAGENAME}}]] }}&lt;br /&gt;
      }}&lt;br /&gt;
   | protected | protect | p   = This module is [[:Category:Modules subject to page protection|subject to page protection]]. It is a [[Wikipedia:High-risk templates|highly visible module]] in use by a very large number of pages, or is [[Wikipedia:Substitution|substituted]] very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is [[Wikipedia:Protection policy|protected]] from editing.&amp;lt;!--&lt;br /&gt;
   --&amp;gt;{{#switch: {{SUBPAGENAME}}|doc|sandbox=&amp;lt;!-- No category for /doc or /sandbox subpages --&amp;gt;&lt;br /&gt;
       | {{#ifeq: {{{nocat|}}} | true | &amp;lt;!-- No category if user sets nocat=true --&amp;gt; | [[Category:Modules subject to page protection|{{PAGENAME}}]] }}&lt;br /&gt;
      }}&lt;br /&gt;
   | semiprotected | semiprotect | semi   = This module is [[:Category:Modules subject to page protection|subject to page protection]]. It is a [[Wikipedia:High-risk templates|highly visible module]] in use by a very large number of pages, or is [[Wikipedia:Substitution|substituted]] very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is [[WP:SEMI|semi-protected]] from editing.&amp;lt;!--&lt;br /&gt;
   --&amp;gt;{{#switch: {{SUBPAGENAME}}|doc|sandbox=&amp;lt;!-- No category for /doc or /sandbox subpages --&amp;gt;&lt;br /&gt;
       | {{#ifeq: {{{nocat|}}} | true | &amp;lt;!-- No category if user sets nocat=true --&amp;gt; | [[Category:Modules subject to page protection|{{PAGENAME}}]] }}&lt;br /&gt;
      }}&lt;br /&gt;
   | #default                  = {{error|Module rating is invalid or not specified.}}&lt;br /&gt;
  }}&lt;br /&gt;
}}|{{error|Error: {{tl|Module rating}} must be placed in the Module namespace.}} [[Category:Pages with templates in the wrong namespace]]|demospace={{{demospace|&amp;lt;noinclude&amp;gt;module&amp;lt;/noinclude&amp;gt;}}}}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;&lt;br /&gt;
{{module rating|release|nocat=true|demospace=module}}&lt;br /&gt;
{{documentation}}&lt;br /&gt;
&amp;lt;!-- Categories go on the /doc subpage, and interwikis go in Wikidata. --&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Module_other&amp;diff=597</id>
		<title>Template:Module other</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Module_other&amp;diff=597"/>
		<updated>2021-04-26T10:44:04Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#switch:&lt;br /&gt;
  &amp;lt;!--If no or empty &amp;quot;demospace&amp;quot; parameter then detect namespace--&amp;gt;&lt;br /&gt;
  {{#if:{{{demospace|}}}&lt;br /&gt;
  | {{lc: {{{demospace}}} }}    &amp;lt;!--Use lower case &amp;quot;demospace&amp;quot;--&amp;gt;&lt;br /&gt;
  | {{#ifeq:{{NAMESPACE}}|{{ns:Module}}&lt;br /&gt;
    | module&lt;br /&gt;
    | other&lt;br /&gt;
    }}&lt;br /&gt;
  }}&lt;br /&gt;
| module = {{{1|}}}&lt;br /&gt;
| other&lt;br /&gt;
| #default = {{{2|}}}&lt;br /&gt;
}}&amp;lt;!--End switch--&amp;gt;&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{documentation}}&lt;br /&gt;
&amp;lt;!-- Add categories to the /doc subpage, not here! --&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:High-use&amp;diff=595</id>
		<title>Template:High-use</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:High-use&amp;diff=595"/>
		<updated>2021-04-26T10:44:03Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#invoke:High-use|main|1={{{1|}}}|2={{{2|}}}|all-pages={{{all-pages|}}}|info={{{info|}}}|demo={{{demo|}}}|form={{{form|}}}|expiry={{{expiry|}}}|system={{{system|}}}}}&amp;lt;noinclude&amp;gt;&lt;br /&gt;
{{Documentation}}&lt;br /&gt;
&amp;lt;!-- Add categories to the /doc subpage; interwiki links go to Wikidata, thank you! --&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:High-risk&amp;diff=593</id>
		<title>Template:High-risk</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:High-risk&amp;diff=593"/>
		<updated>2021-04-26T10:44:03Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Template:High-use]]&lt;br /&gt;
&lt;br /&gt;
{{Rcat shell|&lt;br /&gt;
{{Wikidata redirect}}&lt;br /&gt;
{{R from merge}}&lt;br /&gt;
{{R from template shortcut}}&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Cs2&amp;diff=591</id>
		<title>Template:Cs2</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Cs2&amp;diff=591"/>
		<updated>2021-04-26T10:44:03Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Help:Citation Style 2|Citation Style 2]]&amp;lt;noinclude&amp;gt;&lt;br /&gt;
[[Category:Documentation assistance templates]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Cs1&amp;diff=589</id>
		<title>Template:Cs1</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Template:Cs1&amp;diff=589"/>
		<updated>2021-04-26T10:44:01Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Help:Citation Style 1|Citation Style 1]]&amp;lt;noinclude&amp;gt;&lt;br /&gt;
[[Category:Documentation assistance templates]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Citation/CS1&amp;diff=587</id>
		<title>Module:Citation/CS1</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Citation/CS1&amp;diff=587"/>
		<updated>2021-04-26T10:44:01Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
require(&#039;Module:No globals&#039;);&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; F O R W A R D   D E C L A R A T I O N S &amp;gt;--------------------------------------&lt;br /&gt;
each of these counts against the Lua upvalue limit&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local validation;																-- functions in Module:Citation/CS1/Date_validation&lt;br /&gt;
&lt;br /&gt;
local utilities;																-- functions in Module:Citation/CS1/Utilities&lt;br /&gt;
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities&lt;br /&gt;
&lt;br /&gt;
local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers&lt;br /&gt;
local metadata;																	-- functions in Module:Citation/CS1/COinS&lt;br /&gt;
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration&lt;br /&gt;
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist&lt;br /&gt;
&lt;br /&gt;
--[[------------------&amp;lt; P A G E   S C O P E   V A R I A B L E S &amp;gt;---------------&lt;br /&gt;
declare variables here that have page-wide scope that are not brought in from&lt;br /&gt;
other modules; that are created here and used here&lt;br /&gt;
]]&lt;br /&gt;
local added_deprecated_cat;														-- Boolean flag so that the category is added only once&lt;br /&gt;
local added_discouraged_cat;													-- Boolean flag so that the category is added only once&lt;br /&gt;
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category&lt;br /&gt;
local Frame;																	-- holds the module&#039;s frame table&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; F I R S T _ S E T &amp;gt;------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Locates and returns the first set value in a table of values where the order established in the table,&lt;br /&gt;
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.&lt;br /&gt;
&lt;br /&gt;
This version replaces the original &#039;for _, val in pairs do&#039; and a similar version that used ipairs.  With the pairs&lt;br /&gt;
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate&lt;br /&gt;
the for-loop before it reached the actual end of the list.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function first_set (list, count)&lt;br /&gt;
	local i = 1;&lt;br /&gt;
	while i &amp;lt;= count do															-- loop through all items in list&lt;br /&gt;
		if utilities.is_set( list[i] ) then&lt;br /&gt;
			return list[i];														-- return the first set list member&lt;br /&gt;
		end&lt;br /&gt;
		i = i + 1;																-- point to next&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; A D D _ V A N C _ E R R O R &amp;gt;----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Adds a single Vancouver system error message to the template&#039;s output regardless of how many error actually exist.&lt;br /&gt;
To prevent duplication, added_vanc_errs is nil until an error message is emitted.&lt;br /&gt;
&lt;br /&gt;
added_vanc_errs is a Boolean declared in page scope variables above&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function add_vanc_error (source, position)&lt;br /&gt;
	if added_vanc_errs then return end&lt;br /&gt;
		&lt;br /&gt;
	added_vanc_errs = true;														-- note that we&#039;ve added this category&lt;br /&gt;
	table.insert( z.message_tail, { utilities.set_message ( &#039;err_vancouver&#039;, {source, position}, true ) } );&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ S C H E M E &amp;gt;------------------------------------------------------------&lt;br /&gt;
&lt;br /&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&lt;br /&gt;
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:&lt;br /&gt;
	Scheme names consist of a sequence of characters beginning with a&lt;br /&gt;
   letter and followed by any combination of letters, digits, plus&lt;br /&gt;
   (&amp;quot;+&amp;quot;), period (&amp;quot;.&amp;quot;), or hyphen (&amp;quot;-&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
returns true if it does, else false&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_scheme (scheme)&lt;br /&gt;
	return scheme and scheme:match (&#039;^%a[%a%d%+%.%-]*:&#039;);						-- true if scheme is set and matches the pattern&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[=[-------------------------&amp;lt; I S _ D O M A I N _ N A M E &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Does this thing that purports to be a domain name seem to be a valid domain name?&lt;br /&gt;
&lt;br /&gt;
Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5&lt;br /&gt;
BNF defined here: https://tools.ietf.org/html/rfc4234&lt;br /&gt;
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;&lt;br /&gt;
	see also [[Single-letter second-level domain]]&lt;br /&gt;
list of TLDs: https://www.iana.org/domains/root/db&lt;br /&gt;
&lt;br /&gt;
RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between&lt;br /&gt;
the first and last characters the name may use letters, digits, and the hyphen.&lt;br /&gt;
&lt;br /&gt;
Also allowed are IPv4 addresses. IPv6 not supported&lt;br /&gt;
&lt;br /&gt;
domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld&lt;br /&gt;
is two or more alpha characters.  Any preceding &#039;//&#039; (from splitting a URL with a scheme) will be stripped&lt;br /&gt;
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.&lt;br /&gt;
&lt;br /&gt;
There are several tests:&lt;br /&gt;
	the first character of the whole domain name including subdomains must be a letter or a digit&lt;br /&gt;
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490&lt;br /&gt;
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs&lt;br /&gt;
	q, x, and z SL domains in the .com TLD&lt;br /&gt;
	i and q SL domains in the .net TLD&lt;br /&gt;
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)&lt;br /&gt;
	two-character SL domains in gTLDs (where the gTLD is two or more letters)&lt;br /&gt;
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)&lt;br /&gt;
	IPv4 dot-decimal address format; TLD not allowed&lt;br /&gt;
&lt;br /&gt;
returns true if domain appears to be a proper name and TLD or IPv4 address, else false&lt;br /&gt;
&lt;br /&gt;
]=]&lt;br /&gt;
&lt;br /&gt;
local function is_domain_name (domain)&lt;br /&gt;
	if not domain then&lt;br /&gt;
		return false;															-- if not set, abandon&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	domain = domain:gsub (&#039;^//&#039;, &#039;&#039;);											-- strip &#039;//&#039; from domain name if present; done here so we only have to do it once&lt;br /&gt;
	&lt;br /&gt;
	if not domain:match (&#039;^[%w]&#039;) then											-- first character must be letter or digit&lt;br /&gt;
		return false;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if domain:match (&#039;^%a+:&#039;) then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource&lt;br /&gt;
		return false;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local patterns = {															-- patterns that look like URLs&lt;br /&gt;
		&#039;%f[%w][%w][%w%-]+[%w]%.%a%a+$&#039;,										-- three or more character hostname.hostname or hostname.tld&lt;br /&gt;
		&#039;%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$&#039;,									-- internationalized domain name with ACE prefix&lt;br /&gt;
		&#039;%f[%a][qxz]%.com$&#039;,													-- assigned one character .com hostname (x.com times out 2015-12-10)&lt;br /&gt;
		&#039;%f[%a][iq]%.net$&#039;,														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)&lt;br /&gt;
		&#039;%f[%w][%w]%.%a%a$&#039;,													-- one character hostname and ccTLD (2 chars)&lt;br /&gt;
		&#039;%f[%w][%w][%w]%.%a%a+$&#039;,												-- two character hostname and TLD&lt;br /&gt;
		&#039;^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?&#039;,								-- IPv4 address&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
	for _, pattern in ipairs (patterns) do										-- loop through the patterns list&lt;br /&gt;
		if domain:match (pattern) then&lt;br /&gt;
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for _, d in ipairs ({&#039;cash&#039;, &#039;company&#039;, &#039;today&#039;, &#039;org&#039;}) do					-- look for single letter second level domain names for these top level domains&lt;br /&gt;
		if domain:match (&#039;%f[%w][%w]%.&#039; .. d) then&lt;br /&gt;
			return true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return false;																-- no matches, we don&#039;t know what this thing is&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ U R L &amp;gt;------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.&lt;br /&gt;
&lt;br /&gt;
This function is the last step in the validation process.  This function is separate because there are cases that&lt;br /&gt;
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external&lt;br /&gt;
wikilinks.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_url (scheme, domain)&lt;br /&gt;
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain&lt;br /&gt;
		return is_scheme (scheme) and is_domain_name (domain);&lt;br /&gt;
	else&lt;br /&gt;
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S P L I T _ U R L &amp;gt;------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Split a URL into a scheme, authority indicator, and domain.&lt;br /&gt;
&lt;br /&gt;
First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).&lt;br /&gt;
&lt;br /&gt;
If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.&lt;br /&gt;
&lt;br /&gt;
When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one&lt;br /&gt;
or more &#039;/&#039; characters immediately following the scheme&#039;s colon), make sure that there are only 2.&lt;br /&gt;
&lt;br /&gt;
Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes&lt;br /&gt;
like news: that don&#039;t use authority indicator?&lt;br /&gt;
&lt;br /&gt;
Strip off any port and path;&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function split_url (url_str)&lt;br /&gt;
	local scheme, authority, domain;&lt;br /&gt;
	&lt;br /&gt;
	url_str = url_str:gsub (&#039;([%a%d])%.?[/%?#].*$&#039;, &#039;%1&#039;);						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of &#039;//&#039;)&lt;br /&gt;
&lt;br /&gt;
	if url_str:match (&#039;^//%S*&#039;) then											-- if there is what appears to be a protocol-relative URL&lt;br /&gt;
		domain = url_str:match (&#039;^//(%S*)&#039;)&lt;br /&gt;
	elseif url_str:match (&#039;%S-:/*%S+&#039;) then										-- if there is what appears to be a scheme, optional authority indicator, and domain name&lt;br /&gt;
		scheme, authority, domain = url_str:match (&#039;(%S-:)(/*)(%S+)&#039;);			-- extract the scheme, authority indicator, and domain portions&lt;br /&gt;
		if utilities.is_set (authority) then&lt;br /&gt;
			authority = authority:gsub (&#039;//&#039;, &#039;&#039;, 1);							-- replace place 1 pair of &#039;/&#039; with nothing;&lt;br /&gt;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ &#039;/&#039; where authority should be) then&lt;br /&gt;
				return scheme;													-- return scheme only making domain nil which will cause an error message&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			if not scheme:match (&#039;^news:&#039;) then									-- except for news:..., MediaWiki won&#039;t link URLs that do not have authority indicator; TODO: a better way to do this test?&lt;br /&gt;
				return scheme;													-- return scheme only making domain nil which will cause an error message&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		domain = domain:gsub (&#039;(%a):%d+&#039;, &#039;%1&#039;);								-- strip port number if present&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return scheme, domain;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; L I N K _ P A R A M _ O K &amp;gt;---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs&lt;br /&gt;
&lt;br /&gt;
Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:&lt;br /&gt;
	# &amp;lt; &amp;gt; [ ] | { } _&lt;br /&gt;
except the underscore which is used as a space in wiki URLs and # which is used for section links&lt;br /&gt;
&lt;br /&gt;
returns false when the value contains any of these characters.&lt;br /&gt;
&lt;br /&gt;
When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the&lt;br /&gt;
|&amp;lt;param&amp;gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&amp;lt;param&amp;gt;-link= parameter is NOT ok).&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function link_param_ok (value)&lt;br /&gt;
	local scheme, domain;&lt;br /&gt;
	if value:find (&#039;[&amp;lt;&amp;gt;%[%]|{}]&#039;) then											-- if any prohibited characters&lt;br /&gt;
		return false;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; &lt;br /&gt;
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; L I N K _ T I T L E _ O K &amp;gt;---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Use link_param_ok() to validate |&amp;lt;param&amp;gt;-link= value and its matching |&amp;lt;title&amp;gt;= value.&lt;br /&gt;
&lt;br /&gt;
|&amp;lt;title&amp;gt;= may be wiki-linked but not when |&amp;lt;param&amp;gt;-link= has a value.  This function emits an error message when&lt;br /&gt;
that condition exists&lt;br /&gt;
&lt;br /&gt;
check &amp;lt;link&amp;gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language&lt;br /&gt;
code and must begin with a colon.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function link_title_ok (link, lorig, title, torig)&lt;br /&gt;
local orig;&lt;br /&gt;
	if utilities.is_set (link) then 											-- don&#039;t bother if &amp;lt;param&amp;gt;-link doesn&#039;t have a value&lt;br /&gt;
		if not link_param_ok (link) then										-- check |&amp;lt;param&amp;gt;-link= markup&lt;br /&gt;
			orig = lorig;														-- identify the failing link parameter&lt;br /&gt;
		elseif title:find (&#039;%[%[&#039;) then											-- check |title= for wikilink markup&lt;br /&gt;
			orig = torig;														-- identify the failing |title= parameter&lt;br /&gt;
		elseif link:match (&#039;^%a+:&#039;) then										-- if the link is what looks like an interwiki&lt;br /&gt;
			local prefix = link:match (&#039;^(%a+):&#039;):lower();						-- get the interwiki prefix&lt;br /&gt;
&lt;br /&gt;
			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon&lt;br /&gt;
				orig = lorig;													-- flag as error&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (orig) then&lt;br /&gt;
		link = &#039;&#039;;																-- unset&lt;br /&gt;
		table.insert( z.message_tail, { utilities.set_message ( &#039;err_bad_paramlink&#039;, orig)});	-- URL or wikilink in |title= with |title-link=;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return link;																-- link if ok, empty string else&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; C H E C K _ U R L &amp;gt;------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Determines whether a URL string appears to be valid.&lt;br /&gt;
&lt;br /&gt;
First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain&lt;br /&gt;
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two&lt;br /&gt;
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.&lt;br /&gt;
&lt;br /&gt;
Because it is different from a standard URL, and because this module used external_link() to make external links&lt;br /&gt;
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name&lt;br /&gt;
is at https://tools.ietf.org/html/rfc5536#section-3.1.4&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function check_url( url_str )&lt;br /&gt;
	if nil == url_str:match (&amp;quot;^%S+$&amp;quot;) then										-- if there are any spaces in |url=value it can&#039;t be a proper URL&lt;br /&gt;
		return false;&lt;br /&gt;
	end&lt;br /&gt;
	local scheme, domain;&lt;br /&gt;
&lt;br /&gt;
	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;&lt;br /&gt;
	&lt;br /&gt;
	if &#039;news:&#039; == scheme then													-- special case for newsgroups&lt;br /&gt;
		return domain:match(&#039;^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$&#039;);&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[=[-------------------------&amp;lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &amp;gt;----------------------------&lt;br /&gt;
&lt;br /&gt;
Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first&lt;br /&gt;
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks&lt;br /&gt;
that use protocol-relative URLs. Also finds bare URLs.&lt;br /&gt;
&lt;br /&gt;
The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that&lt;br /&gt;
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,&lt;br /&gt;
and |publisher=) may have wikilinks and there are articles or redirects like &#039;//Hus&#039; so, while uncommon, |title=[[//Hus]]&lt;br /&gt;
is possible as might be [[en://Hus]].&lt;br /&gt;
&lt;br /&gt;
]=]&lt;br /&gt;
&lt;br /&gt;
local function is_parameter_ext_wikilink (value)&lt;br /&gt;
local scheme, domain;&lt;br /&gt;
&lt;br /&gt;
	if value:match (&#039;%f[%[]%[%a%S*:%S+.*%]&#039;) then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]&lt;br /&gt;
		scheme, domain = split_url (value:match (&#039;%f[%[]%[(%a%S*:%S+).*%]&#039;));&lt;br /&gt;
	elseif value:match (&#039;%f[%[]%[//%S+.*%]&#039;) then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]&lt;br /&gt;
		scheme, domain = split_url (value:match (&#039;%f[%[]%[(//%S+).*%]&#039;));&lt;br /&gt;
	elseif value:match (&#039;%a%S*:%S+&#039;) then										-- if bare URL with scheme; may have leading or trailing plain text&lt;br /&gt;
		scheme, domain = split_url (value:match (&#039;(%a%S*:%S+)&#039;));&lt;br /&gt;
	elseif value:match (&#039;//%S+&#039;) then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text&lt;br /&gt;
		scheme, domain = split_url (value:match (&#039;(//%S+)&#039;));					-- what is left should be the domain&lt;br /&gt;
	else&lt;br /&gt;
		return false;															-- didn&#039;t find anything that is obviously a URL&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[-------------------------&amp;lt; C H E C K _ F O R _ U R L &amp;gt;-----------------------------------------------------&lt;br /&gt;
&lt;br /&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.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function check_for_url (parameter_list)&lt;br /&gt;
local error_message = &#039;&#039;;&lt;br /&gt;
	for k, v in pairs (parameter_list) do										-- for each parameter in the list&lt;br /&gt;
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message&lt;br /&gt;
			if utilities.is_set(error_message) then								-- once we&#039;ve added the first portion of the error message ...&lt;br /&gt;
				error_message = error_message .. &amp;quot;, &amp;quot;;							-- ... add a comma space separator&lt;br /&gt;
			end&lt;br /&gt;
			error_message = error_message .. &amp;quot;&amp;amp;#124;&amp;quot; .. k .. &amp;quot;=&amp;quot;;				-- add the failed parameter&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if utilities.is_set (error_message) then									-- done looping, if there is an error message, display it&lt;br /&gt;
		table.insert( z.message_tail, { utilities.set_message ( &#039;err_param_has_ext_link&#039;, {error_message}, true ) } );&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S A F E _ F O R _ U R L &amp;gt;------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Escape sequences for content that will be used for URL descriptions&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function safe_for_url( str )&lt;br /&gt;
	if str:match( &amp;quot;%[%[.-%]%]&amp;quot; ) ~= nil then &lt;br /&gt;
		table.insert( z.message_tail, { utilities.set_message ( &#039;err_wikilink_in_url&#039;, {}, true ) } );&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return str:gsub( &#039;[%[%]\n]&#039;, {	&lt;br /&gt;
		[&#039;[&#039;] = &#039;&amp;amp;#91;&#039;,&lt;br /&gt;
		[&#039;]&#039;] = &#039;&amp;amp;#93;&#039;,&lt;br /&gt;
		[&#039;\n&#039;] = &#039; &#039; } );&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E X T E R N A L _ L I N K &amp;gt;----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Format an external link with error checking&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function external_link( URL, label, source, access)&lt;br /&gt;
	local error_str = &amp;quot;&amp;quot;;&lt;br /&gt;
	local domain;&lt;br /&gt;
	local path;&lt;br /&gt;
	local base_url;&lt;br /&gt;
&lt;br /&gt;
	if not utilities.is_set ( label ) then&lt;br /&gt;
		label = URL;&lt;br /&gt;
		if utilities.is_set ( source ) then&lt;br /&gt;
			error_str = utilities.set_message ( &#039;err_bare_url_missing_title&#039;, { utilities.wrap_style (&#039;parameter&#039;, source) }, false, &amp;quot; &amp;quot; );&lt;br /&gt;
		else&lt;br /&gt;
			error( cfg.messages[&amp;quot;bare_url_no_origin&amp;quot;] );&lt;br /&gt;
		end			&lt;br /&gt;
	end&lt;br /&gt;
	if not check_url( URL ) then&lt;br /&gt;
		error_str = utilities.set_message ( &#039;err_bad_url&#039;, {utilities.wrap_style (&#039;parameter&#039;, source)}, false, &amp;quot; &amp;quot; ) .. error_str;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	domain, path = URL:match (&#039;^([/%.%-%+:%a%d]+)([/%?#].*)$&#039;);					-- split the URL into scheme plus domain and path&lt;br /&gt;
	if path then																-- if there is a path portion&lt;br /&gt;
		path = path:gsub (&#039;[%[%]]&#039;, {[&#039;[&#039;] = &#039;%5b&#039;, [&#039;]&#039;] = &#039;%5d&#039;});			-- replace &#039;[&#039; and &#039;]&#039; with their percent-encoded values&lt;br /&gt;
		URL = table.concat ({domain, path});									-- and reassemble&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	base_url = table.concat({ &amp;quot;[&amp;quot;, URL, &amp;quot; &amp;quot;, safe_for_url (label), &amp;quot;]&amp;quot; });		-- assemble a wiki-markup URL&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (access) then											-- access level (subscription, registration, limited)&lt;br /&gt;
		base_url = utilities.substitute (cfg.presentation[&#039;ext-link-access-signal&#039;], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return table.concat ({base_url, error_str});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; D E P R E C A T E D _ P A R A M E T E R &amp;gt;--------------------------------------&lt;br /&gt;
&lt;br /&gt;
Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the&lt;br /&gt;
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated&lt;br /&gt;
parameters in the citation.&lt;br /&gt;
&lt;br /&gt;
added_deprecated_cat is a Boolean declared in page scope variables above&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function deprecated_parameter(name)&lt;br /&gt;
	if not added_deprecated_cat then&lt;br /&gt;
		added_deprecated_cat = true;											-- note that we&#039;ve added this category&lt;br /&gt;
		table.insert( z.message_tail, { utilities.set_message ( &#039;err_deprecated_params&#039;, {name}, true ) } );	-- add error message&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; D I S C O U R A G E D _ P A R A M E T E R &amp;gt;------------------------------------&lt;br /&gt;
&lt;br /&gt;
Categorize and emit an maintenance message when the citation contains one or more discouraged parameters.  Only&lt;br /&gt;
one error message is emitted regardless of the number of discouraged parameters in the citation.&lt;br /&gt;
&lt;br /&gt;
added_discouraged_cat is a Boolean declared in page scope variables above&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function discouraged_parameter(name)&lt;br /&gt;
	if not added_discouraged_cat then&lt;br /&gt;
		added_discouraged_cat = true;											-- note that we&#039;ve added this category&lt;br /&gt;
		table.insert( z.message_tail, { utilities.set_message ( &#039;maint_discouraged&#039;, {name}, true ) } );	-- add maint message&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[=[-------------------------&amp;lt; K E R N _ Q U O T E S &amp;gt;--------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote&lt;br /&gt;
mark contained in a |title= or |chapter= parameter&#039;s value.&lt;br /&gt;
&lt;br /&gt;
This function will positive kern either single or double quotes:&lt;br /&gt;
	&amp;quot;&#039;Unkerned title with leading and trailing single quote marks&#039;&amp;quot;&lt;br /&gt;
	&amp;quot; &#039;Kerned title with leading and trailing single quote marks&#039; &amp;quot; (in real life the kerning isn&#039;t as wide as this example)&lt;br /&gt;
Double single quotes (italic or bold wiki-markup) are not kerned.&lt;br /&gt;
&lt;br /&gt;
Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter&lt;br /&gt;
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.&lt;br /&gt;
&lt;br /&gt;
Call this function for chapter titles, for website titles, etc.; not for book titles.&lt;br /&gt;
&lt;br /&gt;
]=]&lt;br /&gt;
&lt;br /&gt;
local function kern_quotes (str)&lt;br /&gt;
	local cap = &#039;&#039;;&lt;br /&gt;
	local cap2 = &#039;&#039;;&lt;br /&gt;
	local wl_type, label, link;&lt;br /&gt;
&lt;br /&gt;
	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]&lt;br /&gt;
	&lt;br /&gt;
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks&lt;br /&gt;
		if mw.ustring.match (str, &#039;%[%[[\&amp;quot;“”\&#039;‘’].+[\&amp;quot;“”\&#039;‘’]%]%]&#039;) then		-- leading and trailing quote marks&lt;br /&gt;
			str = utilities.substitute (cfg.presentation[&#039;kern-wl-both&#039;], str);&lt;br /&gt;
		elseif mw.ustring.match (str, &#039;%[%[[\&amp;quot;“”\&#039;‘’].+%]%]&#039;)	then			-- leading quote marks&lt;br /&gt;
			str = utilities.substitute (cfg.presentation[&#039;kern-wl-left&#039;], str);&lt;br /&gt;
		elseif mw.ustring.match (str, &#039;%[%[.+[\&amp;quot;“”\&#039;‘’]%]%]&#039;) then				-- trailing quote marks&lt;br /&gt;
			str = utilities.substitute (cfg.presentation[&#039;kern-wl-right&#039;], str);&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
	else																		-- plain text or [[L|D]]; text in label variable&lt;br /&gt;
		label = mw.ustring.gsub (label, &#039;[“”]&#039;, &#039;\&amp;quot;&#039;);							-- replace “” (U+201C &amp;amp; U+201D) with &amp;quot; (typewriter double quote mark)&lt;br /&gt;
		label = mw.ustring.gsub (label, &#039;[‘’]&#039;, &#039;\&#039;&#039;);							-- replace ‘’ (U+2018 &amp;amp; U+2019) with &#039; (typewriter single quote mark)&lt;br /&gt;
&lt;br /&gt;
		cap, cap2 = mw.ustring.match (label, &amp;quot;^([\&amp;quot;\&#039;])([^\&#039;].+)&amp;quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)&lt;br /&gt;
		if utilities.is_set (cap) then&lt;br /&gt;
			label = utilities.substitute (cfg.presentation[&#039;kern-left&#039;], {cap, cap2});&lt;br /&gt;
		end&lt;br /&gt;
	&lt;br /&gt;
		cap, cap2 = mw.ustring.match (label, &amp;quot;^(.+[^\&#039;])([\&amp;quot;\&#039;])$&amp;quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)&lt;br /&gt;
		if utilities.is_set (cap) then&lt;br /&gt;
			label = utilities.substitute (cfg.presentation[&#039;kern-right&#039;], {cap, cap2});&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		if 2 == wl_type then&lt;br /&gt;
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink&lt;br /&gt;
		else&lt;br /&gt;
			str = label;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return str;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; F O R M A T _ S C R I P T _ V A L U E &amp;gt;----------------------------------------&lt;br /&gt;
&lt;br /&gt;
|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should&lt;br /&gt;
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&lt;br /&gt;
in italic markup.&lt;br /&gt;
&lt;br /&gt;
Regardless of language, all values provided by |script-title= are wrapped in &amp;lt;bdi&amp;gt;...&amp;lt;/bdi&amp;gt; tags to isolate RTL languages from the English left to right.&lt;br /&gt;
&lt;br /&gt;
|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:&lt;br /&gt;
	|script-title=ja:*** *** (where * represents a Japanese character)&lt;br /&gt;
Spaces between the two-character code and the colon and the colon and the first script character are allowed:&lt;br /&gt;
	|script-title=ja : *** ***&lt;br /&gt;
	|script-title=ja: *** ***&lt;br /&gt;
	|script-title=ja :*** ***&lt;br /&gt;
Spaces preceding the prefix are allowed: |script-title = ja:*** ***&lt;br /&gt;
&lt;br /&gt;
The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&amp;quot;ja&amp;quot;) is added to the &amp;lt;bdi&amp;gt; tag so that browsers can&lt;br /&gt;
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute&lt;br /&gt;
is not added.  At this time there is no error message for this condition.&lt;br /&gt;
&lt;br /&gt;
Supports |script-title=, |script-chapter=, |script-&amp;lt;periodical&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function format_script_value (script_value, script_param)&lt;br /&gt;
	local lang=&#039;&#039;;																-- initialize to empty string&lt;br /&gt;
	local name;&lt;br /&gt;
	if script_value:match(&#039;^%l%l%l?%s*:&#039;) then									-- if first 3 or 4 non-space characters are script language prefix&lt;br /&gt;
		lang = script_value:match(&#039;^(%l%l%l?)%s*:%s*%S.*&#039;);						-- get the language prefix or nil if there is no script&lt;br /&gt;
		if not utilities.is_set (lang) then&lt;br /&gt;
			table.insert( z.message_tail, { utilities.set_message ( &#039;err_script_parameter&#039;, {script_param, &#039;missing title part&#039;}, true ) } );		-- prefix without &#039;title&#039;; add error message&lt;br /&gt;
			return &#039;&#039;;															-- script_value was just the prefix so return empty string&lt;br /&gt;
		end&lt;br /&gt;
																				-- if we get this far we have prefix and script&lt;br /&gt;
		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&lt;br /&gt;
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?&lt;br /&gt;
			script_value = script_value:gsub (&#039;^%l+%s*:%s*&#039;, &#039;&#039;);				-- strip prefix from script&lt;br /&gt;
																				-- is prefix one of these language codes?&lt;br /&gt;
			if utilities.in_array (lang, cfg.script_lang_codes) then&lt;br /&gt;
				utilities.add_prop_cat (&#039;script_with_name&#039;, {name, lang})&lt;br /&gt;
			else&lt;br /&gt;
				table.insert( z.message_tail, { utilities.set_message ( &#039;err_script_parameter&#039;, {script_param, &#039;unknown language code&#039;}, true ) } );	-- unknown script-language; add error message&lt;br /&gt;
			end&lt;br /&gt;
			lang = &#039; lang=&amp;quot;&#039; .. lang .. &#039;&amp;quot; &#039;;									-- convert prefix into a lang attribute&lt;br /&gt;
		else&lt;br /&gt;
			table.insert( z.message_tail, { utilities.set_message ( &#039;err_script_parameter&#039;, {script_param, &#039;invalid language code&#039;}, true ) } );		-- invalid language code; add error message&lt;br /&gt;
			lang = &#039;&#039;;															-- invalid so set lang to empty string&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		table.insert( z.message_tail, { utilities.set_message ( &#039;err_script_parameter&#039;, {script_param, &#039;missing prefix&#039;}, true ) } );				-- no language code prefix; add error message&lt;br /&gt;
	end&lt;br /&gt;
	script_value = utilities.substitute (cfg.presentation[&#039;bdi&#039;], {lang, script_value});	-- isolate in case script is RTL&lt;br /&gt;
&lt;br /&gt;
	return script_value;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S C R I P T _ C O N C A T E N A T E &amp;gt;------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been &lt;br /&gt;
wrapped in &amp;lt;bdi&amp;gt; tags.&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function script_concatenate (title, script, script_param)&lt;br /&gt;
	if utilities.is_set (script) then&lt;br /&gt;
		script = format_script_value (script, script_param);					-- &amp;lt;bdi&amp;gt; tags, lang attribute, categorization, etc.; returns empty string on error&lt;br /&gt;
		if utilities.is_set (script) then&lt;br /&gt;
			title = title .. &#039; &#039; .. script;										-- concatenate title and script title&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return title;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; W R A P _ M S G &amp;gt;--------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Applies additional message text to various parameter values. Supplied string is wrapped using a message_list&lt;br /&gt;
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken&lt;br /&gt;
from citation_config.messages - the reason this function is similar to but separate from wrap_style().&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function wrap_msg (key, str, lower)&lt;br /&gt;
	if not utilities.is_set ( str ) then&lt;br /&gt;
		return &amp;quot;&amp;quot;;&lt;br /&gt;
	end&lt;br /&gt;
	if true == lower then&lt;br /&gt;
		local msg;&lt;br /&gt;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before &lt;br /&gt;
		return utilities.substitute ( msg, str );								-- including template text&lt;br /&gt;
	else&lt;br /&gt;
		return utilities.substitute ( cfg.messages[key], str );&lt;br /&gt;
	end		&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[----------------&amp;lt; W I K I S O U R C E _ U R L _ M A K E &amp;gt;-------------------&lt;br /&gt;
&lt;br /&gt;
Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate&lt;br /&gt;
label; nil else.&lt;br /&gt;
&lt;br /&gt;
str is the value assigned to |chapter= (or aliases) or |title= or |title-link=&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function wikisource_url_make (str)&lt;br /&gt;
	local wl_type, D, L;&lt;br /&gt;
	local ws_url, ws_label;&lt;br /&gt;
	local wikisource_prefix = table.concat ({&#039;https://&#039;, cfg.this_wiki_code, &#039;.wikisource.org/wiki/&#039;});&lt;br /&gt;
&lt;br /&gt;
	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)&lt;br /&gt;
&lt;br /&gt;
	if 0 == wl_type then														-- not a wikilink; might be from |title-link=&lt;br /&gt;
		str = D:match (&#039;^[Ww]ikisource:(.+)&#039;) or D:match (&#039;^[Ss]:(.+)&#039;);		-- article title from interwiki link with long-form or short-form namespace&lt;br /&gt;
		if utilities.is_set (str) then&lt;br /&gt;
			ws_url = table.concat ({											-- build a Wikisource URL&lt;br /&gt;
				wikisource_prefix,												-- prefix&lt;br /&gt;
				str,															-- article title&lt;br /&gt;
				});&lt;br /&gt;
			ws_label = str;														-- label for the URL&lt;br /&gt;
		end&lt;br /&gt;
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]&lt;br /&gt;
		str = D:match (&#039;^[Ww]ikisource:(.+)&#039;) or D:match (&#039;^[Ss]:(.+)&#039;);		-- article title from interwiki link with long-form or short-form namespace&lt;br /&gt;
		if utilities.is_set (str) then&lt;br /&gt;
			ws_url = table.concat ({											-- build a Wikisource URL&lt;br /&gt;
				wikisource_prefix,												-- prefix&lt;br /&gt;
				str,															-- article title&lt;br /&gt;
				});&lt;br /&gt;
			ws_label = str;														-- label for the URL&lt;br /&gt;
		end&lt;br /&gt;
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])&lt;br /&gt;
		str = L:match (&#039;^[Ww]ikisource:(.+)&#039;) or L:match (&#039;^[Ss]:(.+)&#039;);		-- article title from interwiki link with long-form or short-form namespace&lt;br /&gt;
		if utilities.is_set (str) then&lt;br /&gt;
			ws_label = D;														-- get ws article name from display portion of interwiki link&lt;br /&gt;
			ws_url = table.concat ({											-- build a Wikisource URL&lt;br /&gt;
				wikisource_prefix,												-- prefix&lt;br /&gt;
				str,															-- article title without namespace from link portion of wikilink&lt;br /&gt;
				});&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if ws_url then&lt;br /&gt;
		ws_url = mw.uri.encode (ws_url, &#039;WIKI&#039;);								-- make a usable URL&lt;br /&gt;
		ws_url = ws_url:gsub (&#039;%%23&#039;, &#039;#&#039;);										-- undo percent-encoding of fragment marker&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[----------------&amp;lt; F O R M A T _ P E R I O D I C A L &amp;gt;-----------------------&lt;br /&gt;
&lt;br /&gt;
Format the three periodical parameters: |script-&amp;lt;periodical&amp;gt;=, |&amp;lt;periodical&amp;gt;=,&lt;br /&gt;
and |trans-&amp;lt;periodical&amp;gt;= into a single Periodical meta-parameter.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)&lt;br /&gt;
	local periodical_error = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
	if not utilities.is_set (periodical) then&lt;br /&gt;
		periodical = &#039;&#039;;														-- to be safe for concatenation&lt;br /&gt;
	else&lt;br /&gt;
		periodical = utilities.wrap_style (&#039;italic-title&#039;, periodical);			-- style &lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &amp;lt;bdi&amp;gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (trans_periodical) then&lt;br /&gt;
		trans_periodical = utilities.wrap_style (&#039;trans-italic-title&#039;, trans_periodical);&lt;br /&gt;
		if utilities.is_set (periodical) then&lt;br /&gt;
			periodical = periodical .. &#039; &#039; .. trans_periodical;&lt;br /&gt;
		else																	-- here when trans-periodical without periodical or script-periodical&lt;br /&gt;
			periodical = trans_periodical;&lt;br /&gt;
			periodical_error = &#039; &#039; .. utilities.set_message (&#039;err_trans_missing_title&#039;, {&#039;periodical&#039;});&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return periodical .. periodical_error;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[------------------&amp;lt; F O R M A T _ C H A P T E R _ T I T L E &amp;gt;---------------&lt;br /&gt;
&lt;br /&gt;
Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,&lt;br /&gt;
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used&lt;br /&gt;
for error messages).&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
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)&lt;br /&gt;
	local chapter_error = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link&lt;br /&gt;
	if ws_url then&lt;br /&gt;
		ws_label = ws_label:gsub (&#039;_&#039;, &#039; &#039;);									-- replace underscore separators with space characters&lt;br /&gt;
		chapter = ws_label;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not utilities.is_set (chapter) then&lt;br /&gt;
		chapter = &#039;&#039;;															-- to be safe for concatenation&lt;br /&gt;
	else&lt;br /&gt;
		if false == no_quotes then&lt;br /&gt;
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title&#039;s leading and trailing quote marks from module provided quote marks&lt;br /&gt;
			chapter = utilities.wrap_style (&#039;quoted-title&#039;, chapter);&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &amp;lt;bdi&amp;gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (chapter_url) then&lt;br /&gt;
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate&lt;br /&gt;
	elseif ws_url then&lt;br /&gt;
		chapter = external_link (ws_url, chapter .. &#039;&amp;amp;nbsp;&#039;, &#039;ws link in chapter&#039;);	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?&lt;br /&gt;
		chapter = utilities.substitute (cfg.presentation[&#039;interwiki-icon&#039;], {cfg.presentation[&#039;class-wikisource&#039;], L, chapter});				&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (trans_chapter) then&lt;br /&gt;
		trans_chapter = utilities.wrap_style (&#039;trans-quoted-title&#039;, trans_chapter);&lt;br /&gt;
		if utilities.is_set (chapter) then&lt;br /&gt;
			chapter = chapter .. &#039; &#039; .. trans_chapter;&lt;br /&gt;
		else																	-- here when trans_chapter without chapter or script-chapter&lt;br /&gt;
			chapter = trans_chapter;&lt;br /&gt;
			chapter_source = trans_chapter_source:match (&#039;trans%-?(.+)&#039;);		-- when no chapter, get matching name from trans-&amp;lt;param&amp;gt;&lt;br /&gt;
			chapter_error = &#039; &#039; .. utilities.set_message (&#039;err_trans_missing_title&#039;, {chapter_source});&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return chapter .. chapter_error;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[----------------&amp;lt; H A S _ I N V I S I B L E _ C H A R S &amp;gt;-------------------&lt;br /&gt;
&lt;br /&gt;
This function searches a parameter&#039;s value for non-printable or invisible characters.&lt;br /&gt;
The search stops at the first match.&lt;br /&gt;
&lt;br /&gt;
This function will detect the visible replacement character when it is part of the Wikisource.&lt;br /&gt;
&lt;br /&gt;
Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers&lt;br /&gt;
(gallery, math, pre, ref) and identifies them with a slightly different error message.&lt;br /&gt;
See also coins_cleanup().&lt;br /&gt;
&lt;br /&gt;
Output of this function is an error message that identifies the character or the&lt;br /&gt;
Unicode group, or the stripmarker that was detected along with its position (or,&lt;br /&gt;
for multi-byte characters, the position of its first byte) in the parameter value.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function has_invisible_chars (param, v)&lt;br /&gt;
	local position = &#039;&#039;;														-- position of invisible char or starting position of stripmarker&lt;br /&gt;
	local capture;																-- used by stripmarker detection to hold name of the stripmarker&lt;br /&gt;
	local stripmarker;															-- boolean set true when a stripmarker is found&lt;br /&gt;
&lt;br /&gt;
	capture = string.match (v, &#039;[%w%p ]*&#039;);										-- test for values that are simple ASCII text and bypass other tests if true&lt;br /&gt;
	if capture == v then														-- if same there are no Unicode characters&lt;br /&gt;
		return;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for _, invisible_char in ipairs (cfg.invisible_chars) do&lt;br /&gt;
		local char_name = invisible_char[1];									-- the character or group name&lt;br /&gt;
		local pattern = invisible_char[2];										-- the pattern used to find it&lt;br /&gt;
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern&lt;br /&gt;
		&lt;br /&gt;
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character&lt;br /&gt;
			if mw.ustring.find (v, cfg.indic_script) then						-- it&#039;s ok if one of the Indic scripts&lt;br /&gt;
				position = nil;													-- unset position&lt;br /&gt;
			elseif cfg.emoji[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?&lt;br /&gt;
				position = nil;													-- unset position&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		if position then&lt;br /&gt;
			if &#039;nowiki&#039; == capture or &#039;math&#039; == capture or						-- nowiki and math stripmarkers (not an error condition)&lt;br /&gt;
				(&#039;templatestyles&#039; == capture and utilities.in_array (param, {&#039;id&#039;, &#039;quote&#039;})) then	-- templatestyles stripmarker allowed in these parameters&lt;br /&gt;
					stripmarker = true;											-- set a flag&lt;br /&gt;
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we&#039;ve found one end of a stripmarker&lt;br /&gt;
				position = nil;													-- unset&lt;br /&gt;
			else&lt;br /&gt;
				local err_msg;&lt;br /&gt;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then&lt;br /&gt;
					err_msg = capture .. &#039; &#039; .. char_name;&lt;br /&gt;
				else&lt;br /&gt;
					err_msg = char_name .. &#039; &#039; .. &#039;character&#039;;&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				table.insert (z.message_tail, {utilities.set_message (&#039;err_invisible_char&#039;, {err_msg, utilities.wrap_style (&#039;parameter&#039;, param), position}, true)});	-- add error message&lt;br /&gt;
				return;															-- and done with this parameter&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[-------------------&amp;lt; A R G U M E N T _ W R A P P E R &amp;gt;----------------------&lt;br /&gt;
&lt;br /&gt;
Argument wrapper.  This function provides support for argument mapping defined&lt;br /&gt;
in the configuration file so that multiple names can be transparently aliased to&lt;br /&gt;
single internal variable.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function argument_wrapper ( args )&lt;br /&gt;
	local origin = {};&lt;br /&gt;
	&lt;br /&gt;
	return setmetatable({&lt;br /&gt;
		ORIGIN = function ( self, k )&lt;br /&gt;
			local dummy = self[k];												-- force the variable to be loaded.&lt;br /&gt;
			return origin[k];&lt;br /&gt;
		end&lt;br /&gt;
	},&lt;br /&gt;
	{&lt;br /&gt;
		__index = function ( tbl, k )&lt;br /&gt;
			if origin[k] ~= nil then&lt;br /&gt;
				return nil;&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			local args, list, v = args, cfg.aliases[k];&lt;br /&gt;
			&lt;br /&gt;
			if type( list ) == &#039;table&#039; then&lt;br /&gt;
				v, origin[k] = utilities.select_one ( args, list, &#039;err_redundant_parameters&#039; );&lt;br /&gt;
				if origin[k] == nil then&lt;br /&gt;
					origin[k] = &#039;&#039;;												-- Empty string, not nil&lt;br /&gt;
				end&lt;br /&gt;
			elseif list ~= nil then&lt;br /&gt;
				v, origin[k] = args[list], list;&lt;br /&gt;
			else&lt;br /&gt;
				-- maybe let through instead of raising an error?&lt;br /&gt;
				-- v, origin[k] = args[k], k;&lt;br /&gt;
				error( cfg.messages[&#039;unknown_argument_map&#039;] .. &#039;: &#039; .. k);&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			-- Empty strings, not nil;&lt;br /&gt;
			if v == nil then&lt;br /&gt;
				v = &#039;&#039;;&lt;br /&gt;
				origin[k] = &#039;&#039;;&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			tbl = rawset( tbl, k, v );&lt;br /&gt;
			return v;&lt;br /&gt;
		end,&lt;br /&gt;
	});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; N O W R A P _ D A T E &amp;gt;-------------------------&lt;br /&gt;
&lt;br /&gt;
When date is YYYY-MM-DD format wrap in nowrap span: &amp;lt;span ...&amp;gt;YYYY-MM-DD&amp;lt;/span&amp;gt;.&lt;br /&gt;
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:&lt;br /&gt;
&amp;lt;span ...&amp;gt;DD MMMM&amp;lt;/span&amp;gt; YYYY or &amp;lt;span ...&amp;gt;MMMM DD,&amp;lt;/span&amp;gt; YYYY&lt;br /&gt;
&lt;br /&gt;
DOES NOT yet support MMMM YYYY or any of the date ranges.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function nowrap_date (date)&lt;br /&gt;
	local cap = &#039;&#039;;&lt;br /&gt;
	local cap2 = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
	if date:match(&amp;quot;^%d%d%d%d%-%d%d%-%d%d$&amp;quot;) then&lt;br /&gt;
		date = utilities.substitute (cfg.presentation[&#039;nowrap1&#039;], date);&lt;br /&gt;
	&lt;br /&gt;
	elseif date:match(&amp;quot;^%a+%s*%d%d?,%s+%d%d%d%d$&amp;quot;) or date:match (&amp;quot;^%d%d?%s*%a+%s+%d%d%d%d$&amp;quot;) then&lt;br /&gt;
		cap, cap2 = string.match (date, &amp;quot;^(.*)%s+(%d%d%d%d)$&amp;quot;);&lt;br /&gt;
		date = utilities.substitute (cfg.presentation[&#039;nowrap2&#039;], {cap, cap2});&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return date;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S E T _ T I T L E T Y P E &amp;gt;---------------------&lt;br /&gt;
&lt;br /&gt;
This function sets default title types (equivalent to the citation including&lt;br /&gt;
|type=&amp;lt;default value&amp;gt;) for those templates that have defaults. Also handles the&lt;br /&gt;
special case where it is desirable to omit the title type from the rendered citation&lt;br /&gt;
(|type=none).&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function set_titletype (cite_class, title_type)&lt;br /&gt;
	if utilities.is_set (title_type) then&lt;br /&gt;
		if &#039;none&#039; == cfg.keywords_xlate[title_type] then&lt;br /&gt;
			title_type = &#039;&#039;;													-- if |type=none then type parameter not displayed&lt;br /&gt;
		end&lt;br /&gt;
		return title_type;														-- if |type= has been set to any other value use that value&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return cfg.title_types [cite_class] or &#039;&#039;;									-- set template&#039;s default title type; else empty string for concatenation&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; H Y P H E N _ T O _ D A S H &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Converts a hyphen to a dash under certain conditions.  The hyphen must separate&lt;br /&gt;
like items; unlike items are returned unmodified.  These forms are modified:&lt;br /&gt;
	letter - letter (A - B)&lt;br /&gt;
	digit - digit (4-5)&lt;br /&gt;
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)&lt;br /&gt;
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and&lt;br /&gt;
		digit is supported – a.1-a.5 or a-1-a-5)&lt;br /&gt;
	digitletter - digitletter (5a - 5d) (an optional separator between letter and&lt;br /&gt;
		digit is supported – 5.a-5.d or 5-a-5-d)&lt;br /&gt;
&lt;br /&gt;
any other forms are returned unmodified.&lt;br /&gt;
&lt;br /&gt;
str may be a comma- or semicolon-separated list&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function hyphen_to_dash( str )&lt;br /&gt;
	if not utilities.is_set (str) then&lt;br /&gt;
		return str;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local accept; -- Boolean&lt;br /&gt;
&lt;br /&gt;
	str = str:gsub (&#039;&amp;amp;[nm]dash;&#039;, {[&#039;&amp;amp;ndash;&#039;] = &#039;–&#039;, [&#039;&amp;amp;mdash;&#039;] = &#039;—&#039;});		-- replace &amp;amp;mdash; and &amp;amp;ndash; entities with their characters; semicolon mucks up the text.split&lt;br /&gt;
	str = str:gsub (&#039;&amp;amp;#45;&#039;, &#039;-&#039;); -- replace HTML numeric entity with hyphen character&lt;br /&gt;
&lt;br /&gt;
	str = str:gsub (&#039;&amp;amp;nbsp;&#039;, &#039; &#039;); -- replace &amp;amp;nbsp; entity with generic keyboard space character&lt;br /&gt;
	&lt;br /&gt;
	local out = {};&lt;br /&gt;
	local list = mw.text.split (str, &#039;%s*[,;]%s*&#039;);								-- split str at comma or semicolon separators if there are any&lt;br /&gt;
&lt;br /&gt;
	for _, item in ipairs (list) do												-- for each item in the list&lt;br /&gt;
		item, accept = utilities.has_accept_as_written (item);					-- remove accept-this-as-written markup when it wraps all of item&lt;br /&gt;
		if not accept and mw.ustring.match (item, &#039;^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$&#039;) then	-- if a hyphenated range or has endash or emdash separators&lt;br /&gt;
			if item:match (&#039;^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$&#039;) or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)&lt;br /&gt;
				item:match (&#039;^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$&#039;) or			-- digitletter hyphen digitletter (optional separator between digit and letter)&lt;br /&gt;
				item:match (&#039;^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$&#039;) or			-- digit separator digit hyphen digit separator digit&lt;br /&gt;
				item:match (&#039;^%d+%s*%-%s*%d+$&#039;) or								-- digit hyphen digit&lt;br /&gt;
				item:match (&#039;^%a+%s*%-%s*%a+$&#039;) then							-- letter hyphen letter&lt;br /&gt;
					item = item:gsub (&#039;(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)&#039;, &#039;%1–%2&#039;);	-- replace hyphen, remove extraneous space characters&lt;br /&gt;
			else&lt;br /&gt;
				item = mw.ustring.gsub (item, &#039;%s*[–—]%s*&#039;, &#039;–&#039;);				-- for endash or emdash separated ranges, replace em with en, remove extraneous whitespace&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		table.insert (out, item);												-- add the (possibly modified) item to the output table&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local temp_str = &#039;&#039;;														-- concatenate the output table into a comma separated string&lt;br /&gt;
	temp_str, accept = utilities.has_accept_as_written (table.concat (out, &#039;, &#039;)); -- remove accept-this-as-written markup when it wraps all of concatenated out&lt;br /&gt;
	if accept then&lt;br /&gt;
		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&lt;br /&gt;
		return temp_str;&lt;br /&gt;
	else&lt;br /&gt;
		return temp_str;														-- else, return assembled temp_str&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S A F E _ J O I N &amp;gt;-----------------------------&lt;br /&gt;
&lt;br /&gt;
Joins a sequence of strings together while checking for duplicate separation characters.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function safe_join( tbl, duplicate_char )&lt;br /&gt;
	local f = {};																-- create a function table appropriate to type of &#039;duplicate character&#039;&lt;br /&gt;
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions&lt;br /&gt;
			f.gsub = string.gsub&lt;br /&gt;
			f.match = string.match&lt;br /&gt;
			f.sub = string.sub&lt;br /&gt;
		else																	-- for multi-byte characters use the ustring library functions&lt;br /&gt;
			f.gsub = mw.ustring.gsub&lt;br /&gt;
			f.match = mw.ustring.match&lt;br /&gt;
			f.sub = mw.ustring.sub&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
	local str = &#039;&#039;;																-- the output string&lt;br /&gt;
	local comp = &#039;&#039;;															-- what does &#039;comp&#039; mean?&lt;br /&gt;
	local end_chr = &#039;&#039;;&lt;br /&gt;
	local trim;&lt;br /&gt;
	for _, value in ipairs( tbl ) do&lt;br /&gt;
		if value == nil then value = &#039;&#039;; end&lt;br /&gt;
		&lt;br /&gt;
		if str == &#039;&#039; then														-- if output string is empty&lt;br /&gt;
			str = value;														-- assign value to it (first time through the loop)&lt;br /&gt;
		elseif value ~= &#039;&#039; then&lt;br /&gt;
			if value:sub(1, 1) == &#039;&amp;lt;&#039; then										-- special case of values enclosed in spans and other markup.&lt;br /&gt;
				comp = value:gsub( &amp;quot;%b&amp;lt;&amp;gt;&amp;quot;, &amp;quot;&amp;quot; );								-- remove HTML markup (&amp;lt;span&amp;gt;string&amp;lt;/span&amp;gt; -&amp;gt; string)&lt;br /&gt;
			else&lt;br /&gt;
				comp = value;&lt;br /&gt;
			end&lt;br /&gt;
																				-- typically duplicate_char is sepc&lt;br /&gt;
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?&lt;br /&gt;
																				--   Because individual string segments often (always?) begin with terminal punct for the&lt;br /&gt;
																				--   preceding segment: &#039;First element&#039; .. &#039;sepc next element&#039; .. etc.?&lt;br /&gt;
				trim = false;&lt;br /&gt;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string&lt;br /&gt;
				-- str = str .. &amp;quot;&amp;lt;HERE(enchr=&amp;quot; .. end_chr .. &amp;quot;)&amp;quot;				-- debug stuff?&lt;br /&gt;
				if end_chr == duplicate_char then								-- if same as separator&lt;br /&gt;
					str = f.sub(str, 1, -2);									-- remove it&lt;br /&gt;
				elseif end_chr == &amp;quot;&#039;&amp;quot; then										-- if it might be wiki-markup&lt;br /&gt;
					if f.sub(str, -3, -1) == duplicate_char .. &amp;quot;&#039;&#039;&amp;quot; then		-- if last three chars of str are sepc&#039;&#039; &lt;br /&gt;
						str = f.sub(str, 1, -4) .. &amp;quot;&#039;&#039;&amp;quot;;						-- remove them and add back &#039;&#039;&lt;br /&gt;
					elseif  f.sub(str, -5, -1) == duplicate_char .. &amp;quot;]]&#039;&#039;&amp;quot; then	-- if last five chars of str are sepc]]&#039;&#039; &lt;br /&gt;
						trim = true;											-- why? why do this and next differently from previous?&lt;br /&gt;
					elseif f.sub(str, -4, -1) == duplicate_char .. &amp;quot;]&#039;&#039;&amp;quot; then	-- if last four chars of str are sepc]&#039;&#039; &lt;br /&gt;
						trim = true;											-- same question&lt;br /&gt;
					end&lt;br /&gt;
				elseif end_chr == &amp;quot;]&amp;quot; then										-- if it might be wiki-markup&lt;br /&gt;
					if f.sub(str, -3, -1) == duplicate_char .. &amp;quot;]]&amp;quot; then		-- if last three chars of str are sepc]] wikilink &lt;br /&gt;
						trim = true;&lt;br /&gt;
					elseif f.sub(str, -3, -1) == duplicate_char .. &#039;&amp;quot;]&#039; then	-- if last three chars of str are sepc&amp;quot;] quoted external link &lt;br /&gt;
						trim = true;&lt;br /&gt;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &amp;quot;]&amp;quot; then	-- if last two chars of str are sepc] external link&lt;br /&gt;
						trim = true;&lt;br /&gt;
					elseif f.sub(str, -4, -1) == duplicate_char .. &amp;quot;&#039;&#039;]&amp;quot; then	-- normal case when |url=something &amp;amp; |title=Title.&lt;br /&gt;
						trim = true;&lt;br /&gt;
					end&lt;br /&gt;
				elseif end_chr == &amp;quot; &amp;quot; then										-- if last char of output string is a space&lt;br /&gt;
					if f.sub(str, -2, -1) == duplicate_char .. &amp;quot; &amp;quot; then			-- if last two chars of str are &amp;lt;sepc&amp;gt;&amp;lt;space&amp;gt;&lt;br /&gt;
						str = f.sub(str, 1, -3);								-- remove them both&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
&lt;br /&gt;
				if trim then&lt;br /&gt;
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup&lt;br /&gt;
						local dup2 = duplicate_char;&lt;br /&gt;
						if f.match(dup2, &amp;quot;%A&amp;quot; ) then dup2 = &amp;quot;%&amp;quot; .. dup2; end	-- if duplicate_char not a letter then escape it&lt;br /&gt;
						&lt;br /&gt;
						value = f.gsub(value, &amp;quot;(%b&amp;lt;&amp;gt;)&amp;quot; .. dup2, &amp;quot;%1&amp;quot;, 1 )		-- remove duplicate_char if it follows HTML markup&lt;br /&gt;
					else&lt;br /&gt;
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			str = str .. value; 												-- add it to the output string&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return str;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ S U F F I X &amp;gt;-----------------------------&lt;br /&gt;
&lt;br /&gt;
returns true is suffix is properly formed Jr, Sr, or ordinal in the range 1–9.&lt;br /&gt;
Puncutation not allowed.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_suffix (suffix)&lt;br /&gt;
	if utilities.in_array (suffix, {&#039;Jr&#039;, &#039;Sr&#039;, &#039;Jnr&#039;, &#039;Snr&#039;, &#039;1st&#039;, &#039;2nd&#039;, &#039;3rd&#039;}) or suffix:match (&#039;^%dth$&#039;) then&lt;br /&gt;
		return true;&lt;br /&gt;
	end&lt;br /&gt;
	return false;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------&amp;lt; I S _ G O O D _ V A N C _ N A M E &amp;gt;-------------------&lt;br /&gt;
&lt;br /&gt;
For Vancouver style, author/editor names are supposed to be rendered in Latin&lt;br /&gt;
(read ASCII) characters.  When a name uses characters that contain diacritical&lt;br /&gt;
marks, those characters are to be converted to the corresponding Latin&lt;br /&gt;
character. When a name is written using a non-Latin alphabet or logogram, that&lt;br /&gt;
name is to be transliterated into Latin characters. The module doesn&#039;t do this&lt;br /&gt;
so editors may/must.&lt;br /&gt;
&lt;br /&gt;
This test allows |first= and |last= names to contain any of the letters defined&lt;br /&gt;
in the four Unicode Latin character sets&lt;br /&gt;
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A&lt;br /&gt;
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF&lt;br /&gt;
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F&lt;br /&gt;
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F&lt;br /&gt;
&lt;br /&gt;
|lastn= also allowed to contain hyphens, spaces, and apostrophes.&lt;br /&gt;
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)&lt;br /&gt;
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods&lt;br /&gt;
&lt;br /&gt;
This original test:&lt;br /&gt;
	if nil == mw.ustring.find (last, &amp;quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%&#039;]*$&amp;quot;)&lt;br /&gt;
	or nil == mw.ustring.find (first, &amp;quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%&#039;%.]+[2-6%a]*$&amp;quot;) then&lt;br /&gt;
was written outside of the code editor and pasted here because the code editor&lt;br /&gt;
gets confused between character insertion point and cursor position. The test has&lt;br /&gt;
been rewritten to use decimal character escape sequence for the individual bytes&lt;br /&gt;
of the Unicode characters so that it is not necessary to use an external editor&lt;br /&gt;
to maintain this code.&lt;br /&gt;
&lt;br /&gt;
	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)&lt;br /&gt;
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)&lt;br /&gt;
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp;amp; B)&lt;br /&gt;
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_good_vanc_name (last, first, suffix, position)&lt;br /&gt;
	if not suffix then&lt;br /&gt;
		if first:find (&#039;[,%s]&#039;) then											-- when there is a space or comma, might be first name/initials + generational suffix&lt;br /&gt;
			first = first:match (&#039;(.-)[,%s]+&#039;);									-- get name/initials&lt;br /&gt;
			suffix = first:match (&#039;[,%s]+(.+)$&#039;);								-- get generational suffix&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if utilities.is_set (suffix) then&lt;br /&gt;
		if not is_suffix (suffix) then&lt;br /&gt;
			add_vanc_error (cfg.err_msg_supl.suffix, position);&lt;br /&gt;
			return false;														-- not a name with an appropriate suffix&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if nil == mw.ustring.find (last, &amp;quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%&#039;]*$&amp;quot;) or&lt;br /&gt;
		nil == mw.ustring.find (first, &amp;quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%&#039;%.]*$&amp;quot;) then&lt;br /&gt;
			add_vanc_error (cfg.err_msg_supl[&#039;non-Latin char&#039;], position);&lt;br /&gt;
			return false;														-- not a string of Latin characters; Vancouver requires Romanization&lt;br /&gt;
	end;&lt;br /&gt;
	return true;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; R E D U C E _ T O _ I N I T I A L S &amp;gt;------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Attempts to convert names to initials in support of |name-list-style=vanc.  &lt;br /&gt;
&lt;br /&gt;
Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.&lt;br /&gt;
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.&lt;br /&gt;
&lt;br /&gt;
Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered&lt;br /&gt;
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.&lt;br /&gt;
This code only accepts and understands generational suffix in the Vancouver format&lt;br /&gt;
because Roman numerals look like, and can be mistaken for, initials.&lt;br /&gt;
&lt;br /&gt;
This function uses ustring functions because firstname initials may be any of the&lt;br /&gt;
Unicode Latin characters accepted by is_good_vanc_name ().&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function reduce_to_initials(first, position)&lt;br /&gt;
	local name, suffix = mw.ustring.match(first, &amp;quot;^(%u+) ([%dJS][%drndth]+)$&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if not name then															-- if not initials and a suffix&lt;br /&gt;
		name = mw.ustring.match(first, &amp;quot;^(%u+)$&amp;quot;);								-- is it just initials?&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if name then																-- if first is initials with or without suffix&lt;br /&gt;
		if 3 &amp;gt; mw.ustring.len (name) then										-- if one or two initials&lt;br /&gt;
			if suffix then														-- if there is a suffix&lt;br /&gt;
				if is_suffix (suffix) then										-- is it legitimate?&lt;br /&gt;
					return first;												-- one or two initials and a valid suffix so nothing to do&lt;br /&gt;
				else&lt;br /&gt;
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message&lt;br /&gt;
					return first;												-- and return first unmolested&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				return first;													-- one or two initials without suffix; nothing to do&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word&lt;br /&gt;
&lt;br /&gt;
	local initials, names = {}, {};												-- tables to hold name parts and initials&lt;br /&gt;
	local i = 1;																-- counter for number of initials&lt;br /&gt;
&lt;br /&gt;
	names = mw.text.split (first, &#039;[%s,]+&#039;);									-- split into a table of names and possible suffix&lt;br /&gt;
&lt;br /&gt;
	while names[i] do															-- loop through the table&lt;br /&gt;
		if 1 &amp;lt; i and names[i]:match (&#039;[%dJS][%drndth]+%.?$&#039;) then				-- if not the first name, and looks like a suffix (may have trailing dot)&lt;br /&gt;
			names[i] = names[i]:gsub (&#039;%.&#039;, &#039;&#039;);								-- remove terminal dot if present&lt;br /&gt;
			if is_suffix (names[i]) then										-- if a legitimate suffix&lt;br /&gt;
				table.insert (initials, &#039; &#039; .. names[i]);						-- add a separator space, insert at end of initials table&lt;br /&gt;
				break;															-- and done because suffix must fall at the end of a name&lt;br /&gt;
			end																	-- no error message if not a suffix; possibly because of Romanization&lt;br /&gt;
		end&lt;br /&gt;
		if 3 &amp;gt; i then&lt;br /&gt;
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table&lt;br /&gt;
		end&lt;br /&gt;
		i = i + 1;																-- bump the counter&lt;br /&gt;
	end&lt;br /&gt;
			&lt;br /&gt;
	return table.concat(initials)												-- Vancouver format does not include spaces.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; L I S T _ P E O P L E &amp;gt;--------------------------&lt;br /&gt;
&lt;br /&gt;
Formats a list of people (authors, contributors, editors, interviewers, translators) &lt;br /&gt;
&lt;br /&gt;
names in the list will be linked when&lt;br /&gt;
	|&amp;lt;name&amp;gt;-link= has a value&lt;br /&gt;
	|&amp;lt;name&amp;gt;-mask- does NOT have a value; masked names are presumed to have been&lt;br /&gt;
		rendered previously so should have been linked there&lt;br /&gt;
&lt;br /&gt;
when |&amp;lt;name&amp;gt;-mask=0, the associated name is not rendered&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function list_people (control, people, etal)&lt;br /&gt;
	local sep;&lt;br /&gt;
	local namesep;&lt;br /&gt;
	local format = control.format;&lt;br /&gt;
	local maximum = control.maximum;&lt;br /&gt;
	local name_list = {};&lt;br /&gt;
&lt;br /&gt;
	if &#039;vanc&#039; == format then													-- Vancouver-like name styling?&lt;br /&gt;
		sep = cfg.presentation[&#039;sep_nl_vanc&#039;];									-- name-list separator between names is a comma&lt;br /&gt;
		namesep = cfg.presentation[&#039;sep_name_vanc&#039;];							-- last/first separator is a space&lt;br /&gt;
	else&lt;br /&gt;
		sep = cfg.presentation[&#039;sep_nl&#039;];										-- name-list separator between names is a semicolon&lt;br /&gt;
		namesep = cfg.presentation[&#039;sep_name&#039;];									-- last/first separator is &amp;lt;comma&amp;gt;&amp;lt;space&amp;gt;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if sep:sub (-1, -1) ~= &amp;quot; &amp;quot; then sep = sep .. &amp;quot; &amp;quot; end&lt;br /&gt;
	if utilities.is_set (maximum) and maximum &amp;lt; 1 then return &amp;quot;&amp;quot;, 0; end		-- returned 0 is for EditorCount; not used for other names&lt;br /&gt;
	&lt;br /&gt;
	for i, person in ipairs (people) do&lt;br /&gt;
		if utilities.is_set (person.last) then&lt;br /&gt;
			local mask = person.mask;&lt;br /&gt;
			local one;&lt;br /&gt;
			local sep_one = sep;&lt;br /&gt;
&lt;br /&gt;
			if utilities.is_set (maximum) and i &amp;gt; maximum then&lt;br /&gt;
				etal = true;&lt;br /&gt;
				break;&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			if mask then&lt;br /&gt;
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else&lt;br /&gt;
				if n then&lt;br /&gt;
					one = 0 ~= n and string.rep(&amp;quot;&amp;amp;mdash;&amp;quot;, n) or nil;			-- make a string of (n &amp;gt; 0) mdashes, nil else, to replace name&lt;br /&gt;
					person.link = nil;											-- don&#039;t create link to name if name is replaces with mdash string or has been set nil&lt;br /&gt;
				else&lt;br /&gt;
					one = mask;													-- replace name with mask text (must include name-list separator)&lt;br /&gt;
					sep_one = &amp;quot; &amp;quot;;												-- modify name-list separator&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				one = person.last;												-- get surname&lt;br /&gt;
				local first = person.first										-- get given name&lt;br /&gt;
				if utilities.is_set (first) then&lt;br /&gt;
					if (&amp;quot;vanc&amp;quot; == format) then									-- if Vancouver format&lt;br /&gt;
						one = one:gsub (&#039;%.&#039;, &#039;&#039;);								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)&lt;br /&gt;
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested&lt;br /&gt;
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
					one = one .. namesep .. first;&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if utilities.is_set (person.link) then&lt;br /&gt;
				one = utilities.make_wikilink (person.link, one);				-- link author/editor&lt;br /&gt;
			end&lt;br /&gt;
			if one then															-- if &amp;lt;one&amp;gt; has a value (name, mdash replacement, or mask text replacement)&lt;br /&gt;
				table.insert (name_list, one);									-- add it to the list of names&lt;br /&gt;
				table.insert (name_list, sep_one);								-- add the proper name-list separator&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2&lt;br /&gt;
	if 0 &amp;lt; count then &lt;br /&gt;
		if 1 &amp;lt; count and not etal then&lt;br /&gt;
			if &#039;amp&#039; == format then&lt;br /&gt;
				name_list[#name_list-2] = &amp;quot; &amp;amp; &amp;quot;;								-- replace last separator with ampersand text&lt;br /&gt;
			elseif &#039;and&#039; == format then&lt;br /&gt;
				if 2 == count then&lt;br /&gt;
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with &#039;and&#039; text&lt;br /&gt;
				else&lt;br /&gt;
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with &#039;(sep) and&#039; text&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		name_list[#name_list] = nil;											-- erase the last separator&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local result = table.concat (name_list);									-- construct list&lt;br /&gt;
	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&lt;br /&gt;
		result = result .. sep .. &#039; &#039; .. cfg.messages[&#039;et al&#039;];					-- we&#039;ve got a last-first list and etal so add et al.&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------&amp;lt; M A K E _ C I T E R E F _ I D &amp;gt;-----------------------&lt;br /&gt;
&lt;br /&gt;
Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise&lt;br /&gt;
returns an empty string.&lt;br /&gt;
&lt;br /&gt;
namelist is one of the contributor-, author-, or editor-name lists chosen in that&lt;br /&gt;
order.  year is Year or anchor_year.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function make_citeref_id (namelist, year)&lt;br /&gt;
	local names={};							-- a table for the one to four names and year&lt;br /&gt;
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names&lt;br /&gt;
		names[i] = v.last&lt;br /&gt;
		if i == 4 then break end			-- if four then done&lt;br /&gt;
	end&lt;br /&gt;
	table.insert (names, year);				-- add the year at the end&lt;br /&gt;
	local id = table.concat(names);			-- concatenate names and year for CITEREF id&lt;br /&gt;
	if utilities.is_set (id) then			-- if concatenation is not an empty string&lt;br /&gt;
		return &amp;quot;CITEREF&amp;quot; .. id;				-- add the CITEREF portion&lt;br /&gt;
	else&lt;br /&gt;
		return &#039;&#039;;							-- return an empty string; no reason to include CITEREF id in this citation&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[---------------------&amp;lt; N A M E _ H A S _ E T A L &amp;gt;--------------------------&lt;br /&gt;
&lt;br /&gt;
Evaluates the content of name parameters (author, editor, etc.) for variations on&lt;br /&gt;
the theme of et al.  If found, the et al. is removed, a flag is set to true and&lt;br /&gt;
the function returns the modified name and the flag.&lt;br /&gt;
&lt;br /&gt;
This function never sets the flag to false but returns its previous state because&lt;br /&gt;
it may have been set by previous passes through this function or by the associated&lt;br /&gt;
|display-&amp;lt;names&amp;gt;=etal parameter&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function name_has_etal (name, etal, nocat, param)&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (name) then												-- name can be nil in which case just return&lt;br /&gt;
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration&lt;br /&gt;
		&lt;br /&gt;
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns&lt;br /&gt;
			if name:match (pattern) then										-- if this &#039;et al&#039; pattern is found in name&lt;br /&gt;
				name = name:gsub (pattern, &#039;&#039;);									-- remove the offending text&lt;br /&gt;
				etal = true;													-- set flag (may have been set previously here or by |display-&amp;lt;names&amp;gt;=etal)&lt;br /&gt;
				if not nocat then												-- no categorization for |vauthors=&lt;br /&gt;
					table.insert( z.message_tail, {utilities.set_message (&#039;err_etal&#039;, {param})});	-- and set an error if not added&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return name, etal;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[---------------------&amp;lt; N A M E _ I S _ N U M E R I C &amp;gt;----------------------&lt;br /&gt;
&lt;br /&gt;
Add maint cat when name parameter value does not contain letters.  Does not catch&lt;br /&gt;
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the&lt;br /&gt;
current version of this test but |first=(1888) is caught.&lt;br /&gt;
&lt;br /&gt;
returns nothing&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function name_is_numeric (name, list_name)&lt;br /&gt;
	if utilities.is_set (name) then&lt;br /&gt;
		if mw.ustring.match (name, &#039;^[%A]+$&#039;) then								-- when name does not contain any letters&lt;br /&gt;
			utilities.set_message (&#039;maint_numeric_names&#039;, cfg.special_case_translation [list_name]);	-- add a maint cat for this template&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[-------------------&amp;lt; N A M E _ H A S _ E D _ M A R K U P &amp;gt;------------------&lt;br /&gt;
&lt;br /&gt;
Evaluates the content of author and editor parameters for extraneous editor annotations:&lt;br /&gt;
ed, ed., eds, (Ed.), etc. These annotations do not belong in author parameters and&lt;br /&gt;
are redundant in editor parameters.  If found, the function adds the editor markup&lt;br /&gt;
maintenance category.&lt;br /&gt;
&lt;br /&gt;
returns nothing&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function name_has_ed_markup (name, list_name)&lt;br /&gt;
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (name) then&lt;br /&gt;
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and&lt;br /&gt;
			if name:match (pattern) then&lt;br /&gt;
				utilities.set_message (&#039;maint_extra_text_names&#039;, cfg.special_case_translation [list_name]);	-- add a maint cat for this template&lt;br /&gt;
				break;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[-----------------&amp;lt; N A M E _ H A S _ M U L T _ N A M E S &amp;gt;------------------&lt;br /&gt;
&lt;br /&gt;
Evaluates the content of last/surname (authors etc.) parameters for multiple names.&lt;br /&gt;
Multiple names are indicated if there is more than one comma or any &amp;quot;unescaped&amp;quot;&lt;br /&gt;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.&lt;br /&gt;
If the condition is met, the function adds the multiple name maintenance category.&lt;br /&gt;
&lt;br /&gt;
returns nothing&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function name_has_mult_names (name, list_name)&lt;br /&gt;
	local _, commas, semicolons, nbsps;&lt;br /&gt;
	if utilities.is_set (name) then&lt;br /&gt;
		_, commas = name:gsub (&#039;,&#039;, &#039;&#039;);										-- count the number of commas&lt;br /&gt;
		_, semicolons = name:gsub (&#039;;&#039;, &#039;&#039;);									-- count the number of semicolons&lt;br /&gt;
		-- nbsps probably should be its own separate count rather than merged in&lt;br /&gt;
		-- some way with semicolons because Lua patterns do not support the&lt;br /&gt;
		-- grouping operator that regex does, which means there is no way to add&lt;br /&gt;
		-- more entities to escape except by adding more counts with the new&lt;br /&gt;
		-- entities&lt;br /&gt;
		_, nbsps = name:gsub (&#039;&amp;amp;nbsp;&#039;,&#039;&#039;);										-- count nbsps&lt;br /&gt;
		&lt;br /&gt;
		-- There is exactly 1 semicolon per &amp;amp;nbsp; entity, so subtract nbsps&lt;br /&gt;
		-- from semicolons to &#039;escape&#039; them. If additional entities are added,&lt;br /&gt;
		-- they also can be subtracted.&lt;br /&gt;
		if 1 &amp;lt; commas or 0 &amp;lt; (semicolons - nbsps) then&lt;br /&gt;
			utilities.set_message (&#039;maint_mult_names&#039;, cfg.special_case_translation [list_name]);	-- add a maint message&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[------------------------&amp;lt; N A M E _ C H E C K S &amp;gt;---------------------------&lt;br /&gt;
&lt;br /&gt;
This function calls various name checking functions used to validate the content&lt;br /&gt;
of the various name-holding parameters.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function name_checks (last, first, list_name)&lt;br /&gt;
	local accept_name;&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (last) then&lt;br /&gt;
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &amp;lt;last&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
		if not accept_name then													-- &amp;lt;last&amp;gt; not wrapped in accept-as-written markup&lt;br /&gt;
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)&lt;br /&gt;
			name_has_ed_markup (last, list_name);								-- check for extraneous &#039;editor&#039; annotation&lt;br /&gt;
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (first) then&lt;br /&gt;
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &amp;lt;first&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		if not accept_name then													-- &amp;lt;first&amp;gt; not wrapped in accept-as-written markup&lt;br /&gt;
			name_has_ed_markup (first, list_name);								-- check for extraneous &#039;editor&#039; annotation&lt;br /&gt;
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return last, first;															-- done&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[----------------------&amp;lt; E X T R A C T _ N A M E S &amp;gt;-------------------------&lt;br /&gt;
Gets name list from the input arguments&lt;br /&gt;
&lt;br /&gt;
Searches through args in sequential order to find |lastn= and |firstn= parameters&lt;br /&gt;
(or their aliases), and their matching link and mask parameters. Stops searching&lt;br /&gt;
when both |lastn= and |firstn= are not found in args after two sequential attempts:&lt;br /&gt;
found |last1=, |last2=, and |last3= but doesn&#039;t find |last4= and |last5= then the&lt;br /&gt;
search is done.&lt;br /&gt;
&lt;br /&gt;
This function emits an error message when there is a |firstn= without a matching&lt;br /&gt;
|lastn=.  When there are &#039;holes&#039; in the list of last names, |last1= and |last3=&lt;br /&gt;
are present but |last2= is missing, an error message is emitted. |lastn= is not&lt;br /&gt;
required to have a matching |firstn=.&lt;br /&gt;
&lt;br /&gt;
When an author or editor parameter contains some form of &#039;et al.&#039;, the &#039;et al.&#039;&lt;br /&gt;
is stripped from the parameter and a flag (etal) returned that will cause list_people()&lt;br /&gt;
to add the static &#039;et al.&#039; text from Module:Citation/CS1/Configuration.  This keeps&lt;br /&gt;
&#039;et al.&#039; out of the template&#039;s metadata.  When this occurs, an error is emitted.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function extract_names(args, list_name)&lt;br /&gt;
	local names = {};															-- table of names&lt;br /&gt;
	local last;																	-- individual name components&lt;br /&gt;
	local first;&lt;br /&gt;
	local link;&lt;br /&gt;
	local mask;&lt;br /&gt;
	local i = 1;																-- loop counter/indexer&lt;br /&gt;
	local n = 1;																-- output table indexer&lt;br /&gt;
	local count = 0;															-- used to count the number of times we haven&#039;t found a |last= (or alias for authors, |editor-last or alias for editors)&lt;br /&gt;
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter&lt;br /&gt;
&lt;br /&gt;
	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging&lt;br /&gt;
	while true do&lt;br /&gt;
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. &#039;-Last&#039;], &#039;err_redundant_parameters&#039;, i );		-- search through args for name components beginning at 1&lt;br /&gt;
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. &#039;-First&#039;], &#039;err_redundant_parameters&#039;, i );&lt;br /&gt;
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. &#039;-Link&#039;], &#039;err_redundant_parameters&#039;, i );&lt;br /&gt;
		mask = utilities.select_one ( args, cfg.aliases[list_name .. &#039;-Mask&#039;], &#039;err_redundant_parameters&#039;, i );&lt;br /&gt;
&lt;br /&gt;
		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.&lt;br /&gt;
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.&lt;br /&gt;
		last, first = name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc. checks&lt;br /&gt;
		&lt;br /&gt;
		if first and not last then												-- if there is a firstn without a matching lastn&lt;br /&gt;
			local alias = first_alias:find (&#039;given&#039;, 1, true) and &#039;given&#039; or &#039;first&#039;;	-- get first or given form of the alias&lt;br /&gt;
			table.insert (z.message_tail, { utilities.set_message ( &#039;err_first_missing_last&#039;, {&lt;br /&gt;
				first_alias,													-- param name of alias missing its mate&lt;br /&gt;
				first_alias:gsub (alias, {[&#039;first&#039;] = &#039;last&#039;, [&#039;given&#039;] = &#039;surname&#039;}),	-- make param name appropriate to the alias form&lt;br /&gt;
				}, true ) } );													-- add this error message&lt;br /&gt;
		elseif not first and not last then										-- if both firstn and lastn aren&#039;t found, are we done?&lt;br /&gt;
			count = count + 1;													-- number of times we haven&#039;t found last and first&lt;br /&gt;
			if 2 &amp;lt;= count then													-- two missing names and we give up&lt;br /&gt;
				break;															-- normal exit or there is a two-name hole in the list; can&#039;t tell which&lt;br /&gt;
			end&lt;br /&gt;
		else																	-- we have last with or without a first&lt;br /&gt;
			local result;&lt;br /&gt;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup&lt;br /&gt;
			if first then&lt;br /&gt;
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)&lt;br /&gt;
			n = n + 1;															-- point to next location in the names table&lt;br /&gt;
			if 1 == count then													-- if the previous name was missing&lt;br /&gt;
				table.insert( z.message_tail, { utilities.set_message ( &#039;err_missing_name&#039;, {list_name:match (&amp;quot;(%w+)List&amp;quot;):lower(), i - 1}, true ) } );	-- add this error message&lt;br /&gt;
			end&lt;br /&gt;
			count = 0;															-- reset the counter, we&#039;re looking for two consecutive missing names&lt;br /&gt;
		end&lt;br /&gt;
		i = i + 1;																-- point to next args location&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return names, etal;															-- all done, return our list of names and the etal flag&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[---------------------&amp;lt; G E T _ I S O 6 3 9 _ C O D E &amp;gt;----------------------&lt;br /&gt;
&lt;br /&gt;
Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.&lt;br /&gt;
&lt;br /&gt;
Returns the language name and associated two- or three-character code.  Because&lt;br /&gt;
case of the source may be incorrect or different from the case that WikiMedia uses,&lt;br /&gt;
the name comparisons are done in lower case and when a match is found, the Wikimedia&lt;br /&gt;
version (assumed to be correct) is returned along with the code.  When there is no&lt;br /&gt;
match, we return the original language name string.&lt;br /&gt;
&lt;br /&gt;
mw.language.fetchLanguageNames(&amp;lt;local wiki language&amp;gt;, &#039;all&#039;) returns a list of&lt;br /&gt;
languages that in some cases may include extensions. For example, code &#039;cbk-zam&#039;&lt;br /&gt;
and its associated name &#039;Chavacano de Zamboanga&#039; (MediaWiki does not support&lt;br /&gt;
code &#039;cbk&#039; or name &#039;Chavacano&#039;.  Most (all?) of these languages are not used a&lt;br /&gt;
&#039;language&#039; codes per se, rather they are used as sub-domain names: cbk-zam.wikipedia.org.&lt;br /&gt;
A list of language names and codes supported by fetchLanguageNames() can be found&lt;br /&gt;
at Template:Citation Style documentation/language/doc&lt;br /&gt;
&lt;br /&gt;
Names that are included in the list will be found if that name is provided in the&lt;br /&gt;
|language= parameter.  For example, if |language=Chavacano de Zamboanga, that name&lt;br /&gt;
will be found with the associated code &#039;cbk-zam&#039;.  When names are found and the&lt;br /&gt;
associated code is not two or three characters, this function returns only the&lt;br /&gt;
WikiMedia language name.&lt;br /&gt;
&lt;br /&gt;
Some language names have multiple entries under different codes:&lt;br /&gt;
	Aromanian has code rup and code roa-rup&lt;br /&gt;
When this occurs, this function returns the language name and the 2- or 3-character code&lt;br /&gt;
&lt;br /&gt;
Adapted from code taken from Module:Check ISO 639-1.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function get_iso639_code (lang, this_wiki_code)&lt;br /&gt;
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don&#039;t think is correct)&lt;br /&gt;
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language &#039;name&#039;, return a possibly new name and appropriate code&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local ietf_code;															-- because some languages have both IETF-like codes and ISO 639-like codes&lt;br /&gt;
	local ietf_name;&lt;br /&gt;
	&lt;br /&gt;
	local langlc = mw.ustring.lower (lang);										-- lower-case version for comparisons&lt;br /&gt;
&lt;br /&gt;
	for code, name in pairs (cfg.languages) do									-- scan the list to see if we can find our language&lt;br /&gt;
		if langlc == mw.ustring.lower (name) then&lt;br /&gt;
			if 2 == #code or 3 == #code then									-- two- or three-character codes only; IETF extensions not supported&lt;br /&gt;
				return name, code;												-- so return the name and the code&lt;br /&gt;
			end&lt;br /&gt;
			ietf_code = code;													-- remember that we found an IETF-like code and save its name&lt;br /&gt;
			ietf_name = name;													-- but keep looking for a 2- or 3-char code&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
																				-- didn&#039;t find name with 2- or 3-char code; if IETF-like code found return&lt;br /&gt;
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[-------------------&amp;lt; L A N G U A G E _ P A R A M E T E R &amp;gt;------------------&lt;br /&gt;
&lt;br /&gt;
Gets language name from a provided two- or three-character ISO 639 code.  If a code&lt;br /&gt;
is recognized by MediaWiki, use the returned name; if not, then use the value that&lt;br /&gt;
was provided with the language parameter.&lt;br /&gt;
&lt;br /&gt;
When |language= contains a recognized language (either code or name), the page is&lt;br /&gt;
assigned to the category for that code: Category:Norwegian-language sources (no).&lt;br /&gt;
For valid three-character code languages, the page is assigned to the single category&lt;br /&gt;
for &#039;639-2&#039; codes: Category:CS1 ISO 639-2 language sources.&lt;br /&gt;
&lt;br /&gt;
Languages that are the same as the local wiki are not categorized.  MediaWiki does&lt;br /&gt;
not recognize three-character equivalents of two-character codes: code &#039;ar&#039; is&lt;br /&gt;
recognized but code &#039;ara&#039; is not.&lt;br /&gt;
&lt;br /&gt;
This function supports multiple languages in the form |language=nb, French, th&lt;br /&gt;
where the language names or codes are separated from each other by commas with&lt;br /&gt;
optional space characters.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function language_parameter (lang)&lt;br /&gt;
	local code;																	-- the two- or three-character language code&lt;br /&gt;
	local name;																	-- the language name&lt;br /&gt;
	local language_list = {};													-- table of language names to be rendered&lt;br /&gt;
	local names_table = {};														-- table made from the value assigned to |language=&lt;br /&gt;
&lt;br /&gt;
	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki&#039;s language name&lt;br /&gt;
&lt;br /&gt;
	names_table = mw.text.split (lang, &#039;%s*,%s*&#039;);								-- names should be a comma separated list&lt;br /&gt;
&lt;br /&gt;
	for _, lang in ipairs (names_table) do										-- reuse lang&lt;br /&gt;
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap&lt;br /&gt;
&lt;br /&gt;
		if name then															-- there was a remapped code so&lt;br /&gt;
			if not lang:match (&#039;^%a%a%a?%-x%-%a+$&#039;) then						-- if not a private IETF tag&lt;br /&gt;
				lang = lang:gsub (&#039;^(%a%a%a?)%-.*&#039;, &#039;%1&#039;);						-- strip IETF tags from code&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			lang = lang:gsub (&#039;^(%a%a%a?)%-.*&#039;, &#039;%1&#039;);							-- strip any IETF-like tags from code&lt;br /&gt;
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code&lt;br /&gt;
				name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if |language= is a proper code&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if utilities.is_set (name) then											-- if |language= specified a valid code&lt;br /&gt;
			code = lang:lower();												-- save it&lt;br /&gt;
		else&lt;br /&gt;
			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)&lt;br /&gt;
		end&lt;br /&gt;
	&lt;br /&gt;
		if utilities.is_set (code) then											-- only 2- or 3-character codes&lt;br /&gt;
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names&lt;br /&gt;
&lt;br /&gt;
			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki&#039;s language&lt;br /&gt;
				if 2 == code:len() then											-- and is a two-character code&lt;br /&gt;
					utilities.add_prop_cat (&#039;foreign_lang_source&#039; .. code, {name, code});	-- categorize it; code appended to allow for multiple language categorization&lt;br /&gt;
				else															-- or is a recognized language (but has a three-character code)&lt;br /&gt;
					utilities.add_prop_cat (&#039;foreign_lang_source_2&#039; .. code, {code});		-- categorize it differently TODO: support multiple three-character code categories per cs1|2 template&lt;br /&gt;
				end&lt;br /&gt;
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki&#039;s language are the same and categorization is enabled&lt;br /&gt;
				utilities.add_prop_cat (&#039;local_lang_source&#039;, {name, code});		-- categorize it&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			utilities.set_message (&#039;maint_unknown_lang&#039;);						-- add maint category if not already added&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		table.insert (language_list, name);&lt;br /&gt;
		name = &#039;&#039;;																-- so we can reuse it&lt;br /&gt;
	end&lt;br /&gt;
 &lt;br /&gt;
	name = utilities.make_sep_list (#language_list, language_list);&lt;br /&gt;
&lt;br /&gt;
	if this_wiki_name == name then&lt;br /&gt;
		return &#039;&#039;;																-- if one language and that language is this wiki&#039;s return an empty string (no annotation)&lt;br /&gt;
	end&lt;br /&gt;
	return (&amp;quot; &amp;quot; .. wrap_msg (&#039;language&#039;, name));								-- otherwise wrap with &#039;(in ...)&#039;&lt;br /&gt;
	--[[ TODO: should only return blank or name rather than full list&lt;br /&gt;
	so we can clean up the bunched parenthetical elements Language, Type, Format&lt;br /&gt;
	]]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[-----------------------&amp;lt; S E T _ C S _ S T Y L E &amp;gt;--------------------------&lt;br /&gt;
Gets the default CS style configuration for the given mode.&lt;br /&gt;
Returns default separator and either postscript as passed in or the default.&lt;br /&gt;
In CS1, the default postscript and separator are &#039;.&#039;.&lt;br /&gt;
In CS2, the default postscript is the empty string and the default separator is &#039;,&#039;.&lt;br /&gt;
]]&lt;br /&gt;
local function set_cs_style (postscript, mode)&lt;br /&gt;
	if utilities.is_set(postscript) then&lt;br /&gt;
		-- emit a maintenance message if user postscript is the default cs1 postscript&lt;br /&gt;
		-- we catch the opposite case for cs2 in set_style&lt;br /&gt;
		if mode == &#039;cs1&#039; and postscript == cfg.presentation[&#039;ps_&#039; .. mode] then&lt;br /&gt;
			utilities.set_message (&#039;maint_postscript&#039;);&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		postscript = cfg.presentation[&#039;ps_&#039; .. mode];&lt;br /&gt;
	end&lt;br /&gt;
	return cfg.presentation[&#039;sep_&#039; .. mode], postscript;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S E T _ S T Y L E &amp;gt;-----------------------------&lt;br /&gt;
Sets the separator and postscript styles. Checks the |mode= first and the&lt;br /&gt;
#invoke CitationClass second. Removes the postscript if postscript == none.&lt;br /&gt;
]]&lt;br /&gt;
local function set_style (mode, postscript, cite_class)&lt;br /&gt;
	local sep;&lt;br /&gt;
	if &#039;cs2&#039; == mode then&lt;br /&gt;
		sep, postscript = set_cs_style (postscript, &#039;cs2&#039;);&lt;br /&gt;
	elseif &#039;cs1&#039; == mode then&lt;br /&gt;
		sep, postscript = set_cs_style (postscript, &#039;cs1&#039;);&lt;br /&gt;
	elseif &#039;citation&#039; == cite_class	then&lt;br /&gt;
		sep, postscript = set_cs_style (postscript, &#039;cs2&#039;);&lt;br /&gt;
	else&lt;br /&gt;
		sep, postscript = set_cs_style (postscript, &#039;cs1&#039;);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if cfg.keywords_xlate[postscript:lower()] == &#039;none&#039; then&lt;br /&gt;
		-- emit a maintenance message if user postscript is the default cs2 postscript&lt;br /&gt;
		-- we catch the opposite case for cs1 in set_cs_style&lt;br /&gt;
		if &#039;cs2&#039; == mode or &#039;citation&#039; == cite_class then&lt;br /&gt;
			utilities.set_message (&#039;maint_postscript&#039;);&lt;br /&gt;
		end&lt;br /&gt;
		postscript = &#039;&#039;;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return sep, postscript&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[=[-------------------------&amp;lt; I S _ P D F &amp;gt;-----------------------------------&lt;br /&gt;
&lt;br /&gt;
Determines if a URL has the file extension that is one of the PDF file extensions&lt;br /&gt;
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.&lt;br /&gt;
&lt;br /&gt;
returns true if file extension is one of the recognized extensions, else false&lt;br /&gt;
&lt;br /&gt;
]=]&lt;br /&gt;
&lt;br /&gt;
local function is_pdf (url)&lt;br /&gt;
	return url:match (&#039;%.pdf$&#039;) or url:match (&#039;%.PDF$&#039;) or&lt;br /&gt;
		url:match (&#039;%.pdf[%?#]&#039;) or url:match (&#039;%.PDF[%?#]&#039;) or&lt;br /&gt;
		url:match (&#039;%.PDF&amp;amp;#035&#039;) or url:match (&#039;%.pdf&amp;amp;#035&#039;);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S T Y L E _ F O R M A T &amp;gt;-----------------------&lt;br /&gt;
&lt;br /&gt;
Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message&lt;br /&gt;
if the format parameter does not have a matching URL parameter.  If the format parameter&lt;br /&gt;
is not set and the URL contains a file extension that is recognized as a PDF document&lt;br /&gt;
by MediaWiki&#039;s commons.css, this code will set the format parameter to (PDF) with&lt;br /&gt;
the appropriate styling.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function style_format (format, url, fmt_param, url_param)&lt;br /&gt;
	if utilities.is_set (format) then&lt;br /&gt;
		format = utilities.wrap_style (&#039;format&#039;, format);						-- add leading space, parentheses, resize&lt;br /&gt;
		if not utilities.is_set (url) then&lt;br /&gt;
			format = format .. &#039; &#039; .. utilities.set_message ( &#039;err_format_missing_url&#039;, {fmt_param, url_param} );	-- add an error message&lt;br /&gt;
		end&lt;br /&gt;
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then&lt;br /&gt;
		format = utilities.wrap_style (&#039;format&#039;, &#039;PDF&#039;);						-- set format to PDF&lt;br /&gt;
	else&lt;br /&gt;
		format = &#039;&#039;;															-- empty string for concatenation&lt;br /&gt;
	end&lt;br /&gt;
	return format;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[---------------------&amp;lt; G E T _ D I S P L A Y _ N A M E S &amp;gt;------------------&lt;br /&gt;
&lt;br /&gt;
Returns a number that defines the number of names displayed for author and editor&lt;br /&gt;
name lists and a Boolean flag to indicate when et al. should be appended to the name list.&lt;br /&gt;
&lt;br /&gt;
When the value assigned to |display-xxxxors= is a number greater than or equal to zero,&lt;br /&gt;
return the number and the previous state of the &#039;etal&#039; flag (false by default&lt;br /&gt;
but may have been set to true if the name list contains some variant of the text &#039;et al.&#039;).&lt;br /&gt;
&lt;br /&gt;
When the value assigned to |display-xxxxors= is the keyword &#039;etal&#039;, return a number&lt;br /&gt;
that is one greater than the number of authors in the list and set the &#039;etal&#039; flag true.&lt;br /&gt;
This will cause the list_people() to display all of the names in the name list followed by &#039;et al.&#039;&lt;br /&gt;
&lt;br /&gt;
In all other cases, returns nil and the previous state of the &#039;etal&#039; flag.&lt;br /&gt;
&lt;br /&gt;
inputs:&lt;br /&gt;
	max: A[&#039;DisplayAuthors&#039;] or A[&#039;DisplayEditors&#039;]; a number or some flavor of etal&lt;br /&gt;
	count: #a or #e&lt;br /&gt;
	list_name: &#039;authors&#039; or &#039;editors&#039;&lt;br /&gt;
	etal: author_etal or editor_etal&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function get_display_names (max, count, list_name, etal, param)&lt;br /&gt;
	if utilities.is_set (max) then&lt;br /&gt;
		if &#039;etal&#039; == max:lower():gsub(&amp;quot;[ &#039;%.]&amp;quot;, &#039;&#039;) then						-- the :gsub() portion makes &#039;etal&#039; from a variety of &#039;et al.&#039; spellings and stylings&lt;br /&gt;
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.&lt;br /&gt;
			etal = true;														-- overrides value set by extract_names()&lt;br /&gt;
		elseif max:match (&#039;^%d+$&#039;) then											-- if is a string of numbers&lt;br /&gt;
			max = tonumber (max);												-- make it a number&lt;br /&gt;
			if max &amp;gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors&lt;br /&gt;
				table.insert( z.message_tail, {utilities.set_message (&#039;err_disp_name&#039;, {param, max}, true)});	-- add error message&lt;br /&gt;
				max = nil;&lt;br /&gt;
			end&lt;br /&gt;
		else																	-- not a valid keyword or number&lt;br /&gt;
			table.insert( z.message_tail, {utilities.set_message (&#039;err_disp_name&#039;, {param, max}, true)});		-- add error message&lt;br /&gt;
			max = nil;															-- unset; as if |display-xxxxors= had not been set&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return max, etal;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[----------&amp;lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &amp;gt;---------------&lt;br /&gt;
&lt;br /&gt;
Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be&lt;br /&gt;
some form of p. or pp. abbreviation in the first characters of the parameter content.&lt;br /&gt;
&lt;br /&gt;
check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:&lt;br /&gt;
	good pattern: &#039;^P[^%.P%l]&#039; matches when page begins PX or P# but not Px&lt;br /&gt;
		      where x and X are letters and # is a digit&lt;br /&gt;
	bad pattern:  &#039;^[Pp][PpGg]&#039; matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function extra_text_in_page_check (val, name)&lt;br /&gt;
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then&lt;br /&gt;
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns&lt;br /&gt;
			if val:match (pattern) then											-- when a match, error so&lt;br /&gt;
				table.insert (z.message_tail, {utilities.set_message (&#039;err_extra_text_pages&#039;, {name}, true)}); -- add error message&lt;br /&gt;
				return;															-- and done&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end		&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &amp;gt;------------------------&lt;br /&gt;
&lt;br /&gt;
Adds error if |volume= or |issue= has what appears to be some form of redundant &#039;type&#039; indicator.&lt;br /&gt;
&lt;br /&gt;
For |volume=:&lt;br /&gt;
	&#039;V.&#039;, or &#039;Vol.&#039; (with or without the dot) abbreviations or &#039;Volume&#039; in the first characters of the parameter&lt;br /&gt;
	content (all case insensitive). &#039;V&#039; and &#039;v&#039; (without the dot) are presumed to be roman numerals so&lt;br /&gt;
	are allowed.&lt;br /&gt;
&lt;br /&gt;
For |issue=:&lt;br /&gt;
	&#039;No.&#039;, &#039;I.&#039;, &#039;Iss.&#039; (with or without the dot) abbreviations, or &#039;Issue&#039; in the first characters of the&lt;br /&gt;
	parameter content (all case insensitive).&lt;br /&gt;
	&lt;br /&gt;
Single character values (&#039;v&#039;, &#039;i&#039;, &#039;n&#039;) allowed when not followed by separator character (&#039;.&#039;, &#039;:&#039;, &#039;=&#039;, or&lt;br /&gt;
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.&lt;br /&gt;
	&lt;br /&gt;
&amp;lt;val&amp;gt; is |volume= or |issue= parameter value&lt;br /&gt;
&amp;lt;name&amp;gt; is |volume= or |issue= parameter name for error message&lt;br /&gt;
&amp;lt;selector&amp;gt; is &#039;v&#039; for |volume=, &#039;i&#039; for |issue=&lt;br /&gt;
&lt;br /&gt;
sets error message on failure; returns nothing&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function extra_text_in_vol_iss_check (val, name, selector)&lt;br /&gt;
	if not utilities.is_set (val) then&lt;br /&gt;
		return;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local patterns = &#039;v&#039; == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;&lt;br /&gt;
&lt;br /&gt;
	local handler = &#039;v&#039; == selector and &#039;err_extra_text_volume&#039; or &#039;err_extra_text_issue&#039;;&lt;br /&gt;
	val = val:lower();															-- force parameter value to lower case&lt;br /&gt;
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns&lt;br /&gt;
		if val:match (pattern) then												-- when a match, error so&lt;br /&gt;
			table.insert (z.message_tail, {utilities.set_message (handler, {name}, true)}); -- add error message&lt;br /&gt;
			return;																-- and done&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[=[-------------------------&amp;lt; G E T _ V _ N A M E _ T A B L E &amp;gt;----------------------------------------------&lt;br /&gt;
&lt;br /&gt;
split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled&lt;br /&gt;
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the&lt;br /&gt;
rendered citation and in the metadata.  Individual author names may be wikilinked&lt;br /&gt;
&lt;br /&gt;
	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))&lt;br /&gt;
&lt;br /&gt;
]=]&lt;br /&gt;
&lt;br /&gt;
local function get_v_name_table (vparam, output_table, output_link_table)&lt;br /&gt;
	local name_table = mw.text.split(vparam, &amp;quot;%s*,%s*&amp;quot;);						-- names are separated by commas&lt;br /&gt;
	local wl_type, label, link;													-- wl_type not used here; just a placeholder&lt;br /&gt;
	&lt;br /&gt;
	local i = 1;&lt;br /&gt;
	&lt;br /&gt;
	while name_table[i] do&lt;br /&gt;
		if name_table[i]:match (&#039;^%(%(.*[^%)][^%)]$&#039;) then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses&lt;br /&gt;
			local name = name_table[i];&lt;br /&gt;
			i = i + 1;															-- bump indexer to next segment&lt;br /&gt;
			while name_table[i] do&lt;br /&gt;
				name = name .. &#039;, &#039; .. name_table[i];							-- concatenate with previous segments&lt;br /&gt;
				if name_table[i]:match (&#039;^.*%)%)$&#039;) then						-- if this table member has the closing doubled parentheses&lt;br /&gt;
					break;														-- and done reassembling so&lt;br /&gt;
				end&lt;br /&gt;
				i = i + 1;														-- bump indexer&lt;br /&gt;
			end&lt;br /&gt;
			table.insert (output_table, name);									-- and add corporate name to the output table&lt;br /&gt;
			table.insert (output_link_table, &#039;&#039;);								-- no wikilink&lt;br /&gt;
		else&lt;br /&gt;
			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]]&lt;br /&gt;
			table.insert (output_table, label);									-- add this name&lt;br /&gt;
			if 1 == wl_type then&lt;br /&gt;
				table.insert (output_link_table, label);						-- simple wikilink [[D]]&lt;br /&gt;
			else&lt;br /&gt;
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		i = i + 1;&lt;br /&gt;
	end	&lt;br /&gt;
	return output_table;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; P A R S E _ V A U T H O R S _ V E D I T O R S &amp;gt;--------------------------------&lt;br /&gt;
&lt;br /&gt;
This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and&lt;br /&gt;
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.&lt;br /&gt;
&lt;br /&gt;
Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names&lt;br /&gt;
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance&lt;br /&gt;
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.&lt;br /&gt;
&lt;br /&gt;
Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.&lt;br /&gt;
&lt;br /&gt;
This function sets the Vancouver error when a required comma is missing and when there is a space between an author&#039;s initials.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function parse_vauthors_veditors (args, vparam, list_name)&lt;br /&gt;
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=&lt;br /&gt;
	local v_name_table = {};&lt;br /&gt;
	local v_link_table = {};													-- when name is wikilinked, targets go in this table&lt;br /&gt;
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter&lt;br /&gt;
	local last, first, link, mask, suffix;&lt;br /&gt;
	local corporate = false;&lt;br /&gt;
&lt;br /&gt;
	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)&lt;br /&gt;
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas&lt;br /&gt;
&lt;br /&gt;
	for i, v_name in ipairs(v_name_table) do&lt;br /&gt;
		first = &#039;&#039;;																-- set to empty string for concatenation and because it may have been set for previous author/editor&lt;br /&gt;
		local accept_name;&lt;br /&gt;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &amp;lt;v_name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		if accept_name then&lt;br /&gt;
			last = v_name;&lt;br /&gt;
			corporate = true;													-- flag used in list_people()&lt;br /&gt;
		elseif string.find(v_name, &amp;quot;%s&amp;quot;) then&lt;br /&gt;
			if v_name:find(&#039;[;%.]&#039;) then										-- look for commonly occurring punctuation characters; &lt;br /&gt;
				add_vanc_error (cfg.err_msg_supl.punctuation, i);&lt;br /&gt;
			end&lt;br /&gt;
			local lastfirstTable = {}&lt;br /&gt;
			lastfirstTable = mw.text.split(v_name, &amp;quot;%s+&amp;quot;)&lt;br /&gt;
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix&lt;br /&gt;
&lt;br /&gt;
			if not mw.ustring.match (first, &#039;^%u+$&#039;) then						-- mw.ustring here so that later we will catch non-Latin characters&lt;br /&gt;
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix&lt;br /&gt;
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table&lt;br /&gt;
			end&lt;br /&gt;
			last = table.concat(lastfirstTable, &#039; &#039;)							-- returns a string that is the concatenation of all other names that are not initials and generational suffix&lt;br /&gt;
			if not utilities.is_set (last) then&lt;br /&gt;
				first = &#039;&#039;;														-- unset&lt;br /&gt;
				last = v_name;													-- last empty because something wrong with first&lt;br /&gt;
				add_vanc_error (cfg.err_msg_supl.name, i);&lt;br /&gt;
			end&lt;br /&gt;
			if mw.ustring.match (last, &#039;%a+%s+%u+%s+%a+&#039;) then&lt;br /&gt;
				add_vanc_error (cfg.err_msg_supl[&#039;missing comma&#039;], i);			-- matches last II last; the case when a comma is missing&lt;br /&gt;
			end&lt;br /&gt;
			if mw.ustring.match (v_name, &#039; %u %u$&#039;) then						-- this test is in the wrong place TODO: move or replace with a more appropriate test&lt;br /&gt;
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			last = v_name;														-- last name or single corporate name?  Doesn&#039;t support multiword corporate names? do we need this?&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		if utilities.is_set (first) then&lt;br /&gt;
			if not mw.ustring.match (first, &amp;quot;^%u?%u$&amp;quot;) then						-- first shall contain one or two upper-case letters, nothing else&lt;br /&gt;
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials&lt;br /&gt;
			end&lt;br /&gt;
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit&lt;br /&gt;
			if utilities.is_set (suffix) then&lt;br /&gt;
				first = first .. &#039; &#039; .. suffix;									-- if there was a suffix concatenate with the initials&lt;br /&gt;
				suffix = &#039;&#039;;													-- unset so we don&#039;t add this suffix to all subsequent names&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			if not corporate then&lt;br /&gt;
				is_good_vanc_name (last, &#039;&#039;, nil, i);&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		link = utilities.select_one ( args, cfg.aliases[list_name .. &#039;-Link&#039;], &#039;err_redundant_parameters&#039;, i ) or v_link_table[i];&lt;br /&gt;
		mask = utilities.select_one ( args, cfg.aliases[list_name .. &#039;-Mask&#039;], &#039;err_redundant_parameters&#039;, i );&lt;br /&gt;
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list&lt;br /&gt;
	end&lt;br /&gt;
	return names, etal;															-- all done, return our list of names&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;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 &amp;gt;------------------------&lt;br /&gt;
&lt;br /&gt;
Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or&lt;br /&gt;
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.&lt;br /&gt;
&lt;br /&gt;
Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;&lt;br /&gt;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)&lt;br /&gt;
&lt;br /&gt;
When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second&lt;br /&gt;
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better&lt;br /&gt;
way to do this, I just haven&#039;t discovered what that way is.&lt;br /&gt;
&lt;br /&gt;
Emits an error message when more than one xxxxor name source is provided.&lt;br /&gt;
&lt;br /&gt;
In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)&lt;br /&gt;
	local lastfirst = false;&lt;br /&gt;
	if utilities.select_one ( args, cfg.aliases[list_name .. &#039;-Last&#039;], &#039;none&#039;, 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...&lt;br /&gt;
		utilities.select_one ( args, cfg.aliases[list_name .. &#039;-First&#039;], &#039;none&#039;, 1 ) or		-- ... also catches the case where |first= is used with |vauthors=&lt;br /&gt;
		utilities.select_one ( args, cfg.aliases[list_name .. &#039;-Last&#039;], &#039;none&#039;, 2 ) or&lt;br /&gt;
		utilities.select_one ( args, cfg.aliases[list_name .. &#039;-First&#039;], &#039;none&#039;, 2 ) then&lt;br /&gt;
			lastfirst = true;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions&lt;br /&gt;
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or&lt;br /&gt;
		(true == lastfirst and utilities.is_set (xxxxors)) then&lt;br /&gt;
			local err_name;&lt;br /&gt;
			if &#039;AuthorList&#039; == list_name then									-- figure out which name should be used in error message&lt;br /&gt;
				err_name = &#039;author&#039;;&lt;br /&gt;
			else&lt;br /&gt;
				err_name = &#039;editor&#039;;&lt;br /&gt;
			end&lt;br /&gt;
			table.insert( z.message_tail, { utilities.set_message ( &#039;err_redundant_parameters&#039;,&lt;br /&gt;
				{err_name .. &#039;-name-list parameters&#039;}, true ) } );				-- add error message&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use&lt;br /&gt;
	if utilities.is_set (vxxxxors) then return 2 end;&lt;br /&gt;
	if utilities.is_set (xxxxors) then return 3 end;&lt;br /&gt;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &amp;gt;------------------------------&lt;br /&gt;
&lt;br /&gt;
This function is used to validate a parameter&#039;s assigned value for those parameters that have only a limited number&lt;br /&gt;
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing&lt;br /&gt;
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one&lt;br /&gt;
of the list of allowed values returns the translated value; else, emits an error message and returns the value&lt;br /&gt;
specified by ret_val.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_valid_parameter_value (value, name, possible, ret_val)&lt;br /&gt;
	if not utilities.is_set (value) then&lt;br /&gt;
		return ret_val;															-- an empty parameter is ok&lt;br /&gt;
	elseif utilities.in_array (value, possible) then&lt;br /&gt;
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword&lt;br /&gt;
	else&lt;br /&gt;
		table.insert( z.message_tail, { utilities.set_message ( &#039;err_invalid_param_val&#039;, {name, value}, true ) } );	-- not an allowed value so add error message&lt;br /&gt;
		return ret_val;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; T E R M I N A T E _ N A M E _ L I S T &amp;gt;----------------------------------------&lt;br /&gt;
&lt;br /&gt;
This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space&lt;br /&gt;
when the last character is not a sepc character or when the last three characters are not sepc followed by two&lt;br /&gt;
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a&lt;br /&gt;
single space character.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function terminate_name_list (name_list, sepc)&lt;br /&gt;
	if (string.sub (name_list, -3, -1) == sepc .. &#039;. &#039;) then					-- if already properly terminated&lt;br /&gt;
		return name_list;														-- just return the name list&lt;br /&gt;
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. &#039;]]&#039;) then	-- if last name in list ends with sepc char&lt;br /&gt;
		return name_list .. &amp;quot; &amp;quot;;												-- don&#039;t add another&lt;br /&gt;
	else&lt;br /&gt;
		return name_list .. sepc .. &#039; &#039;;										-- otherwise terminate the name list&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[-------------------------&amp;lt; F O R M A T _ V O L U M E _ I S S U E &amp;gt;----------------------------------------&lt;br /&gt;
&lt;br /&gt;
returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume&lt;br /&gt;
or formatted issue, or an empty string if neither are set.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
	&lt;br /&gt;
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)&lt;br /&gt;
	if not utilities.is_set (volume) and not utilities.is_set (issue) then&lt;br /&gt;
		return &#039;&#039;;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if &#039;magazine&#039; == cite_class or (utilities.in_array (cite_class, {&#039;citation&#039;, &#039;map&#039;}) and &#039;magazine&#039; == origin) then&lt;br /&gt;
		if utilities.is_set (volume) and utilities.is_set (issue) then&lt;br /&gt;
			return wrap_msg (&#039;vol-no&#039;, {sepc, hyphen_to_dash (volume), issue}, lower);&lt;br /&gt;
		elseif utilities.is_set (volume) then&lt;br /&gt;
			return wrap_msg (&#039;vol&#039;, {sepc, hyphen_to_dash (volume)}, lower);&lt;br /&gt;
		else&lt;br /&gt;
			return wrap_msg (&#039;issue&#039;, {sepc, issue}, lower);&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if &#039;podcast&#039; == cite_class and utilities.is_set (issue) then&lt;br /&gt;
		return wrap_msg (&#039;issue&#039;, {sepc, issue}, lower);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local vol = &#039;&#039;;																-- here for all cites except magazine&lt;br /&gt;
		&lt;br /&gt;
	if utilities.is_set (volume) then&lt;br /&gt;
		if volume:match (&#039;^[MDCLXVI]+$&#039;) or volume:match (&#039;^%d+$&#039;) then			-- volume value is all digits or all uppercase Roman numerals&lt;br /&gt;
			vol = utilities.substitute (cfg.presentation[&#039;vol-bold&#039;], {sepc, volume});	-- render in bold face&lt;br /&gt;
		elseif (4 &amp;lt; mw.ustring.len(volume)) then								-- not all digits or Roman numerals and longer than 4 characters&lt;br /&gt;
			vol = utilities.substitute (cfg.messages[&#039;j-vol&#039;], {sepc, hyphen_to_dash (volume)});	-- not bold&lt;br /&gt;
			utilities.add_prop_cat (&#039;long_vol&#039;);&lt;br /&gt;
		else																	-- four or less characters&lt;br /&gt;
			vol = utilities.substitute (cfg.presentation[&#039;vol-bold&#039;], {sepc, hyphen_to_dash (volume)});	-- bold&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if utilities.is_set (issue) then&lt;br /&gt;
		return vol .. utilities.substitute (cfg.messages[&#039;j-issue&#039;], issue);&lt;br /&gt;
	end&lt;br /&gt;
	return vol;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[-------------------------&amp;lt; F O R M A T _ P A G E S _ S H E E T S &amp;gt;-----------------------------------------&lt;br /&gt;
&lt;br /&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.&lt;br /&gt;
The return order is:&lt;br /&gt;
	page, pages, sheet, sheets&lt;br /&gt;
&lt;br /&gt;
Singular has priority over plural when both are provided.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)&lt;br /&gt;
	if &#039;map&#039; == cite_class then													-- only cite map supports sheet(s) as in-source locators&lt;br /&gt;
		if utilities.is_set (sheet) then&lt;br /&gt;
			if &#039;journal&#039; == origin then&lt;br /&gt;
				return &#039;&#039;, &#039;&#039;, wrap_msg (&#039;j-sheet&#039;, sheet, lower), &#039;&#039;;&lt;br /&gt;
			else&lt;br /&gt;
				return &#039;&#039;, &#039;&#039;, wrap_msg (&#039;sheet&#039;, {sepc, sheet}, lower), &#039;&#039;;&lt;br /&gt;
			end&lt;br /&gt;
		elseif utilities.is_set (sheets) then&lt;br /&gt;
			if &#039;journal&#039; == origin then&lt;br /&gt;
				return &#039;&#039;, &#039;&#039;, &#039;&#039;, wrap_msg (&#039;j-sheets&#039;, sheets, lower);&lt;br /&gt;
			else&lt;br /&gt;
				return &#039;&#039;, &#039;&#039;, &#039;&#039;, wrap_msg (&#039;sheets&#039;, {sepc, sheets}, lower);&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local is_journal = &#039;journal&#039; == cite_class or (utilities.in_array (cite_class, {&#039;citation&#039;, &#039;map&#039;, &#039;interview&#039;}) and &#039;journal&#039; == origin);&lt;br /&gt;
	&lt;br /&gt;
	if utilities.is_set (page) then&lt;br /&gt;
		if is_journal then&lt;br /&gt;
			return utilities.substitute (cfg.messages[&#039;j-page(s)&#039;], page), &#039;&#039;, &#039;&#039;, &#039;&#039;;&lt;br /&gt;
		elseif not nopp then&lt;br /&gt;
			return utilities.substitute (cfg.messages[&#039;p-prefix&#039;], {sepc, page}), &#039;&#039;, &#039;&#039;, &#039;&#039;;&lt;br /&gt;
		else&lt;br /&gt;
			return utilities.substitute (cfg.messages[&#039;nopp&#039;], {sepc, page}), &#039;&#039;, &#039;&#039;, &#039;&#039;;&lt;br /&gt;
		end&lt;br /&gt;
	elseif utilities.is_set (pages) then&lt;br /&gt;
		if is_journal then&lt;br /&gt;
			return utilities.substitute (cfg.messages[&#039;j-page(s)&#039;], pages), &#039;&#039;, &#039;&#039;, &#039;&#039;;&lt;br /&gt;
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number&lt;br /&gt;
			return &#039;&#039;, utilities.substitute (cfg.messages[&#039;p-prefix&#039;], {sepc, pages}), &#039;&#039;, &#039;&#039;;&lt;br /&gt;
		elseif not nopp then&lt;br /&gt;
			return &#039;&#039;, utilities.substitute (cfg.messages[&#039;pp-prefix&#039;], {sepc, pages}), &#039;&#039;, &#039;&#039;;&lt;br /&gt;
		else&lt;br /&gt;
			return &#039;&#039;, utilities.substitute (cfg.messages[&#039;nopp&#039;], {sepc, pages}), &#039;&#039;, &#039;&#039;;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return &#039;&#039;, &#039;&#039;, &#039;&#039;, &#039;&#039;;														-- return empty strings&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I N S O U R C E _ L O C _ G E T &amp;gt;----------------------------------------------&lt;br /&gt;
&lt;br /&gt;
returns one of the in-source locators: page, pages, or at. &lt;br /&gt;
&lt;br /&gt;
If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text&lt;br /&gt;
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and&lt;br /&gt;
add an icon span around that; get_coins_pages() doesn&#039;t know about the span.  TODO: should it?  &lt;br /&gt;
&lt;br /&gt;
TODO: add support for sheet and sheets?; streamline;&lt;br /&gt;
&lt;br /&gt;
TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned&lt;br /&gt;
to a new name)?&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function insource_loc_get (page, page_orig, pages, pages_orig, at)&lt;br /&gt;
	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?)&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (page) then&lt;br /&gt;
		if utilities.is_set (pages) or utilities.is_set (at) then&lt;br /&gt;
			pages = &#039;&#039;;															-- unset the others&lt;br /&gt;
			at = &#039;&#039;;&lt;br /&gt;
		end&lt;br /&gt;
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.&lt;br /&gt;
&lt;br /&gt;
		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label&lt;br /&gt;
		if ws_url then&lt;br /&gt;
			page = external_link (ws_url, ws_label .. &#039;&amp;amp;nbsp;&#039;, &#039;ws link in page&#039;);	-- space char after label to move icon away from in-source text; TODO: a better way to do this?&lt;br /&gt;
			page = utilities.substitute (cfg.presentation[&#039;interwiki-icon&#039;], {cfg.presentation[&#039;class-wikisource&#039;], L, page});&lt;br /&gt;
			coins_pages = ws_label;&lt;br /&gt;
		end&lt;br /&gt;
	elseif utilities.is_set (pages) then&lt;br /&gt;
		if utilities.is_set (at) then&lt;br /&gt;
			at = &#039;&#039;;															-- unset&lt;br /&gt;
		end&lt;br /&gt;
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.&lt;br /&gt;
&lt;br /&gt;
		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label&lt;br /&gt;
		if ws_url then&lt;br /&gt;
			pages = external_link (ws_url, ws_label .. &#039;&amp;amp;nbsp;&#039;, &#039;ws link in pages&#039;);	-- space char after label to move icon away from in-source text; TODO: a better way to do this?&lt;br /&gt;
			pages = utilities.substitute (cfg.presentation[&#039;interwiki-icon&#039;], {cfg.presentation[&#039;class-wikisource&#039;], L, pages});&lt;br /&gt;
			coins_pages = ws_label;&lt;br /&gt;
		end&lt;br /&gt;
	elseif utilities.is_set (at) then&lt;br /&gt;
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label&lt;br /&gt;
		if ws_url then&lt;br /&gt;
			at = external_link (ws_url, ws_label .. &#039;&amp;amp;nbsp;&#039;, &#039;ws link in at&#039;);	-- space char after label to move icon away from in-source text; TODO: a better way to do this?&lt;br /&gt;
			at = utilities.substitute (cfg.presentation[&#039;interwiki-icon&#039;], {cfg.presentation[&#039;class-wikisource&#039;], L, at});&lt;br /&gt;
			coins_pages = ws_label;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return page, pages, at, coins_pages;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ U N I Q U E _ A R C H I V E _ U R L &amp;gt;------------------------------------&lt;br /&gt;
&lt;br /&gt;
add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_unique_archive_url (archive, url, c_url, source, date)&lt;br /&gt;
	if utilities.is_set (archive) then&lt;br /&gt;
		if archive == url or archive == c_url then&lt;br /&gt;
			table.insert (z.message_tail, {utilities.set_message (&#039;err_bad_url&#039;, {utilities.wrap_style (&#039;parameter&#039;, source)}, true)});	-- add error message&lt;br /&gt;
			return &#039;&#039;, &#039;&#039;;														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return archive, date;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[=[-------------------------&amp;lt; A R C H I V E _ U R L _ C H E C K &amp;gt;--------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the &lt;br /&gt;
save snapshot URL or to calendar pages.  When the archive URL is &#039;https://web.archive.org/save/&#039; (or http://...)&lt;br /&gt;
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow&lt;br /&gt;
unwitting readers to do.&lt;br /&gt;
&lt;br /&gt;
When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own&lt;br /&gt;
algorithm or provides a calendar &#039;search&#039; result.  [[WP:ELNO]] discourages links to search results.&lt;br /&gt;
&lt;br /&gt;
This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and&lt;br /&gt;
|archive-date= and an error message when:&lt;br /&gt;
	|archive-url= holds an archive.org save command URL&lt;br /&gt;
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the&lt;br /&gt;
		correct place&lt;br /&gt;
otherwise returns |archive-url= and |archive-date=&lt;br /&gt;
&lt;br /&gt;
There are two mostly compatible archive.org URLs:&lt;br /&gt;
	//web.archive.org/&amp;lt;timestamp&amp;gt;...		-- the old form&lt;br /&gt;
	//web.archive.org/web/&amp;lt;timestamp&amp;gt;...	-- the new form&lt;br /&gt;
&lt;br /&gt;
The old form does not support or map to the new form when it contains a display flag.  There are four identified flags&lt;br /&gt;
(&#039;id_&#039;, &#039;js_&#039;, &#039;cs_&#039;, &#039;im_&#039;) but since archive.org ignores others following the same form (two letters and an underscore)&lt;br /&gt;
we don&#039;t check for these specific flags but we do check the form.&lt;br /&gt;
&lt;br /&gt;
This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified&lt;br /&gt;
archive URL:&lt;br /&gt;
	for save command errors, return undated wildcard (/*/)&lt;br /&gt;
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified&lt;br /&gt;
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)&lt;br /&gt;
&lt;br /&gt;
]=]&lt;br /&gt;
&lt;br /&gt;
local function archive_url_check (url, date)&lt;br /&gt;
	local err_msg = &#039;&#039;;															-- start with the error message empty&lt;br /&gt;
	local path, timestamp, flag;												-- portions of the archive.org URL&lt;br /&gt;
	&lt;br /&gt;
	if (not url:match(&#039;//web%.archive%.org/&#039;)) and (not url:match(&#039;//liveweb%.archive%.org/&#039;)) then		-- also deprecated liveweb Wayback machine URL&lt;br /&gt;
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if url:match(&#039;//web%.archive%.org/save/&#039;) then								-- if a save command URL, we don&#039;t want to allow saving of the target page &lt;br /&gt;
		err_msg = cfg.err_msg_supl.save;&lt;br /&gt;
		url = url:gsub (&#039;(//web%.archive%.org)/save/&#039;, &#039;%1/*/&#039;, 1);				-- for preview mode: modify ArchiveURL&lt;br /&gt;
	elseif url:match(&#039;//liveweb%.archive%.org/&#039;) then&lt;br /&gt;
		err_msg = cfg.err_msg_supl.liveweb;&lt;br /&gt;
	else&lt;br /&gt;
		path, timestamp, flag = url:match(&#039;//web%.archive%.org/([^%d]*)(%d+)([^/]*)/&#039;);	-- split out some of the URL parts for evaluation&lt;br /&gt;
		&lt;br /&gt;
		if not utilities.is_set (timestamp) or 14 ~= timestamp:len() then		-- path and flag optional, must have 14-digit timestamp here&lt;br /&gt;
			err_msg = cfg.err_msg_supl.timestamp;&lt;br /&gt;
			if &#039;*&#039; ~= flag then&lt;br /&gt;
				url=url:gsub (&#039;(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*&#039;, &#039;%1*&#039;, 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)&lt;br /&gt;
			end&lt;br /&gt;
		elseif utilities.is_set (path) and &#039;web/&#039; ~= path then					-- older archive URLs do not have the extra &#039;web/&#039; path element&lt;br /&gt;
			err_msg = cfg.err_msg_supl.path;&lt;br /&gt;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the &#039;web/&#039; path element)&lt;br /&gt;
			err_msg = cfg.err_msg_supl.flag;&lt;br /&gt;
		elseif utilities.is_set (flag) and not flag:match (&#039;%a%a_&#039;) then		-- flag if present must be two alpha characters and underscore (requires &#039;web/&#039; path element)&lt;br /&gt;
			err_msg = cfg.err_msg_supl.flag;&lt;br /&gt;
		else&lt;br /&gt;
			return url, date;													-- return ArchiveURL and ArchiveDate&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
																				-- if here, something not right so&lt;br /&gt;
	table.insert( z.message_tail, { utilities.set_message ( &#039;err_archive_url&#039;, {err_msg}, true ) } );	-- add error message and&lt;br /&gt;
	if utilities.is_set (Frame:preprocess(&#039;{{REVISIONID}}&#039;)) then&lt;br /&gt;
		return &#039;&#039;, &#039;&#039;;															-- return empty strings for ArchiveURL and ArchiveDate&lt;br /&gt;
	else&lt;br /&gt;
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; P L A C E _ C H E C K &amp;gt;--------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
check |place=, |publication-place=, |location= to see if these params include digits.  This function added because&lt;br /&gt;
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)&lt;br /&gt;
&lt;br /&gt;
returns the original parameter value without modification; added maint cat when parameter value contains digits&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function place_check (param_val)&lt;br /&gt;
	if not utilities.is_set (param_val) then									-- parameter empty or omitted&lt;br /&gt;
		return param_val;														-- return that empty state&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if mw.ustring.find (param_val, &#039;%d&#039;) then									-- not empty, are there digits in the parameter value&lt;br /&gt;
		utilities.set_message (&#039;maint_location&#039;);								-- yep, add maint cat&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return param_val;															-- and done&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ G E N E R I C _ T I T L E &amp;gt;----------------------------------------------&lt;br /&gt;
&lt;br /&gt;
compares |title= value against list of known generic title patterns.  Returns true when pattern matches; nil else&lt;br /&gt;
&lt;br /&gt;
the k/v pairs in &#039;generic_titles&#039; each contain two tables, one for English and one for another &#039;local&#039; language&lt;br /&gt;
Each of those tables contain another table that holds the string or pattern (whole title or title fragment) in&lt;br /&gt;
index [1].  index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)&lt;br /&gt;
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so&lt;br /&gt;
that we don&#039;t run out of processing time on very large articles.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_generic_title (title)&lt;br /&gt;
	title = mw.ustring.lower(title);											-- switch title to lower case&lt;br /&gt;
	for _, generic_title in ipairs (cfg.special_case_translation[&#039;generic_titles&#039;]) do 	-- spin through the list of known generic title fragments&lt;br /&gt;
		if title:find (generic_title[&#039;en&#039;][1], 1, generic_title[&#039;en&#039;][2]) then&lt;br /&gt;
			return true;														-- found English generic title so done&lt;br /&gt;
		elseif generic_title[&#039;local&#039;] then										-- to keep work load down, generic_title[&#039;local&#039;] should be nil except when there is a local version of the generic title&lt;br /&gt;
			if mw.ustring.find (title, generic_title[&#039;local&#039;][1], 1, generic_title[&#039;local&#039;][2]) then	-- mw.ustring() because might not be Latin script&lt;br /&gt;
				return true;													-- found local generic title so done&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ A R C H I V E D _ C O P Y &amp;gt;----------------------------------------------&lt;br /&gt;
&lt;br /&gt;
compares |title= to &#039;Archived copy&#039; (placeholder added by bots that can&#039;t find proper title); if matches, return true; nil else&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_archived_copy (title)&lt;br /&gt;
	title = mw.ustring.lower(title);											-- switch title to lower case&lt;br /&gt;
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is &#039;Archived copy&#039;&lt;br /&gt;
		return true;&lt;br /&gt;
	elseif cfg.special_case_translation.archived_copy[&#039;local&#039;] then&lt;br /&gt;
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy[&#039;local&#039;]) then	-- mw.ustring() because might not be Latin script&lt;br /&gt;
			return true;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; C I T A T I O N 0 &amp;gt;------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
This is the main function doing the majority of the citation formatting.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function citation0( config, args )&lt;br /&gt;
	--[[ &lt;br /&gt;
	Load Input Parameters&lt;br /&gt;
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.&lt;br /&gt;
	]]&lt;br /&gt;
	local A = argument_wrapper ( args );&lt;br /&gt;
	local i &lt;br /&gt;
&lt;br /&gt;
	-- Pick out the relevant fields from the arguments.  Different citation templates&lt;br /&gt;
	-- define different field names for the same underlying things.	&lt;br /&gt;
&lt;br /&gt;
	local author_etal;&lt;br /&gt;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=&lt;br /&gt;
	local Authors;&lt;br /&gt;
	local NameListStyle = is_valid_parameter_value (A[&#039;NameListStyle&#039;], A:ORIGIN(&#039;NameListStyle&#039;), cfg.keywords_lists[&#039;name-list-style&#039;], &#039;&#039;);&lt;br /&gt;
	local Collaboration = A[&#039;Collaboration&#039;];&lt;br /&gt;
&lt;br /&gt;
	do																			-- to limit scope of selected&lt;br /&gt;
		local selected = select_author_editor_source (A[&#039;Vauthors&#039;], A[&#039;Authors&#039;], args, &#039;AuthorList&#039;);&lt;br /&gt;
		if 1 == selected then&lt;br /&gt;
			a, author_etal = extract_names (args, &#039;AuthorList&#039;);				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=&lt;br /&gt;
		elseif 2 == selected then&lt;br /&gt;
			NameListStyle = &#039;vanc&#039;;												-- override whatever |name-list-style= might be&lt;br /&gt;
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, &#039;AuthorList&#039;);	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=&lt;br /&gt;
		elseif 3 == selected then&lt;br /&gt;
			Authors = A[&#039;Authors&#039;];												-- use content of |authors=&lt;br /&gt;
			if &#039;authors&#039; == A:ORIGIN(&#039;Authors&#039;) then							-- but add a maint cat if the parameter is |authors=&lt;br /&gt;
				utilities.set_message (&#039;maint_authors&#039;);						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if utilities.is_set (Collaboration) then&lt;br /&gt;
			author_etal = true;													-- so that |display-authors=etal not required&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local editor_etal;&lt;br /&gt;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=&lt;br /&gt;
&lt;br /&gt;
	do																			-- to limit scope of selected&lt;br /&gt;
		local selected = select_author_editor_source (A[&#039;Veditors&#039;], nil, args, &#039;EditorList&#039;);	-- support for |editors= withdrawn&lt;br /&gt;
		if 1 == selected then&lt;br /&gt;
			e, editor_etal = extract_names (args, &#039;EditorList&#039;);				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=&lt;br /&gt;
		elseif 2 == selected then&lt;br /&gt;
			NameListStyle = &#039;vanc&#039;;												-- override whatever |name-list-style= might be&lt;br /&gt;
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, &#039;EditorList&#039;);	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
							&lt;br /&gt;
	local Chapter = A[&#039;Chapter&#039;];												-- done here so that we have access to |contribution= from |chapter= aliases&lt;br /&gt;
	local Chapter_origin = A:ORIGIN (&#039;Chapter&#039;);&lt;br /&gt;
	local Contribution;															-- because contribution is required for contributor(s)&lt;br /&gt;
		if &#039;contribution&#039; == Chapter_origin then&lt;br /&gt;
			Contribution = Chapter;												-- get the name of the contribution&lt;br /&gt;
		end&lt;br /&gt;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs&lt;br /&gt;
	&lt;br /&gt;
	if utilities.in_array (config.CitationClass, {&amp;quot;book&amp;quot;, &amp;quot;citation&amp;quot;}) and not utilities.is_set (A[&#039;Periodical&#039;]) then	-- |contributor= and |contribution= only supported in book cites&lt;br /&gt;
		c = extract_names (args, &#039;ContributorList&#039;);							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=&lt;br /&gt;
		&lt;br /&gt;
		if 0 &amp;lt; #c then&lt;br /&gt;
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=&lt;br /&gt;
				table.insert( z.message_tail, { utilities.set_message ( &#039;err_contributor_missing_required_param&#039;, &#039;contribution&#039;)});	-- add missing contribution error message&lt;br /&gt;
				c = {};															-- blank the contributors&#039; table; it is used as a flag later&lt;br /&gt;
			end&lt;br /&gt;
			if 0 == #a then														-- |contributor= requires |author=&lt;br /&gt;
				table.insert( z.message_tail, { utilities.set_message ( &#039;err_contributor_missing_required_param&#039;, &#039;author&#039;)});	-- add missing author error message&lt;br /&gt;
				c = {};															-- blank the contributors&#039; table; it is used as a flag later&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else																		-- if not a book cite&lt;br /&gt;
		if utilities.select_one (args, cfg.aliases[&#039;ContributorList-Last&#039;], &#039;err_redundant_parameters&#039;, 1 ) then	-- are there contributor name list parameters?&lt;br /&gt;
			table.insert( z.message_tail, { utilities.set_message ( &#039;err_contributor_ignored&#039;)});	-- add contributor ignored error message&lt;br /&gt;
		end&lt;br /&gt;
		Contribution = nil;														-- unset&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local Title = A[&#039;Title&#039;];&lt;br /&gt;
	local TitleLink = A[&#039;TitleLink&#039;];&lt;br /&gt;
&lt;br /&gt;
	local auto_select = &#039;&#039;; -- default is auto&lt;br /&gt;
	local accept_link;&lt;br /&gt;
	TitleLink, accept_link = utilities.has_accept_as_written(TitleLink, true);	-- test for accept-this-as-written markup&lt;br /&gt;
	if (not accept_link) and utilities.in_array (TitleLink, {&#039;none&#039;, &#039;pmc&#039;, &#039;doi&#039;}) then -- check for special keywords&lt;br /&gt;
		auto_select = TitleLink;												-- remember selection for later&lt;br /&gt;
		TitleLink = &#039;&#039;;															-- treat as if |title-link= would have been empty&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	TitleLink = link_title_ok (TitleLink, A:ORIGIN (&#039;TitleLink&#039;), Title, &#039;title&#039;);	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set&lt;br /&gt;
&lt;br /&gt;
	local Section = &#039;&#039;;															-- {{cite map}} only; preset to empty string for concatenation if not used&lt;br /&gt;
	if &#039;map&#039; == config.CitationClass and &#039;section&#039; == Chapter_origin then&lt;br /&gt;
		Section = A[&#039;Chapter&#039;];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}&lt;br /&gt;
		Chapter = &#039;&#039;;															-- unset for now; will be reset later from |map= if present&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local Periodical = A[&#039;Periodical&#039;];&lt;br /&gt;
	local Periodical_origin = &#039;&#039;;&lt;br /&gt;
	if utilities.is_set (Periodical) then&lt;br /&gt;
		Periodical_origin = A:ORIGIN(&#039;Periodical&#039;);								-- get the name of the periodical parameter&lt;br /&gt;
		local i;&lt;br /&gt;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn&#039;t contaminated &lt;br /&gt;
		if i then																-- non-zero when markup was stripped so emit an error message&lt;br /&gt;
			table.insert( z.message_tail, {utilities.set_message (&#039;err_apostrophe_markup&#039;, {Periodical_origin}, true)});&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if &#039;mailinglist&#039; == config.CitationClass then								-- special case for {{cite mailing list}}&lt;br /&gt;
		if utilities.is_set (Periodical) and utilities.is_set (A [&#039;MailingList&#039;]) then	-- both set emit an error&lt;br /&gt;
			table.insert( z.message_tail, {utilities.set_message (&#039;err_redundant_parameters&#039;, {utilities.wrap_style (&#039;parameter&#039;, Periodical_origin) .. &#039; and &#039; .. utilities.wrap_style (&#039;parameter&#039;, &#039;mailinglist&#039;)}, true )});&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		Periodical = A [&#039;MailingList&#039;];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}&lt;br /&gt;
		Periodical_origin = A:ORIGIN(&#039;MailingList&#039;);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local ScriptPeriodical = A[&#039;ScriptPeriodical&#039;];&lt;br /&gt;
&lt;br /&gt;
	-- web and news not tested for now because of &lt;br /&gt;
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&amp;quot;Cite_Web&amp;quot;_errors?&lt;br /&gt;
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- &#039;periodical&#039; templates require periodical parameter&lt;br /&gt;
	--	local p = {[&#039;journal&#039;] = &#039;journal&#039;, [&#039;magazine&#039;] = &#039;magazine&#039;, [&#039;news&#039;] = &#039;newspaper&#039;, [&#039;web&#039;] = &#039;website&#039;};	-- for error message&lt;br /&gt;
		local p = {[&#039;journal&#039;] = &#039;journal&#039;, [&#039;magazine&#039;] = &#039;magazine&#039;};			-- for error message&lt;br /&gt;
		if p[config.CitationClass]  then&lt;br /&gt;
			table.insert( z.message_tail, {utilities.set_message (&#039;err_missing_periodical&#039;, {config.CitationClass, p[config.CitationClass]}, true)});&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local Volume;&lt;br /&gt;
	local ScriptPeriodical_origin = A:ORIGIN(&#039;ScriptPeriodical&#039;);&lt;br /&gt;
	if &#039;citation&#039; == config.CitationClass then&lt;br /&gt;
		if utilities.is_set (Periodical) then&lt;br /&gt;
			if not utilities.in_array (Periodical_origin, {&#039;website&#039;, &#039;mailinglist&#039;}) then	-- {{citation}} does not render volume for these &#039;periodicals&#039;&lt;br /&gt;
				Volume = A[&#039;Volume&#039;];											-- but does for all other &#039;periodicals&#039;&lt;br /&gt;
			end&lt;br /&gt;
		elseif utilities.is_set (ScriptPeriodical) then&lt;br /&gt;
			if &#039;script-website&#039; ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=&lt;br /&gt;
				Volume = A[&#039;Volume&#039;];											-- but does for all other &#039;periodicals&#039;&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			Volume = A[&#039;Volume&#039;];												-- and does for non-&#039;periodical&#039; cites&lt;br /&gt;
		end&lt;br /&gt;
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings&lt;br /&gt;
		Volume = A[&#039;Volume&#039;];&lt;br /&gt;
	end	&lt;br /&gt;
	extra_text_in_vol_iss_check (Volume, A:ORIGIN (&#039;Volume&#039;), &#039;v&#039;);	&lt;br /&gt;
&lt;br /&gt;
	local Issue;&lt;br /&gt;
	if &#039;citation&#039; == config.CitationClass then&lt;br /&gt;
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {&#039;journal&#039;, &#039;magazine&#039;, &#039;newspaper&#039;, &#039;periodical&#039;, &#039;work&#039;}) or	-- {{citation}} renders issue for these &#039;periodicals&#039;&lt;br /&gt;
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {&#039;script-journal&#039;, &#039;script-magazine&#039;, &#039;script-newspaper&#039;, &#039;script-periodical&#039;, &#039;script-work&#039;}) then -- and these &#039;script-periodicals&#039;&lt;br /&gt;
				Issue = hyphen_to_dash (A[&#039;Issue&#039;]);&lt;br /&gt;
		end&lt;br /&gt;
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp;amp; map books do not support issue; {{citation}} listed here because included in settings table&lt;br /&gt;
		if not (utilities.in_array (config.CitationClass, {&#039;conference&#039;, &#039;map&#039;, &#039;citation&#039;}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then&lt;br /&gt;
			Issue = hyphen_to_dash (A[&#039;Issue&#039;]);&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	extra_text_in_vol_iss_check (Issue, A:ORIGIN (&#039;Issue&#039;), &#039;i&#039;);	&lt;br /&gt;
&lt;br /&gt;
	local Page;&lt;br /&gt;
	local Pages;&lt;br /&gt;
	local At;&lt;br /&gt;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then&lt;br /&gt;
		Page = A[&#039;Page&#039;];&lt;br /&gt;
		Pages = hyphen_to_dash (A[&#039;Pages&#039;]);	&lt;br /&gt;
		At = A[&#039;At&#039;];&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local Edition = A[&#039;Edition&#039;];&lt;br /&gt;
	local PublicationPlace = place_check (A[&#039;PublicationPlace&#039;], A:ORIGIN(&#039;PublicationPlace&#039;));&lt;br /&gt;
	local Place = place_check (A[&#039;Place&#039;], A:ORIGIN(&#039;Place&#039;));&lt;br /&gt;
	&lt;br /&gt;
	local PublisherName = A[&#039;PublisherName&#039;];&lt;br /&gt;
	local PublisherName_origin = A:ORIGIN(&#039;PublisherName&#039;);&lt;br /&gt;
	if utilities.is_set (PublisherName) then&lt;br /&gt;
		local i = 0;&lt;br /&gt;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn&#039;t contaminated; publisher is never italicized&lt;br /&gt;
		if i then																-- non-zero when markup was stripped so emit an error message&lt;br /&gt;
			table.insert( z.message_tail, {utilities.set_message (&#039;err_apostrophe_markup&#039;, {PublisherName_origin}, true)});&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local Newsgroup = A[&#039;Newsgroup&#039;];											-- TODO: strip apostrophe markup?&lt;br /&gt;
	local Newsgroup_origin = A:ORIGIN(&#039;Newsgroup&#039;);	&lt;br /&gt;
&lt;br /&gt;
	if &#039;newsgroup&#039; == config.CitationClass then&lt;br /&gt;
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup&lt;br /&gt;
			local error_text, error_state = utilities.set_message (&#039;err_parameter_ignored&#039;, {PublisherName_origin}, true);&lt;br /&gt;
			if utilities.is_set (error_text) then&lt;br /&gt;
				table.insert( z.message_tail, {error_text, error_state} );&lt;br /&gt;
			end				&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local URL = A[&#039;URL&#039;]&lt;br /&gt;
	local UrlAccess = is_valid_parameter_value (A[&#039;UrlAccess&#039;], A:ORIGIN(&#039;UrlAccess&#039;), cfg.keywords_lists[&#039;url-access&#039;], nil);&lt;br /&gt;
	&lt;br /&gt;
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then&lt;br /&gt;
		UrlAccess = nil;&lt;br /&gt;
		table.insert( z.message_tail, { utilities.set_message ( &#039;err_param_access_requires_param&#039;, {&#039;url&#039;}, true ) } );&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local ChapterURL = A[&#039;ChapterURL&#039;];&lt;br /&gt;
	local ChapterUrlAccess = is_valid_parameter_value (A[&#039;ChapterUrlAccess&#039;], A:ORIGIN(&#039;ChapterUrlAccess&#039;), cfg.keywords_lists[&#039;url-access&#039;], nil);&lt;br /&gt;
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then&lt;br /&gt;
		ChapterUrlAccess = nil;&lt;br /&gt;
		table.insert( z.message_tail, { utilities.set_message ( &#039;err_param_access_requires_param&#039;, {A:ORIGIN(&#039;ChapterUrlAccess&#039;):gsub (&#039;%-access&#039;, &#039;&#039;)}, true ) } );&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local MapUrlAccess = is_valid_parameter_value (A[&#039;MapUrlAccess&#039;], A:ORIGIN(&#039;MapUrlAccess&#039;), cfg.keywords_lists[&#039;url-access&#039;], nil);&lt;br /&gt;
	if not utilities.is_set (A[&#039;MapURL&#039;]) and utilities.is_set (MapUrlAccess) then&lt;br /&gt;
		MapUrlAccess = nil;&lt;br /&gt;
		table.insert( z.message_tail, { utilities.set_message ( &#039;err_param_access_requires_param&#039;, {&#039;map-url&#039;}, true ) } );&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language&lt;br /&gt;
	local no_tracking_cats = is_valid_parameter_value (A[&#039;NoTracking&#039;], A:ORIGIN(&#039;NoTracking&#039;), cfg.keywords_lists[&#039;yes_true_y&#039;], nil);&lt;br /&gt;
&lt;br /&gt;
	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories&lt;br /&gt;
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page&lt;br /&gt;
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then&lt;br /&gt;
			no_tracking_cats = &amp;quot;true&amp;quot;;											-- set no_tracking_cats&lt;br /&gt;
		end&lt;br /&gt;
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns&lt;br /&gt;
			if this_page.text:match (v) then									-- test page name against each pattern&lt;br /&gt;
				no_tracking_cats = &amp;quot;true&amp;quot;;										-- set no_tracking_cats&lt;br /&gt;
				break;															-- bail out if one is found&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we&#039;re at it)&lt;br /&gt;
	utilities.select_one (args, {&#039;page&#039;, &#039;p&#039;, &#039;pp&#039;, &#039;pages&#039;, &#039;at&#039;, &#039;sheet&#039;, &#039;sheets&#039;}, &#039;err_redundant_parameters&#039;);	-- this is a dummy call simply to get the error message and category&lt;br /&gt;
&lt;br /&gt;
	local coins_pages;&lt;br /&gt;
	&lt;br /&gt;
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN(&#039;Page&#039;), Pages, A:ORIGIN(&#039;Pages&#039;), At);&lt;br /&gt;
&lt;br /&gt;
	local NoPP = is_valid_parameter_value (A[&#039;NoPP&#039;], A:ORIGIN(&#039;NoPP&#039;), cfg.keywords_lists[&#039;yes_true_y&#039;], nil);&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different&lt;br /&gt;
		utilities.add_prop_cat (&#039;location test&#039;);								-- add property cat to evaluate how often PublicationPlace and Place are used together&lt;br /&gt;
		if PublicationPlace == Place then&lt;br /&gt;
			Place = &#039;&#039;;															-- unset; don&#039;t need both if they are the same&lt;br /&gt;
		end&lt;br /&gt;
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...&lt;br /&gt;
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if PublicationPlace == Place then Place = &#039;&#039;; end							-- don&#039;t need both if they are the same&lt;br /&gt;
	&lt;br /&gt;
	local URL_origin = A:ORIGIN(&#039;URL&#039;);											-- get name of parameter that holds URL&lt;br /&gt;
	local ChapterURL_origin = A:ORIGIN(&#039;ChapterURL&#039;);							-- get name of parameter that holds ChapterURL&lt;br /&gt;
	local ScriptChapter = A[&#039;ScriptChapter&#039;];&lt;br /&gt;
	local ScriptChapter_origin = A:ORIGIN (&#039;ScriptChapter&#039;);&lt;br /&gt;
	local Format = A[&#039;Format&#039;];&lt;br /&gt;
	local ChapterFormat = A[&#039;ChapterFormat&#039;];&lt;br /&gt;
	local TransChapter = A[&#039;TransChapter&#039;];&lt;br /&gt;
	local TransChapter_origin = A:ORIGIN (&#039;TransChapter&#039;);&lt;br /&gt;
	local TransTitle = A[&#039;TransTitle&#039;];&lt;br /&gt;
	local ScriptTitle = A[&#039;ScriptTitle&#039;];&lt;br /&gt;
	&lt;br /&gt;
	--[[&lt;br /&gt;
	Parameter remapping for cite encyclopedia:&lt;br /&gt;
	When the citation has these parameters:&lt;br /&gt;
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=&lt;br /&gt;
		|encyclopedia= and |article= then map |encyclopedia= to |title=&lt;br /&gt;
&lt;br /&gt;
		|trans-title= maps to |trans-chapter= when |title= is re-mapped&lt;br /&gt;
		|url= maps to |chapter-url= when |title= is remapped&lt;br /&gt;
	&lt;br /&gt;
	All other combinations of |encyclopedia=, |title=, and |article= are not modified&lt;br /&gt;
	&lt;br /&gt;
	]]&lt;br /&gt;
&lt;br /&gt;
	local Encyclopedia = A[&#039;Encyclopedia&#039;];										-- used as a flag by this module and by ~/COinS&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}&lt;br /&gt;
		if &#039;encyclopaedia&#039; ~= config.CitationClass and &#039;citation&#039; ~= config.CitationClass then&lt;br /&gt;
			table.insert (z.message_tail, {utilities.set_message (&#039;err_parameter_ignored&#039;, {A:ORIGIN (&#039;Encyclopedia&#039;)}, true)});&lt;br /&gt;
			Encyclopedia = nil;													-- unset because not supported by this template&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (&#039;encyclopaedia&#039; == config.CitationClass) or (&#039;citation&#039; == config.CitationClass and utilities.is_set (Encyclopedia)) then&lt;br /&gt;
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error&lt;br /&gt;
			table.insert (z.message_tail, {utilities.set_message (&#039;err_redundant_parameters&#039;, {utilities.wrap_style (&#039;parameter&#039;, A:ORIGIN (&#039;Encyclopedia&#039;)) .. &#039; and &#039; .. utilities.wrap_style (&#039;parameter&#039;, Periodical_origin)}, true )});&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if utilities.is_set (Encyclopedia) then&lt;br /&gt;
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia&lt;br /&gt;
			Periodical_origin = A:ORIGIN (&#039;Encyclopedia&#039;);&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set&lt;br /&gt;
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then&lt;br /&gt;
				if not utilities.is_set (Chapter) then&lt;br /&gt;
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=&lt;br /&gt;
					ScriptChapter = ScriptTitle;&lt;br /&gt;
					ScriptChapter_origin = A:ORIGIN(&#039;ScriptTitle&#039;)&lt;br /&gt;
					TransChapter = TransTitle;&lt;br /&gt;
					ChapterURL = URL;&lt;br /&gt;
					ChapterURL_origin = URL_origin;&lt;br /&gt;
&lt;br /&gt;
					ChapterUrlAccess = UrlAccess;&lt;br /&gt;
&lt;br /&gt;
					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then&lt;br /&gt;
						Chapter = utilities.make_wikilink (TitleLink, Chapter);&lt;br /&gt;
					end&lt;br /&gt;
					Title = Periodical;&lt;br /&gt;
					ChapterFormat = Format;&lt;br /&gt;
					Periodical = &#039;&#039;;											-- redundant so unset&lt;br /&gt;
					TransTitle = &#039;&#039;;&lt;br /&gt;
					URL = &#039;&#039;;&lt;br /&gt;
					Format = &#039;&#039;;&lt;br /&gt;
					TitleLink = &#039;&#039;;&lt;br /&gt;
					ScriptTitle = &#039;&#039;;&lt;br /&gt;
				end&lt;br /&gt;
			elseif utilities.is_set (Chapter) then								-- |title= not set&lt;br /&gt;
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=&lt;br /&gt;
				Periodical = &#039;&#039;;												-- redundant so unset&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- special case for cite techreport.&lt;br /&gt;
	local ID = A[&#039;ID&#039;];&lt;br /&gt;
	if (config.CitationClass == &amp;quot;techreport&amp;quot;) then								-- special case for cite techreport&lt;br /&gt;
		if utilities.is_set (A[&#039;Number&#039;]) then									-- cite techreport uses &#039;number&#039;, which other citations alias to &#039;issue&#039;&lt;br /&gt;
			if not utilities.is_set (ID) then									-- can we use ID for the &amp;quot;number&amp;quot;?&lt;br /&gt;
				ID = A[&#039;Number&#039;];												-- yes, use it&lt;br /&gt;
			else																-- ID has a value so emit error message&lt;br /&gt;
				table.insert( z.message_tail, { utilities.set_message (&#039;err_redundant_parameters&#039;, {utilities.wrap_style (&#039;parameter&#039;, &#039;id&#039;) .. &#039; and &#039; .. utilities.wrap_style (&#039;parameter&#039;, &#039;number&#039;)}, true )});&lt;br /&gt;
			end&lt;br /&gt;
		end	&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.&lt;br /&gt;
	local ChapterLink -- = A[&#039;ChapterLink&#039;];									-- deprecated as a parameter but still used internally by cite episode&lt;br /&gt;
	local Conference = A[&#039;Conference&#039;];&lt;br /&gt;
	local BookTitle = A[&#039;BookTitle&#039;];&lt;br /&gt;
	local TransTitle_origin = A:ORIGIN (&#039;TransTitle&#039;);&lt;br /&gt;
	if &#039;conference&#039; == config.CitationClass then&lt;br /&gt;
		if utilities.is_set (BookTitle) then&lt;br /&gt;
			Chapter = Title;&lt;br /&gt;
			Chapter_origin = &#039;title&#039;;&lt;br /&gt;
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated&lt;br /&gt;
			ChapterURL = URL;&lt;br /&gt;
			ChapterUrlAccess = UrlAccess;&lt;br /&gt;
			ChapterURL_origin = URL_origin;&lt;br /&gt;
			URL_origin = &#039;&#039;;&lt;br /&gt;
			ChapterFormat = Format;&lt;br /&gt;
			TransChapter = TransTitle;&lt;br /&gt;
			TransChapter_origin = TransTitle_origin;&lt;br /&gt;
			Title = BookTitle;&lt;br /&gt;
			Format = &#039;&#039;;&lt;br /&gt;
	--		TitleLink = &#039;&#039;;&lt;br /&gt;
			TransTitle = &#039;&#039;;&lt;br /&gt;
			URL = &#039;&#039;;&lt;br /&gt;
		end&lt;br /&gt;
	elseif &#039;speech&#039; ~= config.CitationClass then&lt;br /&gt;
		Conference = &#039;&#039;;														-- not cite conference or cite speech so make sure this is empty string&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- CS1/2 mode&lt;br /&gt;
	local Mode = is_valid_parameter_value (A[&#039;Mode&#039;], A:ORIGIN(&#039;Mode&#039;), cfg.keywords_lists[&#039;mode&#039;], &#039;&#039;);&lt;br /&gt;
	-- separator character and postscript&lt;br /&gt;
	local sepc, PostScript = set_style (Mode:lower(), A[&#039;PostScript&#039;], config.CitationClass);&lt;br /&gt;
	-- controls capitalization of certain static text&lt;br /&gt;
	local use_lowercase = ( sepc == &#039;,&#039; );&lt;br /&gt;
	&lt;br /&gt;
	-- cite map oddities&lt;br /&gt;
	local Cartography = &amp;quot;&amp;quot;;&lt;br /&gt;
	local Scale = &amp;quot;&amp;quot;;&lt;br /&gt;
	local Sheet = A[&#039;Sheet&#039;] or &#039;&#039;;&lt;br /&gt;
	local Sheets = A[&#039;Sheets&#039;] or &#039;&#039;;&lt;br /&gt;
	if config.CitationClass == &amp;quot;map&amp;quot; then&lt;br /&gt;
		if utilities.is_set (Chapter) then&lt;br /&gt;
			table.insert( z.message_tail, { utilities.set_message ( &#039;err_redundant_parameters&#039;, {utilities.wrap_style (&#039;parameter&#039;, &#039;map&#039;) .. &#039; and &#039; .. utilities.wrap_style (&#039;parameter&#039;, Chapter_origin)}, true ) } );	-- add error message&lt;br /&gt;
		end&lt;br /&gt;
		Chapter = A[&#039;Map&#039;];&lt;br /&gt;
		Chapter_origin = A:ORIGIN(&#039;Map&#039;);&lt;br /&gt;
		ChapterURL = A[&#039;MapURL&#039;];&lt;br /&gt;
		ChapterURL_origin = A:ORIGIN(&#039;MapURL&#039;);&lt;br /&gt;
		TransChapter = A[&#039;TransMap&#039;];&lt;br /&gt;
		ScriptChapter = A[&#039;ScriptMap&#039;]&lt;br /&gt;
		ScriptChapter_origin = A:ORIGIN(&#039;ScriptMap&#039;)&lt;br /&gt;
&lt;br /&gt;
		ChapterUrlAccess = MapUrlAccess;&lt;br /&gt;
		ChapterFormat = A[&#039;MapFormat&#039;];&lt;br /&gt;
&lt;br /&gt;
		Cartography = A[&#039;Cartography&#039;];&lt;br /&gt;
		if utilities.is_set ( Cartography ) then&lt;br /&gt;
			Cartography = sepc .. &amp;quot; &amp;quot; .. wrap_msg (&#039;cartography&#039;, Cartography, use_lowercase);&lt;br /&gt;
		end		&lt;br /&gt;
		Scale = A[&#039;Scale&#039;];&lt;br /&gt;
		if utilities.is_set ( Scale ) then&lt;br /&gt;
			Scale = sepc .. &amp;quot; &amp;quot; .. Scale;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.&lt;br /&gt;
	local Series = A[&#039;Series&#039;];&lt;br /&gt;
	if &#039;episode&#039; == config.CitationClass or &#039;serial&#039; == config.CitationClass then&lt;br /&gt;
		local SeriesLink = A[&#039;SeriesLink&#039;];&lt;br /&gt;
&lt;br /&gt;
		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN (&#039;SeriesLink&#039;), Series, &#039;series&#039;);	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set&lt;br /&gt;
&lt;br /&gt;
		local Network = A[&#039;Network&#039;];&lt;br /&gt;
		local Station = A[&#039;Station&#039;];&lt;br /&gt;
		local s, n = {}, {};&lt;br /&gt;
																				-- do common parameters first&lt;br /&gt;
		if utilities.is_set (Network) then table.insert(n, Network); end&lt;br /&gt;
		if utilities.is_set (Station) then table.insert(n, Station); end&lt;br /&gt;
		ID = table.concat(n, sepc .. &#039; &#039;);&lt;br /&gt;
		&lt;br /&gt;
		if &#039;episode&#039; == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}&lt;br /&gt;
			local Season = A[&#039;Season&#039;];&lt;br /&gt;
			local SeriesNumber = A[&#039;SeriesNumber&#039;];&lt;br /&gt;
&lt;br /&gt;
			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set&lt;br /&gt;
				table.insert( z.message_tail, { utilities.set_message ( &#039;err_redundant_parameters&#039;, {utilities.wrap_style (&#039;parameter&#039;, &#039;season&#039;) .. &#039; and &#039; .. utilities.wrap_style (&#039;parameter&#039;, &#039;seriesno&#039;)}, true ) } );		-- add error message&lt;br /&gt;
				SeriesNumber = &#039;&#039;;												-- unset; prefer |season= over |seriesno=&lt;br /&gt;
			end&lt;br /&gt;
																				-- assemble a table of parts concatenated later into Series&lt;br /&gt;
			if utilities.is_set (Season) then table.insert(s, wrap_msg (&#039;season&#039;, Season, use_lowercase)); end&lt;br /&gt;
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg (&#039;seriesnum&#039;, SeriesNumber, use_lowercase)); end&lt;br /&gt;
			if utilities.is_set (Issue) then table.insert(s, wrap_msg (&#039;episode&#039;, Issue, use_lowercase)); end&lt;br /&gt;
			Issue = &#039;&#039;;															-- unset because this is not a unique parameter&lt;br /&gt;
	&lt;br /&gt;
			Chapter = Title;													-- promote title parameters to chapter&lt;br /&gt;
			ScriptChapter = ScriptTitle;&lt;br /&gt;
			ScriptChapter_origin = A:ORIGIN(&#039;ScriptTitle&#039;);&lt;br /&gt;
			ChapterLink = TitleLink;											-- alias |episode-link=&lt;br /&gt;
			TransChapter = TransTitle;&lt;br /&gt;
			ChapterURL = URL;&lt;br /&gt;
			ChapterUrlAccess = UrlAccess;&lt;br /&gt;
			ChapterURL_origin = URL_origin;&lt;br /&gt;
			&lt;br /&gt;
			Title = Series;														-- promote series to title&lt;br /&gt;
			TitleLink = SeriesLink;&lt;br /&gt;
			Series = table.concat(s, sepc .. &#039; &#039;);								-- this is concatenation of season, seriesno, episode number&lt;br /&gt;
&lt;br /&gt;
			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL&lt;br /&gt;
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);&lt;br /&gt;
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;&lt;br /&gt;
				Series = utilities.make_wikilink (ChapterLink, Series);&lt;br /&gt;
			end&lt;br /&gt;
			URL = &#039;&#039;;															-- unset&lt;br /&gt;
			TransTitle = &#039;&#039;;&lt;br /&gt;
			ScriptTitle = &#039;&#039;;&lt;br /&gt;
			&lt;br /&gt;
		else																	-- now oddities that are cite serial&lt;br /&gt;
			Issue = &#039;&#039;;															-- unset because this parameter no longer supported by the citation/core version of cite serial&lt;br /&gt;
			Chapter = A[&#039;Episode&#039;];												-- TODO: make |episode= available to cite episode someday?&lt;br /&gt;
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then&lt;br /&gt;
				Series = utilities.make_wikilink (SeriesLink, Series);&lt;br /&gt;
			end&lt;br /&gt;
			Series = utilities.wrap_style (&#039;italic-title&#039;, Series);				-- series is italicized&lt;br /&gt;
		end	&lt;br /&gt;
	end&lt;br /&gt;
	-- end of {{cite episode}} stuff&lt;br /&gt;
&lt;br /&gt;
	-- handle type parameter for those CS1 citations that have default values&lt;br /&gt;
	local TitleType = A[&#039;TitleType&#039;];&lt;br /&gt;
	local Degree = A[&#039;Degree&#039;];&lt;br /&gt;
	if utilities.in_array (config.CitationClass, {&amp;quot;AV-media-notes&amp;quot;, &amp;quot;interview&amp;quot;, &amp;quot;mailinglist&amp;quot;, &amp;quot;map&amp;quot;, &amp;quot;podcast&amp;quot;, &amp;quot;pressrelease&amp;quot;, &amp;quot;report&amp;quot;, &amp;quot;techreport&amp;quot;, &amp;quot;thesis&amp;quot;}) then&lt;br /&gt;
		TitleType = set_titletype (config.CitationClass, TitleType);&lt;br /&gt;
		if utilities.is_set (Degree) and &amp;quot;Thesis&amp;quot; == TitleType then				-- special case for cite thesis&lt;br /&gt;
			TitleType = Degree .. &#039; &#039; .. cfg.title_types [&#039;thesis&#039;]:lower();&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (TitleType) then										-- if type parameter is specified&lt;br /&gt;
		TitleType = utilities.substitute ( cfg.messages[&#039;type&#039;], TitleType);	-- display it in parentheses&lt;br /&gt;
	-- TODO: Hack on TitleType to fix bunched parentheses problem&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.&lt;br /&gt;
	local Date = A[&#039;Date&#039;];&lt;br /&gt;
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging&lt;br /&gt;
	local PublicationDate = A[&#039;PublicationDate&#039;];&lt;br /&gt;
	local Year = A[&#039;Year&#039;];&lt;br /&gt;
&lt;br /&gt;
	if not utilities.is_set (Date) then&lt;br /&gt;
		Date = Year;															-- promote Year to Date&lt;br /&gt;
		Year = nil;																-- make nil so Year as empty string isn&#039;t used for CITEREF&lt;br /&gt;
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set&lt;br /&gt;
			Date = PublicationDate;												-- promote PublicationDate to Date&lt;br /&gt;
			PublicationDate = &#039;&#039;;												-- unset, no longer needed&lt;br /&gt;
			Date_origin = A:ORIGIN(&#039;PublicationDate&#039;);							-- save the name of the promoted parameter&lt;br /&gt;
		else&lt;br /&gt;
			Date_origin = A:ORIGIN(&#039;Year&#039;);										-- save the name of the promoted parameter&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		Date_origin = A:ORIGIN(&#039;Date&#039;);											-- not a promotion; name required for error messaging&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if PublicationDate == Date then PublicationDate = &#039;&#039;; end					-- if PublicationDate is same as Date, don&#039;t display in rendered citation&lt;br /&gt;
&lt;br /&gt;
	--[[&lt;br /&gt;
	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&lt;br /&gt;
	we get the date used in the metadata.&lt;br /&gt;
	&lt;br /&gt;
	Date validation supporting code is in Module:Citation/CS1/Date_validation&lt;br /&gt;
	]]&lt;br /&gt;
&lt;br /&gt;
	local DF = is_valid_parameter_value (A[&#039;DF&#039;], A:ORIGIN(&#039;DF&#039;), cfg.keywords_lists[&#039;df&#039;], &#039;&#039;);&lt;br /&gt;
	if not utilities.is_set (DF) then&lt;br /&gt;
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local ArchiveURL;&lt;br /&gt;
	local ArchiveDate;&lt;br /&gt;
	local ArchiveFormat = A[&#039;ArchiveFormat&#039;];&lt;br /&gt;
&lt;br /&gt;
	ArchiveURL, ArchiveDate = archive_url_check (A[&#039;ArchiveURL&#039;], A[&#039;ArchiveDate&#039;])&lt;br /&gt;
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, &#039;archive-format&#039;, &#039;archive-url&#039;);&lt;br /&gt;
	&lt;br /&gt;
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN(&#039;ArchiveURL&#039;), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	local AccessDate = A[&#039;AccessDate&#039;];&lt;br /&gt;
	local LayDate = A[&#039;LayDate&#039;];&lt;br /&gt;
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification&lt;br /&gt;
	local DoiBroken = A[&#039;DoiBroken&#039;];&lt;br /&gt;
	local Embargo = A[&#039;Embargo&#039;];&lt;br /&gt;
	local anchor_year;															-- used in the CITEREF identifier&lt;br /&gt;
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch&lt;br /&gt;
		local error_message = &#039;&#039;;&lt;br /&gt;
																				-- AirDate has been promoted to Date so not necessary to check it&lt;br /&gt;
		local date_parameters_list = {&lt;br /&gt;
			[&#039;access-date&#039;] = {val = AccessDate, name = A:ORIGIN (&#039;AccessDate&#039;)},&lt;br /&gt;
			[&#039;archive-date&#039;] = {val = ArchiveDate, name = A:ORIGIN (&#039;ArchiveDate&#039;)},&lt;br /&gt;
			[&#039;date&#039;] = {val = Date, name = Date_origin},&lt;br /&gt;
			[&#039;doi-broken-date&#039;] = {val = DoiBroken, name = A:ORIGIN (&#039;DoiBroken&#039;)},&lt;br /&gt;
			[&#039;pmc-embargo-date&#039;] = {val = Embargo, name = A:ORIGIN (&#039;Embargo&#039;)},&lt;br /&gt;
			[&#039;lay-date&#039;] = {val = LayDate, name = A:ORIGIN (&#039;LayDate&#039;)},&lt;br /&gt;
			[&#039;publication-date&#039;] = {val = PublicationDate, name = A:ORIGIN (&#039;PublicationDate&#039;)},&lt;br /&gt;
			[&#039;year&#039;] = {val = Year, name = A:ORIGIN (&#039;Year&#039;)},&lt;br /&gt;
			};&lt;br /&gt;
&lt;br /&gt;
		local error_list = {};&lt;br /&gt;
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);&lt;br /&gt;
&lt;br /&gt;
-- start temporary Julian / Gregorian calendar uncertainty categorization&lt;br /&gt;
		if COinS_date.inter_cal_cat then&lt;br /&gt;
			utilities.add_prop_cat (&#039;jul_greg_uncertainty&#039;);&lt;br /&gt;
		end&lt;br /&gt;
-- end temporary Julian / Gregorian calendar uncertainty categorization&lt;br /&gt;
&lt;br /&gt;
		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; &lt;br /&gt;
			validation.year_date_check (Year, A:ORIGIN (&#039;Year&#039;), Date, A:ORIGIN (&#039;Date&#039;), error_list);&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty&lt;br /&gt;
			local modified = false;												-- flag&lt;br /&gt;
			&lt;br /&gt;
			if validation.edtf_transform (date_parameters_list) then			-- edtf dates to MOS compliant format&lt;br /&gt;
				modified = true;&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			if utilities.is_set (DF) then										-- if we need to reformat dates&lt;br /&gt;
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate&lt;br /&gt;
				modified = true;&lt;br /&gt;
				utilities.set_message (&#039;maint_date_format&#039;);					-- hyphens were converted so add maint category&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
	-- for those wikis that can and want to have English date names translated to the local language,&lt;br /&gt;
	-- uncomment the next three lines.  Not supported by en.wiki (for obvious reasons)&lt;br /&gt;
	-- set validation.date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)&lt;br /&gt;
	--		if validation.date_name_xlate (date_parameters_list, false) then&lt;br /&gt;
	--			modified = true;&lt;br /&gt;
	--		end&lt;br /&gt;
&lt;br /&gt;
			if modified then													-- if the date_parameters_list values were modified&lt;br /&gt;
				AccessDate = date_parameters_list[&#039;access-date&#039;].val;			-- overwrite date holding parameters with modified values&lt;br /&gt;
				ArchiveDate = date_parameters_list[&#039;archive-date&#039;].val;&lt;br /&gt;
				Date = date_parameters_list[&#039;date&#039;].val;&lt;br /&gt;
				DoiBroken = date_parameters_list[&#039;doi-broken-date&#039;].val;&lt;br /&gt;
				LayDate = date_parameters_list[&#039;lay-date&#039;].val;&lt;br /&gt;
				PublicationDate = date_parameters_list[&#039;publication-date&#039;].val;&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			table.insert (z.message_tail, {utilities.set_message (&#039;err_bad_date&#039;, {utilities.make_sep_list (#error_list, error_list)}, true)});	-- add this error message&lt;br /&gt;
		end&lt;br /&gt;
	end	-- end of do&lt;br /&gt;
&lt;br /&gt;
	local ID_list = {};															-- sequence table of rendered identifiers&lt;br /&gt;
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers&#039;s key&lt;br /&gt;
	local Class = A[&#039;Class&#039;];													-- arxiv class identifier&lt;br /&gt;
	&lt;br /&gt;
	local ID_support = {&lt;br /&gt;
		{A[&#039;ASINTLD&#039;], &#039;ASIN&#039;, &#039;err_asintld_missing_asin&#039;, A:ORIGIN (&#039;ASINTLD&#039;)},				&lt;br /&gt;
		{DoiBroken, &#039;DOI&#039;, &#039;err_doibroken_missing_doi&#039;, A:ORIGIN (&#039;DoiBroken&#039;)},&lt;br /&gt;
		{Embargo, &#039;PMC&#039;, &#039;err_embargo_missing_pmc&#039;, A:ORIGIN (&#039;Embargo&#039;)},&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A[&#039;ASINTLD&#039;], Embargo = Embargo, Class = Class}, ID_support);&lt;br /&gt;
&lt;br /&gt;
	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.&lt;br /&gt;
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then&lt;br /&gt;
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp;amp; |citeseerx= required for their templates&lt;br /&gt;
			table.insert (z.message_tail, {utilities.set_message (&#039;err_&#039; .. config.CitationClass .. &#039;_missing&#039;, {}, true)});	-- add error message&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		Periodical = ({[&#039;arxiv&#039;] = &#039;arXiv&#039;, [&#039;biorxiv&#039;] = &#039;bioRxiv&#039;, [&#039;citeseerx&#039;] = &#039;CiteSeerX&#039;, [&#039;ssrn&#039;] = &#039;Social Science Research Network&#039;})[config.CitationClass];&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free&lt;br /&gt;
&lt;br /&gt;
	if config.CitationClass == &amp;quot;journal&amp;quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {&#039;off&#039;, &#039;none&#039;}) then -- TODO: remove &#039;none&#039; once existing citations have been switched to &#039;off&#039;, so &#039;none&#039; can be used as token for &amp;quot;no title&amp;quot; instead&lt;br /&gt;
		if &#039;none&#039; ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled&lt;br /&gt;
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection&lt;br /&gt;
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier&#039;s external link&lt;br /&gt;
 				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=&lt;br /&gt;
			elseif identifiers.auto_link_urls[&#039;pmc&#039;] then						-- auto-select PMC&lt;br /&gt;
				URL = identifiers.auto_link_urls[&#039;pmc&#039;];						-- set URL to be the same as the PMC external link if not embargoed&lt;br /&gt;
				URL_origin = cfg.id_handlers[&#039;PMC&#039;].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=&lt;br /&gt;
			elseif identifiers.auto_link_urls[&#039;doi&#039;] then						-- auto-select DOI&lt;br /&gt;
				URL = identifiers.auto_link_urls[&#039;doi&#039;];&lt;br /&gt;
				URL_origin = cfg.id_handlers[&#039;DOI&#039;].parameters[1];&lt;br /&gt;
			end&lt;br /&gt;
 	 	end&lt;br /&gt;
&lt;br /&gt;
		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=&lt;br /&gt;
			table.insert( z.message_tail, { utilities.set_message ( &#039;err_accessdate_missing_url&#039;, {}, true ) } );	-- add an error message&lt;br /&gt;
			AccessDate = &#039;&#039;;													-- unset&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- At this point fields may be nil if they weren&#039;t specified in the template use.  We can use that fact.&lt;br /&gt;
	-- Test if citation has no title&lt;br /&gt;
	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&lt;br /&gt;
		table.insert( z.message_tail, { utilities.set_message ( &#039;err_citation_missing_title&#039;, {&#039;episode&#039; == config.CitationClass and &#039;series&#039; or &#039;title&#039;}, true ) } );&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if utilities.in_array (cfg.keywords_xlate[Title], {&#039;off&#039;, &#039;none&#039;}) and&lt;br /&gt;
			utilities.in_array (config.CitationClass, {&#039;journal&#039;, &#039;citation&#039;}) and&lt;br /&gt;
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and&lt;br /&gt;
			(&#039;journal&#039; == Periodical_origin or &#039;script-journal&#039; == ScriptPeriodical_origin) then	-- special case for journal cites&lt;br /&gt;
				Title = &#039;&#039;;														-- set title to empty string&lt;br /&gt;
				utilities.set_message (&#039;maint_untitled&#039;);						-- add maint cat&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	check_for_url ({															-- add error message when any of these parameters hold a URL&lt;br /&gt;
		[&#039;title&#039;] = Title,&lt;br /&gt;
		[A:ORIGIN(&#039;Chapter&#039;)] = Chapter,&lt;br /&gt;
		[Periodical_origin] = Periodical,&lt;br /&gt;
		[PublisherName_origin] = PublisherName&lt;br /&gt;
		});&lt;br /&gt;
&lt;br /&gt;
	-- COinS metadata (see &amp;lt;http://ocoins.info/&amp;gt;) for automated parsing of citation information.&lt;br /&gt;
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that&lt;br /&gt;
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title&lt;br /&gt;
	-- is the article title, and Chapter is a section within the article.  So, we remap &lt;br /&gt;
	&lt;br /&gt;
	local coins_chapter = Chapter;												-- default assuming that remapping not required&lt;br /&gt;
	local coins_title = Title;													-- et tu&lt;br /&gt;
	if &#039;encyclopaedia&#039; == config.CitationClass or (&#039;citation&#039; == config.CitationClass and utilities.is_set (Encyclopedia)) then&lt;br /&gt;
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then&lt;br /&gt;
			coins_chapter = Title;												-- remap&lt;br /&gt;
			coins_title = Periodical;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local coins_author = a;														-- default for coins rft.au &lt;br /&gt;
	if 0 &amp;lt; #c then																-- but if contributor list&lt;br /&gt;
		coins_author = c;														-- use that instead&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local QuotePage = A[&#039;QuotePage&#039;];&lt;br /&gt;
	local QuotePages = hyphen_to_dash (A[&#039;QuotePages&#039;]);&lt;br /&gt;
&lt;br /&gt;
	-- this is the function call to COinS()&lt;br /&gt;
	local OCinSoutput = metadata.COinS({&lt;br /&gt;
		[&#039;Periodical&#039;] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata&lt;br /&gt;
		[&#039;Encyclopedia&#039;] = Encyclopedia,										-- just a flag; content ignored by ~/COinS&lt;br /&gt;
		[&#039;Chapter&#039;] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic wiki-markup&lt;br /&gt;
		[&#039;Degree&#039;] = Degree;													-- cite thesis only&lt;br /&gt;
		[&#039;Title&#039;] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic wiki-markup&lt;br /&gt;
		[&#039;PublicationPlace&#039;] = PublicationPlace,&lt;br /&gt;
		[&#039;Date&#039;] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;&lt;br /&gt;
		[&#039;Season&#039;] = COinS_date.rftssn,&lt;br /&gt;
		[&#039;Quarter&#039;] = COinS_date.rftquarter,&lt;br /&gt;
		[&#039;Chron&#039;] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or &#039;&#039;,	-- chron but if not set and invalid date format use Date; keep this last bit?&lt;br /&gt;
		[&#039;Series&#039;] = Series,&lt;br /&gt;
		[&#039;Volume&#039;] = Volume,&lt;br /&gt;
		[&#039;Issue&#039;] = Issue,&lt;br /&gt;
		[&#039;Pages&#039;] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links&lt;br /&gt;
		[&#039;Edition&#039;] = Edition,&lt;br /&gt;
		[&#039;PublisherName&#039;] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName&lt;br /&gt;
		[&#039;URL&#039;] = first_set ({ChapterURL, URL}, 2),&lt;br /&gt;
		[&#039;Authors&#039;] = coins_author,&lt;br /&gt;
		[&#039;ID_list&#039;] = ID_list_coins,&lt;br /&gt;
		[&#039;RawPage&#039;] = this_page.prefixedText,&lt;br /&gt;
	}, config.CitationClass);&lt;br /&gt;
&lt;br /&gt;
	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.&lt;br /&gt;
	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&#039;t displayed&lt;br /&gt;
		Periodical = &#039;&#039;;														-- periodical not allowed in these templates; if article has been published, use cite journal&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text&lt;br /&gt;
	if &#039;newsgroup&#039; == config.CitationClass and utilities.is_set (Newsgroup) then&lt;br /&gt;
		PublisherName = utilities.substitute (cfg.messages[&#039;newsgroup&#039;], external_link( &#039;news:&#039; .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local Editors;&lt;br /&gt;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list&lt;br /&gt;
	local Contributors;															-- assembled contributors name list&lt;br /&gt;
	local contributor_etal;&lt;br /&gt;
	local Translators;															-- assembled translators name list&lt;br /&gt;
	local translator_etal;&lt;br /&gt;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs&lt;br /&gt;
	t = extract_names (args, &#039;TranslatorList&#039;);									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=&lt;br /&gt;
	local Interviewers;															&lt;br /&gt;
	local interviewers_list = {};					&lt;br /&gt;
	interviewers_list = extract_names (args, &#039;InterviewerList&#039;);				-- process preferred interviewers parameters&lt;br /&gt;
	local interviewer_etal;&lt;br /&gt;
	&lt;br /&gt;
	-- Now perform various field substitutions.&lt;br /&gt;
	-- We also add leading spaces and surrounding markup and punctuation to the&lt;br /&gt;
	-- various parts of the citation, but only when they are non-nil.&lt;br /&gt;
	do&lt;br /&gt;
		local last_first_list;&lt;br /&gt;
		local control = { &lt;br /&gt;
			format = NameListStyle,												-- empty string or &#039;vanc&#039;&lt;br /&gt;
			maximum = nil,														-- as if display-authors or display-editors not set&lt;br /&gt;
			mode = Mode&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		do																		-- do editor name list first because the now unsupported coauthors used to modify control table&lt;br /&gt;
			control.maximum , editor_etal = get_display_names (A[&#039;DisplayEditors&#039;], #e, &#039;editors&#039;, editor_etal, A:ORIGIN (&#039;DisplayEditors&#039;));&lt;br /&gt;
			Editors, EditorCount = list_people (control, e, editor_etal);&lt;br /&gt;
&lt;br /&gt;
			if 1 == EditorCount and (true == editor_etal or 1 &amp;lt; #e) then		-- only one editor displayed but includes etal then &lt;br /&gt;
				EditorCount = 2;												-- spoof to display (eds.) annotation&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		do																		-- now do interviewers&lt;br /&gt;
			control.maximum, interviewer_etal = get_display_names (A[&#039;DisplayInterviewers&#039;], #interviewers_list, &#039;interviewers&#039;, interviewer_etal, A:ORIGIN (&#039;DisplayInterviewers&#039;));&lt;br /&gt;
			Interviewers = list_people (control, interviewers_list, interviewer_etal);&lt;br /&gt;
		end&lt;br /&gt;
		do																		-- now do translators&lt;br /&gt;
			control.maximum, translator_etal = get_display_names (A[&#039;DisplayTranslators&#039;], #t, &#039;translators&#039;, translator_etal, A:ORIGIN (&#039;DisplayTranslators&#039;));&lt;br /&gt;
			Translators = list_people (control, t, translator_etal);&lt;br /&gt;
		end&lt;br /&gt;
		do																		-- now do contributors&lt;br /&gt;
			control.maximum, contributor_etal = get_display_names (A[&#039;DisplayContributors&#039;], #c, &#039;contributors&#039;, contributor_etal, A:ORIGIN (&#039;DisplayContributors&#039;));&lt;br /&gt;
			Contributors = list_people (control, c, contributor_etal);&lt;br /&gt;
		end&lt;br /&gt;
		do																		-- now do authors&lt;br /&gt;
			control.maximum, author_etal = get_display_names (A[&#039;DisplayAuthors&#039;], #a, &#039;authors&#039;, author_etal, A:ORIGIN (&#039;DisplayAuthors&#039;));&lt;br /&gt;
&lt;br /&gt;
			last_first_list = list_people (control, a, author_etal);&lt;br /&gt;
&lt;br /&gt;
			if utilities.is_set (Authors) then&lt;br /&gt;
				Authors, author_etal = name_has_etal (Authors, author_etal, false, &#039;authors&#039;);	-- find and remove variations on et al.&lt;br /&gt;
				if author_etal then&lt;br /&gt;
					Authors = Authors .. &#039; &#039; .. cfg.messages[&#039;et al&#039;];			-- add et al. to authors parameter&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				Authors = last_first_list;										-- either an author name list or an empty string&lt;br /&gt;
			end&lt;br /&gt;
		end																		-- end of do&lt;br /&gt;
	&lt;br /&gt;
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then&lt;br /&gt;
			Authors = Authors .. &#039; (&#039; .. Collaboration .. &#039;)&#039;;					-- add collaboration after et al.&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local ConferenceFormat = A[&#039;ConferenceFormat&#039;];&lt;br /&gt;
	local ConferenceURL = A[&#039;ConferenceURL&#039;];&lt;br /&gt;
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, &#039;conference-format&#039;, &#039;conference-url&#039;);&lt;br /&gt;
	Format = style_format (Format, URL, &#039;format&#039;, &#039;url&#039;);&lt;br /&gt;
&lt;br /&gt;
	-- special case for chapter format so no error message or cat when chapter not supported&lt;br /&gt;
	if not (utilities.in_array (config.CitationClass, {&#039;web&#039;, &#039;news&#039;, &#039;journal&#039;, &#039;magazine&#039;, &#039;pressrelease&#039;, &#039;podcast&#039;, &#039;newsgroup&#039;, &#039;arxiv&#039;, &#039;biorxiv&#039;, &#039;citeseerx&#039;, &#039;ssrn&#039;}) or&lt;br /&gt;
		(&#039;citation&#039; == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then&lt;br /&gt;
			ChapterFormat = style_format (ChapterFormat, ChapterURL, &#039;chapter-format&#039;, &#039;chapter-url&#039;);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not utilities.is_set (URL) then&lt;br /&gt;
		if utilities.in_array (config.CitationClass, {&amp;quot;web&amp;quot;, &amp;quot;podcast&amp;quot;, &amp;quot;mailinglist&amp;quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist&lt;br /&gt;
			(&#039;citation&#039; == config.CitationClass and (&#039;website&#039; == Periodical_origin or &#039;script-website&#039; == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=&lt;br /&gt;
				table.insert( z.message_tail, { utilities.set_message ( &#039;err_cite_web_url&#039;, {}, true ) } );&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		-- do we have |accessdate= without either |url= or |chapter-url=?&lt;br /&gt;
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;&lt;br /&gt;
			table.insert( z.message_tail, { utilities.set_message ( &#039;err_accessdate_missing_url&#039;, {}, true ) } );&lt;br /&gt;
			AccessDate = &#039;&#039;;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local UrlStatus = is_valid_parameter_value (A[&#039;UrlStatus&#039;], A:ORIGIN(&#039;UrlStatus&#039;), cfg.keywords_lists[&#039;url-status&#039;], &#039;&#039;);&lt;br /&gt;
	local OriginalURL&lt;br /&gt;
	local OriginalURL_origin&lt;br /&gt;
	local OriginalFormat&lt;br /&gt;
	local OriginalAccess;&lt;br /&gt;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text&lt;br /&gt;
	if utilities.is_set ( ArchiveURL ) then&lt;br /&gt;
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it&lt;br /&gt;
			OriginalURL = ChapterURL;											-- save copy of source chapter&#039;s url for archive text&lt;br /&gt;
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages&lt;br /&gt;
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=&lt;br /&gt;
&lt;br /&gt;
			if &#039;live&#039; ~= UrlStatus then&lt;br /&gt;
				ChapterURL = ArchiveURL											-- swap-in the archive&#039;s URL&lt;br /&gt;
				ChapterURL_origin = A:ORIGIN(&#039;ArchiveURL&#039;)						-- name of |archive-url= parameter for error messages&lt;br /&gt;
				ChapterFormat = ArchiveFormat or &#039;&#039;;							-- swap in archive&#039;s format&lt;br /&gt;
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs&lt;br /&gt;
			end&lt;br /&gt;
		elseif utilities.is_set (URL) then&lt;br /&gt;
			OriginalURL = URL;													-- save copy of original source URL&lt;br /&gt;
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages&lt;br /&gt;
			OriginalFormat = Format; 											-- and original |format=&lt;br /&gt;
			OriginalAccess = UrlAccess;&lt;br /&gt;
&lt;br /&gt;
			if &#039;live&#039; ~= UrlStatus then											-- if URL set then |archive-url= applies to it&lt;br /&gt;
				URL = ArchiveURL												-- swap-in the archive&#039;s URL&lt;br /&gt;
				URL_origin = A:ORIGIN(&#039;ArchiveURL&#039;)								-- name of archive URL parameter for error messages&lt;br /&gt;
				Format = ArchiveFormat or &#039;&#039;;									-- swap in archive&#039;s format&lt;br /&gt;
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs&lt;br /&gt;
			end&lt;br /&gt;
 		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if utilities.in_array (config.CitationClass, {&#039;web&#039;, &#039;news&#039;, &#039;journal&#039;, &#039;magazine&#039;, &#039;pressrelease&#039;, &#039;podcast&#039;, &#039;newsgroup&#039;, &#039;arxiv&#039;, &#039;biorxiv&#039;, &#039;citeseerx&#039;, &#039;ssrn&#039;}) or	-- if any of the &#039;periodical&#039; cites except encyclopedia&lt;br /&gt;
		(&#039;citation&#039; == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then&lt;br /&gt;
			local chap_param;&lt;br /&gt;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters&lt;br /&gt;
				chap_param = A:ORIGIN (&#039;Chapter&#039;)&lt;br /&gt;
			elseif utilities.is_set (TransChapter) then&lt;br /&gt;
				chap_param = A:ORIGIN (&#039;TransChapter&#039;)&lt;br /&gt;
			elseif utilities.is_set (ChapterURL) then&lt;br /&gt;
				chap_param = A:ORIGIN (&#039;ChapterURL&#039;)&lt;br /&gt;
			elseif utilities.is_set (ScriptChapter) then&lt;br /&gt;
				chap_param = ScriptChapter_origin;&lt;br /&gt;
			else utilities.is_set (ChapterFormat)&lt;br /&gt;
				chap_param = A:ORIGIN (&#039;ChapterFormat&#039;)&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			if utilities.is_set (chap_param) then								-- if we found one&lt;br /&gt;
				table.insert( z.message_tail, { utilities.set_message ( &#039;err_chapter_ignored&#039;, {chap_param}, true ) } );	-- add error message&lt;br /&gt;
				Chapter = &#039;&#039;;													-- and set them to empty string to be safe with concatenation&lt;br /&gt;
				TransChapter = &#039;&#039;;&lt;br /&gt;
				ChapterURL = &#039;&#039;;&lt;br /&gt;
				ScriptChapter = &#039;&#039;;&lt;br /&gt;
				ChapterFormat = &#039;&#039;;&lt;br /&gt;
			end&lt;br /&gt;
	else																		-- otherwise, format chapter / article title&lt;br /&gt;
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value&lt;br /&gt;
		if utilities.is_set (Contribution) and 0 &amp;lt; #c then						-- if this is a contribution with contributor(s)&lt;br /&gt;
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title&lt;br /&gt;
				no_quotes = true;												-- then render it unquoted&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter&lt;br /&gt;
		if utilities.is_set (Chapter) then&lt;br /&gt;
			Chapter = Chapter .. ChapterFormat ;&lt;br /&gt;
			if &#039;map&#039; == config.CitationClass and utilities.is_set (TitleType) then&lt;br /&gt;
				Chapter = Chapter .. &#039; &#039; .. TitleType;							-- map annotation here; not after title&lt;br /&gt;
			end&lt;br /&gt;
			Chapter = Chapter .. sepc .. &#039; &#039;;&lt;br /&gt;
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...&lt;br /&gt;
			Chapter = ChapterFormat .. sepc .. &#039; &#039;;								-- ... ChapterFormat has error message, we want to see it&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Format main title&lt;br /&gt;
	local plain_title = false;&lt;br /&gt;
	local accept_title;&lt;br /&gt;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &amp;lt;Title&amp;gt;&lt;br /&gt;
	if accept_title and (&#039;&#039; == Title) then										-- only support forced empty for now &amp;quot;(())&amp;quot;&lt;br /&gt;
		Title = cfg.messages[&#039;notitle&#039;];										-- replace by predefined &amp;quot;No title&amp;quot; message&lt;br /&gt;
			-- TODO: utilities.set_message ( &#039;err_redundant_parameters&#039;, ...);	-- issue proper error message instead of muting	 &lt;br /&gt;
			ScriptTitle = &#039;&#039;;													-- just mute for now	 &lt;br /&gt;
			TransTitle = &#039;&#039;;													-- just mute for now&lt;br /&gt;
 		plain_title = true;														-- suppress text decoration for descriptive title&lt;br /&gt;
		utilities.set_message (&#039;maint_untitled&#039;);								-- add maint cat&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not accept_title then -- &amp;lt;Title&amp;gt; not wrapped in accept-as-written markup&lt;br /&gt;
		if &#039;...&#039; == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=&lt;br /&gt;
			Title = Title:gsub (&#039;(%.%.%.)%.+$&#039;, &#039;%1&#039;);							-- limit the number of dots to three&lt;br /&gt;
		elseif not mw.ustring.find (Title, &#039;%.%s*%a%.$&#039;) and					-- end of title is not a &#039;dot-(optional space-)letter-dot&#039; initialism ...&lt;br /&gt;
			not mw.ustring.find (Title, &#039;%s+%a%.$&#039;) then						-- ...and not a &#039;space-letter-dot&#039; initial (&#039;&#039;Allium canadense&#039;&#039; L.)&lt;br /&gt;
				Title = mw.ustring.gsub(Title, &#039;%&#039; .. sepc .. &#039;$&#039;, &#039;&#039;);			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then&lt;br /&gt;
			utilities.set_message (&#039;maint_archived_copy&#039;);						-- add maintenance category before we modify the content of Title&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if is_generic_title (Title) then&lt;br /&gt;
			table.insert (z.message_tail, {utilities.set_message ( &#039;err_generic_title&#039;, {}, true ) } );	-- set an error message&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (not plain_title) and (utilities.in_array (config.CitationClass, {&#039;web&#039;, &#039;news&#039;, &#039;journal&#039;, &#039;magazine&#039;, &#039;pressrelease&#039;, &#039;podcast&#039;, &#039;newsgroup&#039;, &#039;mailinglist&#039;, &#039;interview&#039;, &#039;arxiv&#039;, &#039;biorxiv&#039;, &#039;citeseerx&#039;, &#039;ssrn&#039;}) or&lt;br /&gt;
		(&#039;citation&#039; == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or&lt;br /&gt;
		(&#039;map&#039; == 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&lt;br /&gt;
			Title = kern_quotes (Title);										-- if necessary, separate title&#039;s leading and trailing quote marks from module provided quote marks&lt;br /&gt;
			Title = utilities.wrap_style (&#039;quoted-title&#039;, Title);&lt;br /&gt;
			Title = script_concatenate (Title, ScriptTitle, &#039;script-title&#039;);	-- &amp;lt;bdi&amp;gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped&lt;br /&gt;
			TransTitle = utilities.wrap_style (&#039;trans-quoted-title&#039;, TransTitle );&lt;br /&gt;
	elseif plain_title or (&#039;report&#039; == config.CitationClass) then								-- no styling for cite report and descriptive titles (otherwise same as above)&lt;br /&gt;
		Title = script_concatenate (Title, ScriptTitle, &#039;script-title&#039;);		-- &amp;lt;bdi&amp;gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped&lt;br /&gt;
		TransTitle = utilities.wrap_style (&#039;trans-quoted-title&#039;, TransTitle );				-- for cite report, use this form for trans-title&lt;br /&gt;
	else&lt;br /&gt;
		Title = utilities.wrap_style (&#039;italic-title&#039;, Title);&lt;br /&gt;
		Title = script_concatenate (Title, ScriptTitle, &#039;script-title&#039;);		-- &amp;lt;bdi&amp;gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped&lt;br /&gt;
		TransTitle = utilities.wrap_style (&#039;trans-italic-title&#039;, TransTitle);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local TransError = &amp;quot;&amp;quot;;&lt;br /&gt;
	if utilities.is_set (TransTitle) then&lt;br /&gt;
		if utilities.is_set (Title) then&lt;br /&gt;
			TransTitle = &amp;quot; &amp;quot; .. TransTitle;&lt;br /&gt;
		else&lt;br /&gt;
			TransError = &amp;quot; &amp;quot; .. utilities.set_message ( &#039;err_trans_missing_title&#039;, {&#039;title&#039;} );&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?&lt;br /&gt;
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then&lt;br /&gt;
			table.insert( z.message_tail, { utilities.set_message ( &#039;err_wikilink_in_url&#039;, {}, true ) } );	-- set an error message because we can&#039;t have both&lt;br /&gt;
			TitleLink = &#039;&#039;;														-- unset&lt;br /&gt;
		end&lt;br /&gt;
	&lt;br /&gt;
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then&lt;br /&gt;
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. TransError .. Format;&lt;br /&gt;
			URL = &#039;&#039;;															-- unset these because no longer needed&lt;br /&gt;
			Format = &amp;quot;&amp;quot;;&lt;br /&gt;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then&lt;br /&gt;
			local ws_url;&lt;br /&gt;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here&lt;br /&gt;
			if ws_url then&lt;br /&gt;
				Title = external_link (ws_url, Title .. &#039;&amp;amp;nbsp;&#039;, &#039;ws link in title-link&#039;);	-- space char after Title to move icon away from italic text; TODO: a better way to do this?&lt;br /&gt;
				Title = utilities.substitute (cfg.presentation[&#039;interwiki-icon&#039;], {cfg.presentation[&#039;class-wikisource&#039;], TitleLink, Title});				&lt;br /&gt;
				Title = Title .. TransTitle .. TransError;&lt;br /&gt;
			else&lt;br /&gt;
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle .. TransError;&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			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)&lt;br /&gt;
			ws_url, ws_label, L = wikisource_url_make (Title:gsub(&#039;^[\&#039;&amp;quot;]*(.-)[\&#039;&amp;quot;]*$&#039;, &#039;%1&#039;));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label&lt;br /&gt;
			if ws_url then&lt;br /&gt;
				Title = Title:gsub (&#039;%b[]&#039;, ws_label);							-- replace interwiki link with ws_label to retain markup&lt;br /&gt;
				Title = external_link (ws_url, Title .. &#039;&amp;amp;nbsp;&#039;, &#039;ws link in title&#039;);	-- space char after Title to move icon away from italic text; TODO: a better way to do this?&lt;br /&gt;
				Title = utilities.substitute (cfg.presentation[&#039;interwiki-icon&#039;], {cfg.presentation[&#039;class-wikisource&#039;], L, Title});				&lt;br /&gt;
				Title = Title .. TransTitle .. TransError;&lt;br /&gt;
			else&lt;br /&gt;
				Title = Title .. TransTitle .. TransError;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		Title = TransTitle .. TransError;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (Place) then&lt;br /&gt;
		Place = &amp;quot; &amp;quot; .. wrap_msg (&#039;written&#039;, Place, use_lowercase) .. sepc .. &amp;quot; &amp;quot;;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local ConferenceURL_origin = A:ORIGIN(&#039;ConferenceURL&#039;);						-- get name of parameter that holds ConferenceURL&lt;br /&gt;
	if utilities.is_set (Conference) then&lt;br /&gt;
		if utilities.is_set (ConferenceURL) then&lt;br /&gt;
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );&lt;br /&gt;
		end&lt;br /&gt;
		Conference = sepc .. &amp;quot; &amp;quot; .. Conference .. ConferenceFormat;&lt;br /&gt;
	elseif utilities.is_set (ConferenceURL) then&lt;br /&gt;
		Conference = sepc .. &amp;quot; &amp;quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local Position = &#039;&#039;;&lt;br /&gt;
	if not utilities.is_set (Position) then&lt;br /&gt;
		local Minutes = A[&#039;Minutes&#039;];&lt;br /&gt;
		local Time = A[&#039;Time&#039;];&lt;br /&gt;
&lt;br /&gt;
		if utilities.is_set (Minutes) then&lt;br /&gt;
			if utilities.is_set (Time) then&lt;br /&gt;
				table.insert( z.message_tail, { utilities.set_message ( &#039;err_redundant_parameters&#039;, {utilities.wrap_style (&#039;parameter&#039;, &#039;minutes&#039;) .. &#039; and &#039; .. utilities.wrap_style (&#039;parameter&#039;, &#039;time&#039;)}, true ) } );&lt;br /&gt;
			end&lt;br /&gt;
			Position = &amp;quot; &amp;quot; .. Minutes .. &amp;quot; &amp;quot; .. cfg.messages[&#039;minutes&#039;];&lt;br /&gt;
		else&lt;br /&gt;
			if utilities.is_set (Time) then&lt;br /&gt;
				local TimeCaption = A[&#039;TimeCaption&#039;]&lt;br /&gt;
				if not utilities.is_set (TimeCaption) then&lt;br /&gt;
					TimeCaption = cfg.messages[&#039;event&#039;];&lt;br /&gt;
					if sepc ~= &#039;.&#039; then&lt;br /&gt;
						TimeCaption = TimeCaption:lower();&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
				Position = &amp;quot; &amp;quot; .. TimeCaption .. &amp;quot; &amp;quot; .. Time;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		Position = &amp;quot; &amp;quot; .. Position;&lt;br /&gt;
		At = &#039;&#039;;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);&lt;br /&gt;
&lt;br /&gt;
	At = utilities.is_set (At) and (sepc .. &amp;quot; &amp;quot; .. At) or &amp;quot;&amp;quot;;&lt;br /&gt;
	Position = utilities.is_set (Position) and (sepc .. &amp;quot; &amp;quot; .. Position) or &amp;quot;&amp;quot;;&lt;br /&gt;
	if config.CitationClass == &#039;map&#039; then&lt;br /&gt;
		local Sections = A[&#039;Sections&#039;];											-- Section (singular) is an alias of Chapter so set earlier&lt;br /&gt;
		local Inset = A[&#039;Inset&#039;];&lt;br /&gt;
		&lt;br /&gt;
		if utilities.is_set ( Inset ) then&lt;br /&gt;
			Inset = sepc .. &amp;quot; &amp;quot; .. wrap_msg (&#039;inset&#039;, Inset, use_lowercase);&lt;br /&gt;
		end			&lt;br /&gt;
&lt;br /&gt;
		if utilities.is_set ( Sections ) then&lt;br /&gt;
			Section = sepc .. &amp;quot; &amp;quot; .. wrap_msg (&#039;sections&#039;, Sections, use_lowercase);&lt;br /&gt;
		elseif utilities.is_set ( Section ) then&lt;br /&gt;
			Section = sepc .. &amp;quot; &amp;quot; .. wrap_msg (&#039;section&#039;, Section, use_lowercase);&lt;br /&gt;
		end&lt;br /&gt;
		At = At .. Inset .. Section;		&lt;br /&gt;
	end	&lt;br /&gt;
&lt;br /&gt;
	local Others = A[&#039;Others&#039;];&lt;br /&gt;
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=&lt;br /&gt;
		if config.CitationClass == &amp;quot;AV-media-notes&amp;quot;&lt;br /&gt;
		or config.CitationClass == &amp;quot;audio-visual&amp;quot; then							-- special maint for AV/M which has a lot of &#039;false&#039; positives right now&lt;br /&gt;
			utilities.set_message (&#039;maint_others_avm&#039;)&lt;br /&gt;
		else&lt;br /&gt;
			utilities.set_message (&#039;maint_others&#039;);&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	Others = utilities.is_set (Others) and (sepc .. &amp;quot; &amp;quot; .. Others) or &amp;quot;&amp;quot;;&lt;br /&gt;
	&lt;br /&gt;
	if utilities.is_set (Translators) then&lt;br /&gt;
		Others = safe_join ({sepc .. &#039; &#039;, wrap_msg (&#039;translated&#039;, Translators, use_lowercase), Others}, sepc);&lt;br /&gt;
	end&lt;br /&gt;
	if utilities.is_set (Interviewers) then&lt;br /&gt;
		Others = safe_join ({sepc .. &#039; &#039;, wrap_msg (&#039;interview&#039;, Interviewers, use_lowercase), Others}, sepc);&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local TitleNote = A[&#039;TitleNote&#039;];&lt;br /&gt;
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &amp;quot; &amp;quot; .. TitleNote) or &amp;quot;&amp;quot;;&lt;br /&gt;
	if utilities.is_set (Edition) then&lt;br /&gt;
		if Edition:match (&#039;%f[%a][Ee]d%n?%.?$&#039;) or Edition:match (&#039;%f[%a][Ee]dition$&#039;) then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.&lt;br /&gt;
			table.insert( z.message_tail, { utilities.set_message ( &#039;err_extra_text_edition&#039;)}); -- add error&lt;br /&gt;
		end&lt;br /&gt;
		Edition = &amp;quot; &amp;quot; .. wrap_msg (&#039;edition&#039;, Edition);&lt;br /&gt;
	else&lt;br /&gt;
		Edition = &#039;&#039;;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	Series = utilities.is_set (Series) and wrap_msg (&#039;series&#039;, {sepc, Series}) or &amp;quot;&amp;quot;;	-- not the same as SeriesNum&lt;br /&gt;
	local Agency = A[&#039;Agency&#039;];&lt;br /&gt;
	Agency = utilities.is_set (Agency) and wrap_msg (&#039;agency&#039;, {sepc, Agency}) or &amp;quot;&amp;quot;;&lt;br /&gt;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (AccessDate) then&lt;br /&gt;
		local retrv_text = &amp;quot; &amp;quot; .. cfg.messages[&#039;retrieved&#039;]&lt;br /&gt;
&lt;br /&gt;
		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format&lt;br /&gt;
		if (sepc ~= &amp;quot;.&amp;quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case&lt;br /&gt;
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text&lt;br /&gt;
&lt;br /&gt;
		AccessDate = utilities.substitute (cfg.presentation[&#039;accessdate&#039;], {sepc, AccessDate});	-- allow editors to hide accessdates&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if utilities.is_set (ID) then ID = sepc .. &amp;quot; &amp;quot; .. ID; end&lt;br /&gt;
	&lt;br /&gt;
	local Docket = A[&#039;Docket&#039;];&lt;br /&gt;
   	if &amp;quot;thesis&amp;quot; == config.CitationClass and utilities.is_set (Docket) then&lt;br /&gt;
		ID = sepc .. &amp;quot; Docket &amp;quot; .. Docket .. ID;&lt;br /&gt;
	end&lt;br /&gt;
   	if &amp;quot;report&amp;quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set&lt;br /&gt;
		ID = sepc .. &#039; &#039; .. Docket;												-- overwrite ID even if |id= is set&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (URL) then&lt;br /&gt;
		URL = &amp;quot; &amp;quot; .. external_link( URL, nil, URL_origin, UrlAccess );&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local Quote = A[&#039;Quote&#039;];&lt;br /&gt;
	local TransQuote = A[&#039;TransQuote&#039;];&lt;br /&gt;
	local ScriptQuote = A[&#039;ScriptQuote&#039;];&lt;br /&gt;
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then&lt;br /&gt;
&lt;br /&gt;
		if utilities.is_set (Quote) then&lt;br /&gt;
			if Quote:sub(1, 1) == &#039;&amp;quot;&#039; and Quote:sub(-1, -1) == &#039;&amp;quot;&#039; then			-- if first and last characters of quote are quote marks&lt;br /&gt;
				Quote = Quote:sub(2, -2);										-- strip them off&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		Quote = utilities.wrap_style (&#039;quoted-text&#039;, Quote );					-- wrap in &amp;lt;q&amp;gt;...&amp;lt;/q&amp;gt; tags&lt;br /&gt;
	&lt;br /&gt;
		if utilities.is_set (ScriptQuote) then&lt;br /&gt;
			Quote = script_concatenate (Quote, ScriptQuote, &#039;script-quote&#039;);	-- &amp;lt;bdi&amp;gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if utilities.is_set (TransQuote) then&lt;br /&gt;
			if TransQuote:sub(1, 1) == &#039;&amp;quot;&#039; and TransQuote:sub(-1, -1) == &#039;&amp;quot;&#039; then -- if first and last characters of |trans-quote are quote marks&lt;br /&gt;
				TransQuote = TransQuote:sub(2, -2); -- strip them off&lt;br /&gt;
			end&lt;br /&gt;
			Quote = Quote .. &amp;quot; &amp;quot; .. utilities.wrap_style (&#039;trans-quoted-title&#039;, TransQuote );&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix&lt;br /&gt;
			local quote_prefix = &#039;&#039;;&lt;br /&gt;
			if utilities.is_set (QuotePage) then&lt;br /&gt;
				extra_text_in_page_check (QuotePage, &#039;quote-page&#039;);				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.&lt;br /&gt;
				if not NoPP then&lt;br /&gt;
					quote_prefix = utilities.substitute (cfg.messages[&#039;p-prefix&#039;], {sepc, QuotePage}), &#039;&#039;, &#039;&#039;, &#039;&#039;;&lt;br /&gt;
				else&lt;br /&gt;
					quote_prefix = utilities.substitute (cfg.messages[&#039;nopp&#039;], {sepc, QuotePage}), &#039;&#039;, &#039;&#039;, &#039;&#039;;&lt;br /&gt;
				end&lt;br /&gt;
			elseif utilities.is_set (QuotePages) then&lt;br /&gt;
				extra_text_in_page_check (QuotePages, &#039;quote-pages&#039;);			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.&lt;br /&gt;
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page&lt;br /&gt;
					quote_prefix = utilities.substitute (cfg.messages[&#039;p-prefix&#039;], {sepc, QuotePages}), &#039;&#039;, &#039;&#039;;&lt;br /&gt;
				elseif not NoPP then&lt;br /&gt;
					quote_prefix = utilities.substitute (cfg.messages[&#039;pp-prefix&#039;], {sepc, QuotePages}), &#039;&#039;, &#039;&#039;;&lt;br /&gt;
				else&lt;br /&gt;
					quote_prefix = utilities.substitute (cfg.messages[&#039;nopp&#039;], {sepc, QuotePages}), &#039;&#039;, &#039;&#039;;&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
                        &lt;br /&gt;
			Quote = quote_prefix .. &amp;quot;: &amp;quot; .. Quote;&lt;br /&gt;
		else&lt;br /&gt;
			Quote = sepc .. &amp;quot; &amp;quot; .. Quote;&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		PostScript = &amp;quot;&amp;quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- We check length of PostScript here because it will have been nuked by&lt;br /&gt;
	-- the quote parameters. We&#039;d otherwise emit a message even if there wasn&#039;t&lt;br /&gt;
	-- a displayed postscript.&lt;br /&gt;
	-- TODO: Should the max size (1) be configurable?&lt;br /&gt;
	-- TODO: Should we check a specific pattern?&lt;br /&gt;
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &amp;gt; 1 then&lt;br /&gt;
		utilities.set_message(&#039;maint_postscript&#039;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local Archived&lt;br /&gt;
	if utilities.is_set (ArchiveURL) then&lt;br /&gt;
		local arch_text;&lt;br /&gt;
		if not utilities.is_set (ArchiveDate) then&lt;br /&gt;
			ArchiveDate = utilities.set_message (&#039;err_archive_missing_date&#039;);&lt;br /&gt;
		end&lt;br /&gt;
		if &amp;quot;live&amp;quot; == UrlStatus then&lt;br /&gt;
			arch_text = cfg.messages[&#039;archived&#039;];&lt;br /&gt;
			if sepc ~= &amp;quot;.&amp;quot; then arch_text = arch_text:lower() end&lt;br /&gt;
			Archived = sepc .. &amp;quot; &amp;quot; .. utilities.substitute ( cfg.messages[&#039;archived-live&#039;],&lt;br /&gt;
				{ external_link( ArchiveURL, arch_text, A:ORIGIN(&#039;ArchiveURL&#039;), nil ) .. ArchiveFormat, ArchiveDate } );&lt;br /&gt;
			if not utilities.is_set (OriginalURL) then&lt;br /&gt;
				Archived = Archived .. &amp;quot; &amp;quot; .. utilities.set_message (&#039;err_archive_missing_url&#039;);							   &lt;br /&gt;
			end&lt;br /&gt;
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, &#039;dead&#039;, &#039;unfit&#039;, &#039;usurped&#039;, &#039;bot: unknown&#039;&lt;br /&gt;
			if utilities.in_array (UrlStatus, {&#039;unfit&#039;, &#039;usurped&#039;, &#039;bot: unknown&#039;}) then&lt;br /&gt;
				arch_text = cfg.messages[&#039;archived-unfit&#039;];&lt;br /&gt;
				if sepc ~= &amp;quot;.&amp;quot; then arch_text = arch_text:lower() end&lt;br /&gt;
				Archived = sepc .. &amp;quot; &amp;quot; .. arch_text .. ArchiveDate;				-- format already styled&lt;br /&gt;
				if &#039;bot: unknown&#039; == UrlStatus then&lt;br /&gt;
					utilities.set_message (&#039;maint_bot_unknown&#039;);				-- and add a category if not already added&lt;br /&gt;
				else&lt;br /&gt;
					utilities.set_message (&#039;maint_unfit&#039;);						-- and add a category if not already added&lt;br /&gt;
				end&lt;br /&gt;
			else																-- UrlStatus is empty, &#039;dead&#039;&lt;br /&gt;
				arch_text = cfg.messages[&#039;archived-dead&#039;];&lt;br /&gt;
				if sepc ~= &amp;quot;.&amp;quot; then arch_text = arch_text:lower() end&lt;br /&gt;
				Archived = sepc .. &amp;quot; &amp;quot; .. utilities.substitute ( arch_text,&lt;br /&gt;
					{ external_link( OriginalURL, cfg.messages[&#039;original&#039;], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled&lt;br /&gt;
			end	&lt;br /&gt;
		else																	-- OriginalUrl not set&lt;br /&gt;
			arch_text = cfg.messages[&#039;archived-missing&#039;];&lt;br /&gt;
			if sepc ~= &amp;quot;.&amp;quot; then arch_text = arch_text:lower() end&lt;br /&gt;
			Archived = sepc .. &amp;quot; &amp;quot; .. utilities.substitute ( arch_text, &lt;br /&gt;
				{ utilities.set_message (&#039;err_archive_missing_url&#039;), ArchiveDate } );&lt;br /&gt;
		end&lt;br /&gt;
	elseif utilities.is_set (ArchiveFormat) then&lt;br /&gt;
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message&lt;br /&gt;
	else&lt;br /&gt;
		Archived = &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local Lay = &#039;&#039;;&lt;br /&gt;
	local LaySource = A[&#039;LaySource&#039;];&lt;br /&gt;
	local LayURL = A[&#039;LayURL&#039;];&lt;br /&gt;
	local LayFormat = A[&#039;LayFormat&#039;];&lt;br /&gt;
	LayFormat = style_format (LayFormat, LayURL, &#039;lay-format&#039;, &#039;lay-url&#039;);&lt;br /&gt;
	if utilities.is_set (LayURL) then&lt;br /&gt;
		if utilities.is_set (LayDate) then LayDate = &amp;quot; (&amp;quot; .. LayDate .. &amp;quot;)&amp;quot; end&lt;br /&gt;
		if utilities.is_set (LaySource) then &lt;br /&gt;
			LaySource = &amp;quot; &amp;amp;ndash; &#039;&#039;&amp;quot; .. utilities.safe_for_italics (LaySource) .. &amp;quot;&#039;&#039;&amp;quot;;&lt;br /&gt;
		else&lt;br /&gt;
			LaySource = &amp;quot;&amp;quot;;&lt;br /&gt;
		end&lt;br /&gt;
		if sepc == &#039;.&#039; then&lt;br /&gt;
			Lay = sepc .. &amp;quot; &amp;quot; .. external_link( LayURL, cfg.messages[&#039;lay summary&#039;], A:ORIGIN(&#039;LayURL&#039;), nil ) .. LayFormat .. LaySource .. LayDate&lt;br /&gt;
		else&lt;br /&gt;
			Lay = sepc .. &amp;quot; &amp;quot; .. external_link( LayURL, cfg.messages[&#039;lay summary&#039;]:lower(), A:ORIGIN(&#039;LayURL&#039;), nil ) .. LayFormat .. LaySource .. LayDate&lt;br /&gt;
		end			&lt;br /&gt;
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=&lt;br /&gt;
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local TranscriptURL = A[&#039;TranscriptURL&#039;]&lt;br /&gt;
	local TranscriptFormat = A[&#039;TranscriptFormat&#039;];&lt;br /&gt;
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, &#039;transcript-format&#039;, &#039;transcripturl&#039;);&lt;br /&gt;
	local Transcript = A[&#039;Transcript&#039;];&lt;br /&gt;
	local TranscriptURL_origin = A:ORIGIN(&#039;TranscriptURL&#039;);						-- get name of parameter that holds TranscriptURL&lt;br /&gt;
	if utilities.is_set (Transcript) then&lt;br /&gt;
		if utilities.is_set (TranscriptURL) then&lt;br /&gt;
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );&lt;br /&gt;
		end&lt;br /&gt;
		Transcript = sepc .. &#039; &#039; .. Transcript .. TranscriptFormat;&lt;br /&gt;
	elseif utilities.is_set (TranscriptURL) then&lt;br /&gt;
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local Publisher;&lt;br /&gt;
	if utilities.is_set (PublicationDate) then&lt;br /&gt;
		PublicationDate = wrap_msg (&#039;published&#039;, PublicationDate);&lt;br /&gt;
	end&lt;br /&gt;
	if utilities.is_set (PublisherName) then&lt;br /&gt;
		if utilities.is_set (PublicationPlace) then&lt;br /&gt;
			Publisher = sepc .. &amp;quot; &amp;quot; .. PublicationPlace .. &amp;quot;: &amp;quot; .. PublisherName .. PublicationDate;&lt;br /&gt;
		else&lt;br /&gt;
			Publisher = sepc .. &amp;quot; &amp;quot; .. PublisherName .. PublicationDate;  &lt;br /&gt;
		end			&lt;br /&gt;
	elseif utilities.is_set (PublicationPlace) then &lt;br /&gt;
		Publisher= sepc .. &amp;quot; &amp;quot; .. PublicationPlace .. PublicationDate;&lt;br /&gt;
	else &lt;br /&gt;
		Publisher = PublicationDate;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local TransPeriodical =  A[&#039;TransPeriodical&#039;];&lt;br /&gt;
	local TransPeriodical_origin =  A:ORIGIN (&#039;TransPeriodical&#039;);&lt;br /&gt;
	-- Several of the above rely upon detecting this as nil, so do it last.&lt;br /&gt;
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then&lt;br /&gt;
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then &lt;br /&gt;
			Periodical = sepc .. &amp;quot; &amp;quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);&lt;br /&gt;
		else &lt;br /&gt;
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local Language = A[&#039;Language&#039;];&lt;br /&gt;
	if utilities.is_set (Language) then&lt;br /&gt;
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.&lt;br /&gt;
	else&lt;br /&gt;
		Language=&#039;&#039;;															-- language not specified so make sure this is an empty string;&lt;br /&gt;
	--[[ TODO: need to extract the wrap_msg from language_parameter&lt;br /&gt;
	so that we can solve parentheses bunching problem with Format/Language/TitleType&lt;br /&gt;
	]]&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	--[[&lt;br /&gt;
	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 &amp;quot; (Speech)&amp;quot; so that&lt;br /&gt;
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).&lt;br /&gt;
	]]&lt;br /&gt;
	if &amp;quot;speech&amp;quot; == config.CitationClass then									-- cite speech only&lt;br /&gt;
		TitleNote = &amp;quot; (Speech)&amp;quot;;												-- annotate the citation&lt;br /&gt;
		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter &lt;br /&gt;
			if utilities.is_set (Conference) then								-- and if |event= is set&lt;br /&gt;
				Conference = Conference .. sepc .. &amp;quot; &amp;quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Piece all bits together at last.  Here, all should be non-nil.&lt;br /&gt;
	-- We build things this way because it is more efficient in LUA&lt;br /&gt;
	-- not to keep reassigning to the same string variable over and over.&lt;br /&gt;
&lt;br /&gt;
	local tcommon;&lt;br /&gt;
	local tcommon2;																-- used for book cite when |contributor= is set&lt;br /&gt;
	&lt;br /&gt;
	if utilities.in_array (config.CitationClass, {&amp;quot;journal&amp;quot;, &amp;quot;citation&amp;quot;}) and utilities.is_set (Periodical) then&lt;br /&gt;
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &amp;quot; &amp;quot;}, sepc) end		-- add terminal punctuation &amp;amp; space; check for dup sepc; TODO why do we need to do this here?&lt;br /&gt;
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );&lt;br /&gt;
	elseif utilities.in_array (config.CitationClass, {&amp;quot;book&amp;quot;, &amp;quot;citation&amp;quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites&lt;br /&gt;
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.&lt;br /&gt;
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2&lt;br /&gt;
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );&lt;br /&gt;
		else&lt;br /&gt;
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
	elseif &#039;map&#039; == config.CitationClass then									-- special cases for cite map&lt;br /&gt;
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter&lt;br /&gt;
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );&lt;br /&gt;
		elseif utilities.is_set (Periodical) then								-- map in a periodical&lt;br /&gt;
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );&lt;br /&gt;
		else																	-- a sheet or stand-alone map&lt;br /&gt;
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
	elseif &#039;episode&#039; == config.CitationClass then								-- special case for cite episode&lt;br /&gt;
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );&lt;br /&gt;
&lt;br /&gt;
	else																		-- all other CS1 templates&lt;br /&gt;
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, &lt;br /&gt;
			Volume, Others, Edition, Publisher, Agency}, sepc );&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if #ID_list &amp;gt; 0 then&lt;br /&gt;
		ID_list = safe_join( { sepc .. &amp;quot; &amp;quot;,  table.concat( ID_list, sepc .. &amp;quot; &amp;quot; ), ID }, sepc );&lt;br /&gt;
	else&lt;br /&gt;
		ID_list = ID;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local Via = A[&#039;Via&#039;];&lt;br /&gt;
	Via = utilities.is_set (Via) and  wrap_msg (&#039;via&#039;, Via) or &#039;&#039;;&lt;br /&gt;
	local idcommon;&lt;br /&gt;
	if &#039;audio-visual&#039; == config.CitationClass or &#039;episode&#039; == config.CitationClass then	-- special case for cite AV media &amp;amp; cite episode position transcript&lt;br /&gt;
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );&lt;br /&gt;
	else&lt;br /&gt;
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local text;&lt;br /&gt;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;&lt;br /&gt;
&lt;br /&gt;
	local OrigDate = A[&#039;OrigDate&#039;];&lt;br /&gt;
	OrigDate = utilities.is_set (OrigDate) and wrap_msg (&#039;origdate&#039;, OrigDate) or &#039;&#039;;&lt;br /&gt;
	if utilities.is_set (Date) then&lt;br /&gt;
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set&lt;br /&gt;
			Date = &amp;quot; (&amp;quot; .. Date .. &amp;quot;)&amp;quot; .. OrigDate .. sepc .. &amp;quot; &amp;quot;;				-- in parentheses&lt;br /&gt;
		else																	-- neither of authors and editors set&lt;br /&gt;
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc&lt;br /&gt;
				Date = &amp;quot; &amp;quot; .. Date .. OrigDate;									-- Date does not begin with sepc&lt;br /&gt;
			else&lt;br /&gt;
				Date = sepc .. &amp;quot; &amp;quot; .. Date .. OrigDate;							-- Date begins with sepc&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end	&lt;br /&gt;
	if utilities.is_set (Authors) then&lt;br /&gt;
		if (not utilities.is_set (Date)) then									-- when date is set it&#039;s in parentheses; no Authors termination&lt;br /&gt;
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space&lt;br /&gt;
		end&lt;br /&gt;
		if utilities.is_set (Editors) then&lt;br /&gt;
			local in_text = &amp;quot; &amp;quot;;&lt;br /&gt;
			local post_text = &amp;quot;&amp;quot;;&lt;br /&gt;
			if utilities.is_set (Chapter) and 0 == #c then&lt;br /&gt;
				in_text = in_text .. cfg.messages[&#039;in&#039;] .. &amp;quot; &amp;quot;&lt;br /&gt;
				if (sepc ~= &#039;.&#039;) then&lt;br /&gt;
					in_text = in_text:lower()									-- lowercase for cs2&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if EditorCount &amp;lt;= 1 then&lt;br /&gt;
				post_text = &amp;quot; (&amp;quot; .. cfg.messages[&#039;editor&#039;] .. &amp;quot;)&amp;quot;;				-- be consistent with no-author, no-date case&lt;br /&gt;
			else&lt;br /&gt;
				post_text = &amp;quot; (&amp;quot; .. cfg.messages[&#039;editors&#039;] .. &amp;quot;)&amp;quot;;&lt;br /&gt;
			end&lt;br /&gt;
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space&lt;br /&gt;
		end&lt;br /&gt;
		if utilities.is_set (Contributors) then									-- book cite and we&#039;re citing the intro, preface, etc.&lt;br /&gt;
			local by_text = sepc .. &#039; &#039; .. cfg.messages[&#039;by&#039;] .. &#039; &#039;;&lt;br /&gt;
			if (sepc ~= &#039;.&#039;) then by_text = by_text:lower() end					-- lowercase for cs2&lt;br /&gt;
			Authors = by_text .. Authors;										-- author follows title so tweak it here&lt;br /&gt;
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated&lt;br /&gt;
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space&lt;br /&gt;
			end&lt;br /&gt;
			if (not utilities.is_set (Date)) then								-- when date is set it&#039;s in parentheses; no Contributors termination&lt;br /&gt;
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space&lt;br /&gt;
			end&lt;br /&gt;
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );&lt;br /&gt;
		else&lt;br /&gt;
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );&lt;br /&gt;
		end&lt;br /&gt;
	elseif utilities.is_set (Editors) then&lt;br /&gt;
		if utilities.is_set (Date) then&lt;br /&gt;
			if EditorCount &amp;lt;= 1 then&lt;br /&gt;
				Editors = Editors .. &amp;quot;, &amp;quot; .. cfg.messages[&#039;editor&#039;];&lt;br /&gt;
			else&lt;br /&gt;
				Editors = Editors .. &amp;quot;, &amp;quot; .. cfg.messages[&#039;editors&#039;];&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			if EditorCount &amp;lt;= 1 then&lt;br /&gt;
				Editors = Editors .. &amp;quot; (&amp;quot; .. cfg.messages[&#039;editor&#039;] .. &amp;quot;)&amp;quot; .. sepc .. &amp;quot; &amp;quot;&lt;br /&gt;
			else&lt;br /&gt;
				Editors = Editors .. &amp;quot; (&amp;quot; .. cfg.messages[&#039;editors&#039;] .. &amp;quot;)&amp;quot; .. sepc .. &amp;quot; &amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );&lt;br /&gt;
	else&lt;br /&gt;
		if utilities.in_array (config.CitationClass, {&amp;quot;journal&amp;quot;, &amp;quot;citation&amp;quot;}) and utilities.is_set (Periodical) then&lt;br /&gt;
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );&lt;br /&gt;
		else&lt;br /&gt;
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if utilities.is_set (PostScript) and PostScript ~= sepc then&lt;br /&gt;
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.&lt;br /&gt;
		text = text:sub(1, -sepc:len() - 1);&lt;br /&gt;
	end	&lt;br /&gt;
	&lt;br /&gt;
	text = safe_join( {text, PostScript}, sepc );&lt;br /&gt;
&lt;br /&gt;
	-- Now enclose the whole thing in a &amp;lt;cite&amp;gt; element&lt;br /&gt;
	local options = {};&lt;br /&gt;
	&lt;br /&gt;
	if utilities.is_set (config.CitationClass) and config.CitationClass ~= &amp;quot;citation&amp;quot; then&lt;br /&gt;
		options.class = string.format (&#039;%s %s %s&#039;, &#039;citation&#039;, config.CitationClass, utilities.is_set (Mode) and Mode or &#039;cs1&#039;);	-- class=citation required for blue highlight when used with |ref=&lt;br /&gt;
	else&lt;br /&gt;
		options.class = string.format (&#039;%s %s&#039;, &#039;citation&#039;, utilities.is_set (Mode) and Mode or &#039;cs2&#039;);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local Ref = A[&#039;Ref&#039;];&lt;br /&gt;
	if &#039;harv&#039; == Ref then														-- need to check this before setting to default&lt;br /&gt;
		utilities.set_message (&#039;maint_ref_harv&#039;);								-- add maint cat to identify templates that have this now-extraneous param value&lt;br /&gt;
	elseif not utilities.is_set (Ref) then&lt;br /&gt;
		Ref = &#039;harv&#039;;															-- set as default when not set externally&lt;br /&gt;
	end&lt;br /&gt;
	if &#039;none&#039; ~= cfg.keywords_xlate[Ref:lower()] then&lt;br /&gt;
		local id = Ref&lt;br /&gt;
		local namelist = {};													-- holds selected contributor, author, editor name list&lt;br /&gt;
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation&lt;br /&gt;
&lt;br /&gt;
		if #c &amp;gt; 0 then															-- if there is a contributor list&lt;br /&gt;
			namelist = c;														-- select it&lt;br /&gt;
		elseif #a &amp;gt; 0 then														-- or an author list&lt;br /&gt;
			namelist = a;&lt;br /&gt;
		elseif #e &amp;gt; 0 then														-- or an editor list&lt;br /&gt;
			namelist = e;&lt;br /&gt;
		end&lt;br /&gt;
		local citeref_id&lt;br /&gt;
		if #namelist &amp;gt; 0 then													-- if there are names in namelist&lt;br /&gt;
			citeref_id = make_citeref_id (namelist, year);						-- go make the CITEREF anchor&lt;br /&gt;
		else&lt;br /&gt;
			citeref_id = &#039;&#039;;													-- unset&lt;br /&gt;
		end&lt;br /&gt;
		if citeref_id == Ref then&lt;br /&gt;
			utilities.set_message (&#039;maint_ref_duplicates_default&#039;);&lt;br /&gt;
		end&lt;br /&gt;
		if &#039;harv&#039; == Ref then&lt;br /&gt;
			id = citeref_id&lt;br /&gt;
		end&lt;br /&gt;
		options.id = id;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if string.len(text:gsub(&amp;quot;&amp;lt;span[^&amp;gt;/]*&amp;gt;(.-)&amp;lt;/span&amp;gt;&amp;quot;, &amp;quot;%1&amp;quot;):gsub(&amp;quot;%b&amp;lt;&amp;gt;&amp;quot;, &amp;quot;&amp;quot;)) &amp;lt;= 2 then	-- remove &amp;lt;span&amp;gt; tags and other HTML-like markup; then get length of what remains&lt;br /&gt;
		z.error_categories = {};&lt;br /&gt;
		text = utilities.set_message (&#039;err_empty_citation&#039;);&lt;br /&gt;
		z.message_tail = {};&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation&lt;br /&gt;
&lt;br /&gt;
	if utilities.is_set (options.id) then										-- here we wrap the rendered citation in &amp;lt;cite ...&amp;gt;...&amp;lt;/cite&amp;gt; tags&lt;br /&gt;
		table.insert (render, utilities.substitute (cfg.presentation[&#039;cite-id&#039;], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set&lt;br /&gt;
	else&lt;br /&gt;
		table.insert (render, utilities.substitute (cfg.presentation[&#039;cite&#039;], {mw.text.nowiki(options.class), text}));	-- all other cases&lt;br /&gt;
	end		&lt;br /&gt;
&lt;br /&gt;
	table.insert (render, utilities.substitute (cfg.presentation[&#039;ocins&#039;], {OCinSoutput}));	-- append metadata to the citation&lt;br /&gt;
&lt;br /&gt;
	if 0 ~= #z.message_tail then&lt;br /&gt;
		table.insert (render, &#039; &#039;);&lt;br /&gt;
		for i,v in ipairs( z.message_tail ) do&lt;br /&gt;
			if utilities.is_set (v[1]) then&lt;br /&gt;
				if i == #z.message_tail then&lt;br /&gt;
					table.insert (render, utilities.error_comment ( v[1], v[2] ));&lt;br /&gt;
				else&lt;br /&gt;
					table.insert (render, utilities.error_comment ( v[1] .. &amp;quot;; &amp;quot;, v[2] ));&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if 0 ~= #z.maintenance_cats then&lt;br /&gt;
		local maint_msgs = {};													-- here we collect all of the maint messages&lt;br /&gt;
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories&lt;br /&gt;
			local maint = {};													-- here we assemble a maintenence message&lt;br /&gt;
			table.insert (maint, v);											-- maint msg is the category name&lt;br /&gt;
			table.insert (maint, &#039; (&#039;);											-- open the link text&lt;br /&gt;
			table.insert (maint, utilities.substitute (cfg.messages[&#039;:cat wikilink&#039;], {v}));	-- add the link&lt;br /&gt;
			table.insert (maint, &#039;)&#039;);											-- and close it&lt;br /&gt;
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table&lt;br /&gt;
		end&lt;br /&gt;
		table.insert (render, utilities.substitute (cfg.presentation[&#039;hidden-maint&#039;], table.concat (maint_msgs, &#039; &#039;)));	-- wrap the group of maint message with proper presentation and save&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if not no_tracking_cats then&lt;br /&gt;
		for _, v in ipairs( z.error_categories ) do								-- append error categories&lt;br /&gt;
			table.insert (render, utilities.substitute (cfg.messages[&#039;cat wikilink&#039;], {v}));&lt;br /&gt;
		end&lt;br /&gt;
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories&lt;br /&gt;
			table.insert (render, utilities.substitute (cfg.messages[&#039;cat wikilink&#039;], {v}));&lt;br /&gt;
		end&lt;br /&gt;
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories&lt;br /&gt;
			table.insert (render, utilities.substitute (cfg.messages[&#039;cat wikilink&#039;], {v}));&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return table.concat (render);	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; V A L I D A T E &amp;gt;--------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Looks for a parameter&#039;s name in one of several whitelists.&lt;br /&gt;
&lt;br /&gt;
Parameters in the whitelist can have three values:&lt;br /&gt;
	true - active, supported parameters&lt;br /&gt;
	false - deprecated, supported parameters&lt;br /&gt;
	nil - unsupported parameters&lt;br /&gt;
	&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function validate (name, cite_class, empty)&lt;br /&gt;
	local name = tostring (name);&lt;br /&gt;
	local enum_name;															-- for enumerated parameters, is name with enumerator replaced with &#039;#&#039;&lt;br /&gt;
	local state;&lt;br /&gt;
	local function state_test (state, name)										-- local function to do testing of state values&lt;br /&gt;
		if true == state then return true; end									-- valid actively supported parameter&lt;br /&gt;
		if false == state then&lt;br /&gt;
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns&lt;br /&gt;
			deprecated_parameter (name);										-- parameter is deprecated but still supported&lt;br /&gt;
			return true;&lt;br /&gt;
		end&lt;br /&gt;
		if &#039;discouraged&#039; == state then&lt;br /&gt;
			discouraged_parameter (name);										-- parameter is discouraged but still supported&lt;br /&gt;
			return true;&lt;br /&gt;
		end&lt;br /&gt;
		return nil;&lt;br /&gt;
	end		&lt;br /&gt;
&lt;br /&gt;
	if name:find (&#039;#&#039;) then														-- # is a cs1|2 reserved character so parameters with # not permitted&lt;br /&gt;
		return nil;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates&lt;br /&gt;
		state = whitelist.limited_basic_arguments[name];&lt;br /&gt;
		if true == state_test (state, name) then return true; end&lt;br /&gt;
&lt;br /&gt;
		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class&lt;br /&gt;
		if true == state_test (state, name) then return true; end&lt;br /&gt;
&lt;br /&gt;
																				-- limited enumerated parameters list&lt;br /&gt;
		enum_name = name:gsub(&amp;quot;%d+&amp;quot;, &amp;quot;#&amp;quot; );										-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western &#039;local&#039; digits)&lt;br /&gt;
		state = whitelist.limited_numbered_arguments[enum_name];&lt;br /&gt;
		if true == state_test (state, name) then return true; end&lt;br /&gt;
&lt;br /&gt;
		return false;															-- not supported because not found or name is set to nil&lt;br /&gt;
	end																			-- end limited parameter-set templates&lt;br /&gt;
&lt;br /&gt;
	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&lt;br /&gt;
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class&lt;br /&gt;
		if true == state_test (state, name) then return true; end&lt;br /&gt;
	end																			-- if here, fall into general validation&lt;br /&gt;
		&lt;br /&gt;
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed&lt;br /&gt;
	if true == state_test (state, name) then return true; end&lt;br /&gt;
&lt;br /&gt;
																				-- all enumerated parameters allowed&lt;br /&gt;
	enum_name = name:gsub(&amp;quot;%d+&amp;quot;, &amp;quot;#&amp;quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western &#039;local&#039; digits)&lt;br /&gt;
	state = whitelist.numbered_arguments[enum_name];&lt;br /&gt;
	if true == state_test (state, name) then return true; end&lt;br /&gt;
&lt;br /&gt;
	return false;																-- not supported because not found or name is set to nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[=[-------------------------&amp;lt; I N T E R _ W I K I _ C H E C K &amp;gt;----------------------------------------------&lt;br /&gt;
&lt;br /&gt;
check &amp;lt;value&amp;gt; for inter-language interwiki-link markup.  &amp;lt;prefix&amp;gt; must be a MediaWiki-recognized language&lt;br /&gt;
code.  when these values have the form (without leading colon):&lt;br /&gt;
	[[&amp;lt;prefix&amp;gt;:link|label]] return label as plain-text&lt;br /&gt;
	[[&amp;lt;prefix&amp;gt;:link]] return &amp;lt;prefix&amp;gt;:link as plain-text&lt;br /&gt;
&lt;br /&gt;
return value as is else&lt;br /&gt;
&lt;br /&gt;
]=]&lt;br /&gt;
&lt;br /&gt;
local function inter_wiki_check (parameter, value)&lt;br /&gt;
	local prefix = value:match (&#039;%[%[(%a+):&#039;);									-- get an interwiki prefix if one exists&lt;br /&gt;
	local _;&lt;br /&gt;
	&lt;br /&gt;
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so&lt;br /&gt;
		table.insert( z.message_tail, {utilities.set_message (&#039;err_bad_paramlink&#039;, parameter)});	-- emit an error message&lt;br /&gt;
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink&lt;br /&gt;
	end&lt;br /&gt;
	return value;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; M I S S I N G _ P I P E _ C H E C K &amp;gt;------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal&lt;br /&gt;
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a&lt;br /&gt;
parameter that is missing its pipe.  There are two tests made:&lt;br /&gt;
	{{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&lt;br /&gt;
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)&lt;br /&gt;
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML&lt;br /&gt;
tags are removed before the search.&lt;br /&gt;
&lt;br /&gt;
If a missing pipe is detected, this function adds the missing pipe maintenance category.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function missing_pipe_check (parameter, value)&lt;br /&gt;
	local capture;&lt;br /&gt;
	value = value:gsub (&#039;%b&amp;lt;&amp;gt;&#039;, &#039;&#039;);											-- remove XML/HTML tags because attributes: class=, title=, etc.&lt;br /&gt;
&lt;br /&gt;
	capture = value:match (&#039;%s+(%a[%w%-]+)%s*=&#039;) or value:match (&#039;^(%a[%w%-]+)%s*=&#039;);	-- find and categorize parameters with possible missing pipes&lt;br /&gt;
	if capture and validate (capture) then										-- if the capture is a valid parameter name&lt;br /&gt;
		table.insert( z.message_tail, {utilities.set_message (&#039;err_missing_pipe&#039;, parameter)});&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; H A S _ E X T R A N E O U S _ P U N C T &amp;gt;--------------------------------------&lt;br /&gt;
&lt;br /&gt;
look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function has_extraneous_punc (param, value)&lt;br /&gt;
	if &#039;number&#039; == type (param) then&lt;br /&gt;
		return;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	param = param:gsub (&#039;%d+&#039;, &#039;#&#039;);											-- enumerated name-list mask params allow terminal punct; normalize &lt;br /&gt;
	if cfg.punct_skip[param] then&lt;br /&gt;
		return;																	-- parameter name found in the skip table so done&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if value:match (&#039;[,;:]$&#039;) then&lt;br /&gt;
		utilities.set_message (&#039;maint_extra_punct&#039;);							-- has extraneous punctuation; add maint cat&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; C I T A T I O N &amp;gt;--------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
This is used by templates such as {{cite book}} to create the actual citation text.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function citation(frame)&lt;br /&gt;
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode&lt;br /&gt;
	local pframe = frame:getParent()&lt;br /&gt;
	local styles;&lt;br /&gt;
	&lt;br /&gt;
	if nil ~= string.find (frame:getTitle(), &#039;sandbox&#039;, 1, true) then			-- did the {{#invoke:}} use sandbox version?&lt;br /&gt;
		cfg = mw.loadData (&#039;Module:Citation/CS1/Configuration/sandbox&#039;);		-- load sandbox versions of support modules&lt;br /&gt;
		whitelist = mw.loadData (&#039;Module:Citation/CS1/Whitelist/sandbox&#039;);&lt;br /&gt;
		utilities = require (&#039;Module:Citation/CS1/Utilities/sandbox&#039;);&lt;br /&gt;
		validation = require (&#039;Module:Citation/CS1/Date_validation/sandbox&#039;);&lt;br /&gt;
		identifiers = require (&#039;Module:Citation/CS1/Identifiers/sandbox&#039;);&lt;br /&gt;
		metadata = require (&#039;Module:Citation/CS1/COinS/sandbox&#039;);&lt;br /&gt;
		styles = &#039;Module:Citation/CS1/sandbox/styles.css&#039;;&lt;br /&gt;
		&lt;br /&gt;
	else																		-- otherwise&lt;br /&gt;
		cfg = mw.loadData (&#039;Module:Citation/CS1/Configuration&#039;);				-- load live versions of support modules&lt;br /&gt;
		whitelist = mw.loadData (&#039;Module:Citation/CS1/Whitelist&#039;);&lt;br /&gt;
		utilities = require (&#039;Module:Citation/CS1/Utilities&#039;);&lt;br /&gt;
		validation = require (&#039;Module:Citation/CS1/Date_validation&#039;);&lt;br /&gt;
		identifiers = require (&#039;Module:Citation/CS1/Identifiers&#039;);&lt;br /&gt;
		metadata = require (&#039;Module:Citation/CS1/COinS&#039;);&lt;br /&gt;
		styles = &#039;Module:Citation/CS1/styles.css&#039;;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables&lt;br /&gt;
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module&lt;br /&gt;
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module&lt;br /&gt;
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module&lt;br /&gt;
&lt;br /&gt;
	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities&lt;br /&gt;
&lt;br /&gt;
	local args = {};															-- table where we store all of the template&#039;s arguments&lt;br /&gt;
	local suggestions = {};														-- table where we store suggestions if we need to loadData them&lt;br /&gt;
	local error_text, error_state;&lt;br /&gt;
&lt;br /&gt;
	local config = {};															-- table to store parameters from the module {{#invoke:}}&lt;br /&gt;
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame&lt;br /&gt;
		config[k] = v;&lt;br /&gt;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?&lt;br /&gt;
	end	&lt;br /&gt;
&lt;br /&gt;
	local capture;																-- the single supported capture when matching unknown parameters using patterns&lt;br /&gt;
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing&lt;br /&gt;
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame&lt;br /&gt;
		v = mw.ustring.gsub (v, &#039;^%s*(.-)%s*$&#039;, &#039;%1&#039;);							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string&lt;br /&gt;
		if v ~= &#039;&#039; then&lt;br /&gt;
			if (&#039;string&#039; == type (k)) then&lt;br /&gt;
				k = mw.ustring.gsub (k, &#039;%d&#039;, cfg.date_names.local_digits);		-- for enumerated parameters, translate &#039;local&#039; digits to Western 0-9&lt;br /&gt;
			end&lt;br /&gt;
			if not validate( k, config.CitationClass ) then			&lt;br /&gt;
				error_text = &amp;quot;&amp;quot;;&lt;br /&gt;
				if type( k ) ~= &#039;string&#039; then&lt;br /&gt;
					-- exclude empty numbered parameters&lt;br /&gt;
					if v:match(&amp;quot;%S+&amp;quot;) ~= nil then&lt;br /&gt;
						error_text, error_state = utilities.set_message ( &#039;err_text_ignored&#039;, {v}, true );&lt;br /&gt;
					end&lt;br /&gt;
				elseif validate( k:lower(), config.CitationClass ) then &lt;br /&gt;
					error_text, error_state = utilities.set_message ( &#039;err_parameter_ignored_suggest&#039;, {k, k:lower()}, true );	-- suggest the lowercase version of the parameter&lt;br /&gt;
				else&lt;br /&gt;
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it&lt;br /&gt;
						if nil ~= string.find (frame:getTitle(), &#039;sandbox&#039;, 1, true) then			-- did the {{#invoke:}} use sandbox version?&lt;br /&gt;
							suggestions = mw.loadData( &#039;Module:Citation/CS1/Suggestions/sandbox&#039; );	-- use the sandbox version&lt;br /&gt;
						else&lt;br /&gt;
							suggestions = mw.loadData( &#039;Module:Citation/CS1/Suggestions&#039; );			-- use the live version&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter&lt;br /&gt;
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match&lt;br /&gt;
						if capture then											-- if the pattern matches &lt;br /&gt;
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)&lt;br /&gt;
							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)&lt;br /&gt;
								error_text, error_state = utilities.set_message (&#039;err_parameter_ignored_suggest&#039;, {k, param}, true);	-- set the suggestion error message&lt;br /&gt;
							else&lt;br /&gt;
								error_text, error_state = utilities.set_message ( &#039;err_parameter_ignored&#039;, {k}, true );	-- suggested param not supported by this template&lt;br /&gt;
								v = &#039;&#039;;											-- unset&lt;br /&gt;
							end&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
					if not utilities.is_set (error_text) then					-- couldn&#039;t match with a pattern, is there an explicit suggestion?						&lt;br /&gt;
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then&lt;br /&gt;
							error_text, error_state = utilities.set_message ( &#039;err_parameter_ignored_suggest&#039;, {k, suggestions.suggestions[ k:lower() ]}, true );&lt;br /&gt;
						else&lt;br /&gt;
							error_text, error_state = utilities.set_message ( &#039;err_parameter_ignored&#039;, {k}, true );&lt;br /&gt;
							v = &#039;&#039;;												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				end				  &lt;br /&gt;
				if error_text ~= &#039;&#039; then&lt;br /&gt;
					table.insert( z.message_tail, {error_text, error_state} );&lt;br /&gt;
				end				&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			args[k] = v;														-- save this parameter and its value&lt;br /&gt;
&lt;br /&gt;
		elseif not utilities.is_set (v) then									-- for empty parameters&lt;br /&gt;
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter&lt;br /&gt;
				k = (&#039;&#039; == k) and &#039;(empty string)&#039; or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text&lt;br /&gt;
				table.insert (empty_unknowns, utilities.wrap_style (&#039;parameter&#039;, k));	-- format for error message and add to the list&lt;br /&gt;
			end&lt;br /&gt;
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?&lt;br /&gt;
	--	elseif args[k] ~= nil or (k == &#039;postscript&#039;) then						-- when args[k] has a value from {{#invoke}} frame (we don&#039;t normally do that)&lt;br /&gt;
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here&lt;br /&gt;
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?&lt;br /&gt;
	end	&lt;br /&gt;
&lt;br /&gt;
	if 0 ~= #empty_unknowns then												-- create empty unknown error message&lt;br /&gt;
		table.insert (z.message_tail, {utilities.set_message (&#039;err_param_unknown_empty&#039;, {&lt;br /&gt;
			1 == #empty_unknowns and &#039;&#039; or &#039;s&#039;,&lt;br /&gt;
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)&lt;br /&gt;
			}, true )});&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for k, v in pairs( args ) do&lt;br /&gt;
		if &#039;string&#039; == type (k) then											-- don&#039;t evaluate positional parameters&lt;br /&gt;
			has_invisible_chars (k, v);											-- look for invisible characters&lt;br /&gt;
		end&lt;br /&gt;
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values&lt;br /&gt;
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?&lt;br /&gt;
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return table.concat ({&lt;br /&gt;
		frame:extensionTag (&#039;templatestyles&#039;, &#039;&#039;, {src=styles}),&lt;br /&gt;
		citation0( config, args)&lt;br /&gt;
	});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E X P O R T E D   F U N C T I O N S &amp;gt;------------------------------------------&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
return {citation = citation};&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=585</id>
		<title>SREC (file format)</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=585"/>
		<updated>2021-04-26T10:36:21Z</updated>

		<summary type="html">&lt;p&gt;Darren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Motorola S-record&#039;&#039;&#039; is a file format, created by [[Motorola]], that conveys binary information as [[hexadecimal|hex]] values in [[ASCII]] text form. This file format may also be known as &#039;&#039;&#039;SRECORD&#039;&#039;&#039;, &#039;&#039;&#039;SREC&#039;&#039;&#039;, &#039;&#039;&#039;S19&#039;&#039;&#039;, &#039;&#039;&#039;S28&#039;&#039;&#039;, &#039;&#039;&#039;S37&#039;&#039;&#039;. It is commonly used for programming [[flash memory]] in microcontrollers, [[EPROM]]s, [[EEPROM]]s, and other types of programmable logic devices. In a typical application, a compiler or assembler converts a program&#039;s source code (such as C or assembly language) to machine code and outputs it into a HEX file. The HEX file is then imported by a programmer to &amp;quot;burn&amp;quot; the machine code into [[non-volatile memory]], or is transferred to the target system for loading and execution.&lt;br /&gt;
[[File:Motorola SREC Chart.png|thumb|A quick reference chart for the Motorola SREC format. (Note that in the record example image the word &amp;quot;bytes&amp;quot; is alternatively used to specify characters.)&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename extension&lt;br /&gt;
|&amp;lt;code&amp;gt;.s19&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s28&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s37&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.sx&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.srec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.exo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mxt&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Developed by&lt;br /&gt;
|Motorola&lt;br /&gt;
|}&lt;br /&gt;
]]&lt;br /&gt;
==Overview==&lt;br /&gt;
===History===&lt;br /&gt;
The S-record format was created in the mid-1970s for the [[Motorola 6800]] processor. [[Programming tool|Software development tools]] for that and other [[embedded processor]]s would make executable code and data in the S-record format. PROM programmers would then read the S-record format and &amp;quot;burn&amp;quot; the data into the PROMs or EPROMs used in the embedded system.&lt;br /&gt;
===Other hex formats===&lt;br /&gt;
There are other ASCII encoding with a similar purpose. [[BPNF]], [[BHLF]], and [[B10F]] were early binary formats, but they are neither compact nor flexible. Hexadecimal formats are more compact because they represent 4 bits rather than 1 bit per character. Many, such as S-record, are more flexible because they include address information so they can specify just a portion of a PROM. [[Intel HEX]] format was often used with Intel processors. [[TekHex]] is another hex format that can include a symbol table for debugging.&lt;br /&gt;
==Format==&lt;br /&gt;
===Record structure===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | S || style=&#039;background: #FFCCCC&#039; | Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
An SREC format file consists of a series of ASCII text records. The records have the following structure from left to right:&lt;br /&gt;
# &#039;&#039;Record start&#039;&#039; - each record begins with an uppercase letter &amp;quot;S&amp;quot; character (ASCII 0x53) which stands for &amp;quot;Start-of-Record&amp;quot;.&amp;lt;ref&amp;gt;{{cite book |title=MCM6830L7 MIKBUG / MINIBUG ROM |author-first1=Mike |author-last1=Wiles |author-first2=Andre |author-last2=Felix |editor-first=Michael |editor-last=Holley |date=2000-10-21 |orig-year=1975 |type=Engineering note |id=Note 100 |publisher=[[Motorola Semiconductor Products, Inc.]] |url=http://www.swtpc.com/mholley/MP_A/MikbugEn100.pdf |access-date=2019-06-16 |url-status=dead |archive-url=https://web.archive.org/web/20190616115550/http://www.swtpc.com/mholley/MP_A/MikbugEn100.pdf |archive-date=2019-06-16}} (23 pages)&amp;lt;/ref&amp;gt;&lt;br /&gt;
# &#039;&#039;Record type&#039;&#039; - single numeric digit &amp;quot;0&amp;quot; to &amp;quot;9&amp;quot;, defining the type of record.&lt;br /&gt;
# &#039;&#039;Byte count&#039;&#039; - two hex digits, indicating the number of bytes (hex digit pairs) that follow in the rest of the record (address + data + checksum). This field has a minimum value of 3 for 16-bit address field plus 1 checksum byte, and a maximum value of 255 (0xFF).&lt;br /&gt;
# &#039;&#039;Address&#039;&#039; - four / six / eight hex digits as determined by the record type. The address bytes are arranged in [[Endianness|big endian]] format.&lt;br /&gt;
# &#039;&#039;Data&#039;&#039; - a sequence of 2&#039;&#039;n&#039;&#039; hex digits, for &#039;&#039;n&#039;&#039; bytes of the data. For S1/S2/S3 records, a maximum of 32 bytes per record is typical since it will fit on an 80 character wide terminal screen, though 16 bytes would be easier to visually decode each byte at a specific address.&lt;br /&gt;
# &#039;&#039;Checksum&#039;&#039; - two hex digits, the [[least significant byte]] of [[ones&#039; complement]] of the sum of the values represented by the two hex digit pairs for the byte count, address and data fields. See example section for a detailed checksum example.&lt;br /&gt;
===Text line terminators===&lt;br /&gt;
SREC records are separated by one or more ASCII line termination characters so that each record appears alone on a text line. This enhances legibility by visually [[delimiter|delimiting]] the records and it also provides padding between records that can be used to improve machine [[parsing]] efficiency.&lt;br /&gt;
&lt;br /&gt;
Programs that create HEX records typically use line termination characters that conform to the conventions of their [[operating system]]s. For example, Linux programs use a single LF character ([[Newline|line feed]], 0x0A as ASCII character value) character to terminate lines, whereas Windows programs use a CR character ([[carriage return]], 0x0D as ASCII character value) followed by a LF character.&lt;br /&gt;
===Record types===&lt;br /&gt;
The following table describes 10 possible S-records. S4 is reserved and not currently defined. S6 was originally reserved but was later redefined.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Record&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;purpose&lt;br /&gt;
! Address&amp;lt;br&amp;gt;field&lt;br /&gt;
! Data&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;description&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S0&#039;&#039;&lt;br /&gt;
| Header&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;&amp;quot;0000&amp;quot;&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains vendor specific ASCII text comment represented as a series of hex digit pairs. It is common to see the data for this record in the format of a [[null-terminated string]]. The text data can be anything including a mixture of the following information: file/module name, version/revision number, date/time, product name, vendor name, memory designator on PCB, copyright notice. It is common to see: 48 44 52 which is the ASCII H, D, and R - &amp;quot;HDR&amp;quot;.&amp;lt;ref name=&amp;quot;Tareski_2018&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S1&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at the 16-bit address field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is typically used for 8-bit microcontrollers, such as AVR, PIC, 8051, 68xx, 6502, 80xx, Z80. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 3 (that is, 2 bytes for &amp;quot;16-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S2&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 24-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 4 (that is, 3 bytes for &amp;quot;24-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S3&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 32-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is typically used for 32-bit microcontrollers, such as ARM and 680x0. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 5 (that is, 4 bytes for &amp;quot;32-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S4&#039;&#039;&lt;br /&gt;
| Reserved&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| This record is reserved.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S5&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 16-bit count of S1/S2/S3 records.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is used if the record count is less than or equal to 65,535 (0xFFFF), otherwise S6 record would be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S6&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 24-bit count of S1/S2/S3 records. This record is used if the record count is less than or equal to 16,777,215 (0xFFFFFF). If less than 65,536 (0x10000), then S5 record would be used. &#039;&#039;&#039;NOTE:&#039;&#039;&#039; This newer record is the most recent change (it may not be official).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S7&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 32-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S3 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S8&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 24-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S2 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S9&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 16-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S1 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|}&lt;br /&gt;
===Record order===&lt;br /&gt;
Although some Unix documentation states &amp;quot;the order of S-records within a file is of no significance and no particular order may be assumed&amp;quot;,&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; in practice most software has ordered the SREC records. The typical record order starts with a (sometimes optional) S0 header record, continues with a sequence of one or more S1/S2/S3 data records, may have one optional S5/S6 count record, and ends with one appropriate S7/S8/S9 termination record.&lt;br /&gt;
; S19-style 16-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S1 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S9&lt;br /&gt;
; S28-style 24-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S2 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S8&lt;br /&gt;
; S37-style 32-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S3 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S7&lt;br /&gt;
===Limitations===&lt;br /&gt;
&#039;&#039;Record length&#039;&#039; - Unix manual page documentation states, &amp;quot;An S-record file consists of a sequence of specially formatted ASCII character strings. An S-record will be less than or equal to 78 bytes in length&amp;quot;. The manual page further limits the number of characters in the data field to 64 (or 32 data bytes).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; A record with an 8-hex-character address and 64 data characters would be 78 (2 + 2 + 8 + 64 + 2) characters long (this count ignores possible end-of-line or string termination characters). The file could be printed on an 80-character wide teleprinter. A note at the bottom of the manual page states, &amp;quot;This [manual page] is the only place that a 78-byte limit on total record length or 64-byte limit on data length is documented. These values shouldn&#039;t be trusted for the general case&amp;quot;.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; If that limitation is ignored, the maximum length of an S-record is 514 characters: 2 for Record Type field + 2 for Byte Count field (whose value would be 0xFF=255) + 2 * 255 for Address, Data, and Checksum fields. Additional buffer space may be required for the line and string terminators. Using long line lengths has problems: &amp;quot;The Motorola S-record format definition permits up to 255 bytes of payload, or lines of 514 characters, plus the line termination. All EPROM programmers should have sufficiently large line buffers to cope with records this big. Few do.&amp;quot;&amp;lt;ref name=&amp;quot;sf&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Data field&#039;&#039; - Some documentation recommends a maximum of 32 bytes of data (64 hex characters) in this field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The minimum amount of data for S0/S1/S2/S3 records is zero. The maximum amount of data varies depending on the size of the address field. Since the Byte Count field can&#039;t be higher than 255 (0xFF), then the maximum number of bytes of data is calculated by 255 minus (1 byte for checksum field) minus (number of bytes in the address field). S0/S1 records support up to 252 bytes of data. S2 record supports up to 251 bytes of data. S3 record supports up to 250 bytes of data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Comments&#039;&#039; - The SREC file format does not support comments. Some software ignores all text lines that do not start with &amp;quot;S&amp;quot; and ignores all text after the checksum field; that extra text is sometimes used (incompatibly) for comments. For example, the CCS PIC compiler supports placing a &amp;quot;;&amp;quot; comment line at the top or bottom of an [[Intel HEX]] file, and its manuals states &amp;quot;some programmers (MPLAB in particular) do not like comments at the top of the hex file&amp;quot;, which is why the compiler has the option of placing the comment at the bottom of the hex file.&amp;lt;ref name=&amp;quot;CCS_2014&amp;quot;/&amp;gt;&lt;br /&gt;
==Examples==&lt;br /&gt;
; Color legend&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | Record Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Checksum calculation===&lt;br /&gt;
The following example record:&lt;br /&gt;
 {{SREC HEX|1|13|7AF0|0A0A0D00000000000000000000000000|61}}&lt;br /&gt;
is decoded to show how the checksum value is calculated as follows:&lt;br /&gt;
# Add: Add each byte 0x13 + 0x7A + 0xF0 + 0x0A + 0x0A + 0x0D + 0x00 + ... + 0x00 = 0x19E total.&lt;br /&gt;
# Mask: Keep the least significant byte of the total = 0x9E.&lt;br /&gt;
# Complement: Compute [[ones&#039; complement]] of least significant byte = 0x61.&lt;br /&gt;
===16-bit memory address===&lt;br /&gt;
 {{SREC HEX|0|0F|0000|68656C6C6F20202020200000|3C}}&lt;br /&gt;
 {{SREC HEX|1|1F|0000|7C0802A6900100049421FFF07C6C1B787C8C23783C60000038630000|26}}&lt;br /&gt;
 {{SREC HEX|1|1F|001C|4BFFFFE5398000007D83637880010014382100107C0803A64E800020|E9}}&lt;br /&gt;
 {{SREC HEX|1|11|0038|48656C6C6F20776F726C642E0A00|42}}&lt;br /&gt;
 {{SREC HEX|5|03|0003||F9}}&lt;br /&gt;
 {{SREC HEX|9|03|0000||FC}}&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Binary-to-text encoding]], a survey and comparison of encoding algorithms&lt;br /&gt;
* [[Intel hex format]]&lt;br /&gt;
* [[MOS Technology file format]]&lt;br /&gt;
* [[Tektronix hex format]]&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist|refs=&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Tareski_2018&amp;quot;&amp;gt;{{Cite web |title=Motorola S-record description |author-last=Tareski |author-first=Val |website=www.amelek.gda.pl |url=http://www.amelek.gda.pl/avr/uisp/srecord.htm |access-date=2018-06-26}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;&amp;gt;{{cite web |title=Motorola S-records from Unix man pages |url=http://www.amelek.gda.pl/avr/uisp/srecord.htm |access-date=2014-06-30}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;&amp;gt;{{cite book |title=M68000 Family Programmer&#039;s Reference Manual |version=Revision 1 |publisher=[[Motorola]] ([[Freescale]]) |date=1992 |pages=C-1–C-5 |chapter=Appendix C |isbn=978-0-13723289-5 |url=http://www.freescale.com/files/archives/doc/ref_manual/M68000PRM.pdf}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;sf&amp;quot;&amp;gt;{{cite web |title=srec_examples |work=sourceforge.net |url=http://srecord.sourceforge.net/man/man1/srec_examples.html}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;CCS_2014&amp;quot;&amp;gt;{{citation |title=CCS Compiler Reference Manual PCB/PCM/PCH |publisher=[[Custom Computer Services, Inc.]] |date=May 2014 |page=107 |url=http://www.ccsinfo.com/downloads/ccs_c_manual.pdf |access-date=2015-02-08}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Xilinx_2010_EXO&amp;quot;&amp;gt;{{cite web |title=AR#476 PROMGen - Description of PROM/EEPROM file formats: MCS, EXO, HEX, and others |at=Motorola EXORmacs - File Format Code 87 |date=2010-03-08 |publisher=[[Xilinx]] |url=https://www.xilinx.com/support/answers/476.html |access-date=2020-03-03 |url-status=live |archive-url=https://web.archive.org/web/20200303085851/https://www.xilinx.com/support/answers/476.html |archive-date=2020-03-03}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://srecord.sourceforge.net/ SRecord] is a collection of tools for manipulating SREC format files.&lt;br /&gt;
* [http://www.keil.com/download/docs/4.asp BIN2MOT], BINARY to Motorola S-Record file converter utility.&lt;br /&gt;
* [https://github.com/BigWinston/SRecordizer/wiki SRecordizer] is a tool for viewing, editing, and error checking S19 format files.&lt;br /&gt;
* [https://pypi.python.org/pypi/bincopy bincopy] is a Python package for manipulating SREC format files.&lt;br /&gt;
* [https://github.com/arkku/srec kk_srec] is a C library and program for reading the SREC format.&lt;br /&gt;
{{DEFAULTSORT:Srec (File Format)}}&lt;br /&gt;
[[Category:Binary-to-text encoding formats]]&lt;br /&gt;
[[Category:Embedded systems]]&lt;br /&gt;
[[Category:Computer file formats]]&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=584</id>
		<title>SREC (file format)</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=584"/>
		<updated>2021-04-23T17:01:40Z</updated>

		<summary type="html">&lt;p&gt;Darren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Motorola S-record&#039;&#039;&#039; is a file format, created by [[Motorola]], that conveys binary information as [[hexadecimal|hex]] values in [[ASCII]] text form. This file format may also be known as &#039;&#039;&#039;SRECORD&#039;&#039;&#039;, &#039;&#039;&#039;SREC&#039;&#039;&#039;, &#039;&#039;&#039;S19&#039;&#039;&#039;, &#039;&#039;&#039;S28&#039;&#039;&#039;, &#039;&#039;&#039;S37&#039;&#039;&#039;. It is commonly used for programming [[flash memory]] in microcontrollers, [[EPROM]]s, [[EEPROM]]s, and other types of programmable logic devices. In a typical application, a compiler or assembler converts a program&#039;s source code (such as C or assembly language) to machine code and outputs it into a HEX file. The HEX file is then imported by a programmer to &amp;quot;burn&amp;quot; the machine code into [[non-volatile memory]], or is transferred to the target system for loading and execution.&lt;br /&gt;
[[File:Motorola SREC Chart.png|thumb|A quick reference chart for the Motorola SREC format. (Note that in the record example image the word &amp;quot;bytes&amp;quot; is alternatively used to specify characters.)&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename extension&lt;br /&gt;
|&amp;lt;code&amp;gt;.s19&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s28&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s37&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.sx&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.srec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.exo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mxt&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Developed by&lt;br /&gt;
|Motorola&lt;br /&gt;
|}&lt;br /&gt;
]]&lt;br /&gt;
==Overview==&lt;br /&gt;
===History===&lt;br /&gt;
The S-record format was created in the mid-1970s for the [[Motorola 6800]] processor. [[Programming tool|Software development tools]] for that and other [[embedded processor]]s would make executable code and data in the S-record format. PROM programmers would then read the S-record format and &amp;quot;burn&amp;quot; the data into the PROMs or EPROMs used in the embedded system.&lt;br /&gt;
===Other hex formats===&lt;br /&gt;
There are other ASCII encoding with a similar purpose. [[BPNF]], [[BHLF]], and [[B10F]] were early binary formats, but they are neither compact nor flexible. Hexadecimal formats are more compact because they represent 4 bits rather than 1 bit per character. Many, such as S-record, are more flexible because they include address information so they can specify just a portion of a PROM. [[Intel HEX]] format was often used with Intel processors. [[TekHex]] is another hex format that can include a symbol table for debugging.&lt;br /&gt;
==Format==&lt;br /&gt;
===Record structure===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | S || style=&#039;background: #FFCCCC&#039; | Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
An SREC format file consists of a series of ASCII text records. The records have the following structure from left to right:&lt;br /&gt;
# &#039;&#039;Record start&#039;&#039; - each record begins with an uppercase letter &amp;quot;S&amp;quot; character (ASCII 0x53) which stands for &amp;quot;Start-of-Record&amp;quot;.&amp;lt;ref&amp;gt;{{cite book |title=MCM6830L7 MIKBUG / MINIBUG ROM |author-first1=Mike |author-last1=Wiles |author-first2=Andre |author-last2=Felix |editor-first=Michael |editor-last=Holley |date=2000-10-21 |orig-year=1975 |type=Engineering note |id=Note 100 |publisher=[[Motorola Semiconductor Products, Inc.]] |url=http://www.swtpc.com/mholley/MP_A/MikbugEn100.pdf |access-date=2019-06-16 |url-status=dead |archive-url=https://web.archive.org/web/20190616115550/http://www.swtpc.com/mholley/MP_A/MikbugEn100.pdf |archive-date=2019-06-16}} (23 pages)&amp;lt;/ref&amp;gt;&lt;br /&gt;
# &#039;&#039;Record type&#039;&#039; - single numeric digit &amp;quot;0&amp;quot; to &amp;quot;9&amp;quot;, defining the type of record.&lt;br /&gt;
# &#039;&#039;Byte count&#039;&#039; - two hex digits, indicating the number of bytes (hex digit pairs) that follow in the rest of the record (address + data + checksum). This field has a minimum value of 3 for 16-bit address field plus 1 checksum byte, and a maximum value of 255 (0xFF).&lt;br /&gt;
# &#039;&#039;Address&#039;&#039; - four / six / eight hex digits as determined by the record type. The address bytes are arranged in [[Endianness|big endian]] format.&lt;br /&gt;
# &#039;&#039;Data&#039;&#039; - a sequence of 2&#039;&#039;n&#039;&#039; hex digits, for &#039;&#039;n&#039;&#039; bytes of the data. For S1/S2/S3 records, a maximum of 32 bytes per record is typical since it will fit on an 80 character wide terminal screen, though 16 bytes would be easier to visually decode each byte at a specific address.&lt;br /&gt;
# &#039;&#039;Checksum&#039;&#039; - two hex digits, the [[least significant byte]] of [[ones&#039; complement]] of the sum of the values represented by the two hex digit pairs for the byte count, address and data fields. See example section for a detailed checksum example.&lt;br /&gt;
===Text line terminators===&lt;br /&gt;
SREC records are separated by one or more ASCII line termination characters so that each record appears alone on a text line. This enhances legibility by visually [[delimiter|delimiting]] the records and it also provides padding between records that can be used to improve machine [[parsing]] efficiency.&lt;br /&gt;
&lt;br /&gt;
Programs that create HEX records typically use line termination characters that conform to the conventions of their [[operating system]]s. For example, Linux programs use a single LF character ([[Newline|line feed]], 0x0A as ASCII character value) character to terminate lines, whereas Windows programs use a CR character ([[carriage return]], 0x0D as ASCII character value) followed by a LF character.&lt;br /&gt;
===Record types===&lt;br /&gt;
The following table describes 10 possible S-records. S4 is reserved and not currently defined. S6 was originally reserved but was later redefined.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Record&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;purpose&lt;br /&gt;
! Address&amp;lt;br&amp;gt;field&lt;br /&gt;
! Data&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;description&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S0&#039;&#039;&lt;br /&gt;
| Header&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;&amp;quot;0000&amp;quot;&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains vendor specific ASCII text comment represented as a series of hex digit pairs. It is common to see the data for this record in the format of a [[null-terminated string]]. The text data can be anything including a mixture of the following information: file/module name, version/revision number, date/time, product name, vendor name, memory designator on PCB, copyright notice. It is common to see: 48 44 52 which is the ASCII H, D, and R - &amp;quot;HDR&amp;quot;.&amp;lt;ref name=&amp;quot;Tareski_2018&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S1&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at the 16-bit address field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is typically used for 8-bit microcontrollers, such as AVR, PIC, 8051, 68xx, 6502, 80xx, Z80. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 3 (that is, 2 bytes for &amp;quot;16-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S2&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 24-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 4 (that is, 3 bytes for &amp;quot;24-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S3&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 32-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is typically used for 32-bit microcontrollers, such as ARM and 680x0. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 5 (that is, 4 bytes for &amp;quot;32-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S4&#039;&#039;&lt;br /&gt;
| Reserved&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| This record is reserved.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S5&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 16-bit count of S1/S2/S3 records.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is used if the record count is less than or equal to 65,535 (0xFFFF), otherwise S6 record would be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S6&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 24-bit count of S1/S2/S3 records. This record is used if the record count is less than or equal to 16,777,215 (0xFFFFFF). If less than 65,536 (0x10000), then S5 record would be used. &#039;&#039;&#039;NOTE:&#039;&#039;&#039; This newer record is the most recent change (it may not be official).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S7&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 32-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S3 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S8&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 24-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S2 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S9&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 16-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S1 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|}&lt;br /&gt;
===Record order===&lt;br /&gt;
Although some Unix documentation states &amp;quot;the order of S-records within a file is of no significance and no particular order may be assumed&amp;quot;,&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; in practice most software has ordered the SREC records. The typical record order starts with a (sometimes optional) S0 header record, continues with a sequence of one or more S1/S2/S3 data records, may have one optional S5/S6 count record, and ends with one appropriate S7/S8/S9 termination record.&lt;br /&gt;
; S19-style 16-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S1 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S9&lt;br /&gt;
; S28-style 24-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S2 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S8&lt;br /&gt;
; S37-style 32-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S3 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S7&lt;br /&gt;
===Limitations===&lt;br /&gt;
&#039;&#039;Record length&#039;&#039; - Unix manual page documentation states, &amp;quot;An S-record file consists of a sequence of specially formatted ASCII character strings. An S-record will be less than or equal to 78 bytes in length&amp;quot;. The manual page further limits the number of characters in the data field to 64 (or 32 data bytes).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; A record with an 8-hex-character address and 64 data characters would be 78 (2 + 2 + 8 + 64 + 2) characters long (this count ignores possible end-of-line or string termination characters). The file could be printed on an 80-character wide teleprinter. A note at the bottom of the manual page states, &amp;quot;This [manual page] is the only place that a 78-byte limit on total record length or 64-byte limit on data length is documented. These values shouldn&#039;t be trusted for the general case&amp;quot;.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; If that limitation is ignored, the maximum length of an S-record is 514 characters: 2 for Record Type field + 2 for Byte Count field (whose value would be 0xFF=255) + 2 * 255 for Address, Data, and Checksum fields. Additional buffer space may be required for the line and string terminators. Using long line lengths has problems: &amp;quot;The Motorola S-record format definition permits up to 255 bytes of payload, or lines of 514 characters, plus the line termination. All EPROM programmers should have sufficiently large line buffers to cope with records this big. Few do.&amp;quot;&amp;lt;ref name=&amp;quot;sf&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Data field&#039;&#039; - Some documentation recommends a maximum of 32 bytes of data (64 hex characters) in this field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The minimum amount of data for S0/S1/S2/S3 records is zero. The maximum amount of data varies depending on the size of the address field. Since the Byte Count field can&#039;t be higher than 255 (0xFF), then the maximum number of bytes of data is calculated by 255 minus (1 byte for checksum field) minus (number of bytes in the address field). S0/S1 records support up to 252 bytes of data. S2 record supports up to 251 bytes of data. S3 record supports up to 250 bytes of data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Comments&#039;&#039; - The SREC file format does not support comments. Some software ignores all text lines that do not start with &amp;quot;S&amp;quot; and ignores all text after the checksum field; that extra text is sometimes used (incompatibly) for comments. For example, the CCS PIC compiler supports placing a &amp;quot;;&amp;quot; comment line at the top or bottom of an [[Intel HEX]] file, and its manuals states &amp;quot;some programmers (MPLAB in particular) do not like comments at the top of the hex file&amp;quot;, which is why the compiler has the option of placing the comment at the bottom of the hex file.&amp;lt;ref name=&amp;quot;CCS_2014&amp;quot;/&amp;gt;&lt;br /&gt;
==Examples==&lt;br /&gt;
; Color legend&lt;br /&gt;
{{legend inline| #FFCCCC |Record type}}&lt;br /&gt;
{{legend inline| #CCFFCC |Byte count}}&lt;br /&gt;
{{legend inline| #CCCCFF |Address}}&lt;br /&gt;
{{legend inline| #CCFFFF |Data}}&lt;br /&gt;
{{legend inline| #CCCCCC |Checksum}}&lt;br /&gt;
===Checksum calculation===&lt;br /&gt;
The following example record:&lt;br /&gt;
 {{SREC HEX|1|13|7AF0|0A0A0D00000000000000000000000000|61}}&lt;br /&gt;
is decoded to show how the checksum value is calculated as follows:&lt;br /&gt;
# Add: Add each byte 0x13 + 0x7A + 0xF0 + 0x0A + 0x0A + 0x0D + 0x00 + ... + 0x00 = 0x19E total.&lt;br /&gt;
# Mask: Keep the least significant byte of the total = 0x9E.&lt;br /&gt;
# Complement: Compute [[ones&#039; complement]] of least significant byte = 0x61.&lt;br /&gt;
===16-bit memory address===&lt;br /&gt;
 {{SREC HEX|0|0F|0000|68656C6C6F20202020200000|3C}}&lt;br /&gt;
 {{SREC HEX|1|1F|0000|7C0802A6900100049421FFF07C6C1B787C8C23783C60000038630000|26}}&lt;br /&gt;
 {{SREC HEX|1|1F|001C|4BFFFFE5398000007D83637880010014382100107C0803A64E800020|E9}}&lt;br /&gt;
 {{SREC HEX|1|11|0038|48656C6C6F20776F726C642E0A00|42}}&lt;br /&gt;
 {{SREC HEX|5|03|0003||F9}}&lt;br /&gt;
 {{SREC HEX|9|03|0000||FC}}&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Binary-to-text encoding]], a survey and comparison of encoding algorithms&lt;br /&gt;
* [[Intel hex format]]&lt;br /&gt;
* [[MOS Technology file format]]&lt;br /&gt;
* [[Tektronix hex format]]&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist|refs=&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Tareski_2018&amp;quot;&amp;gt;{{Cite web |title=Motorola S-record description |author-last=Tareski |author-first=Val |website=www.amelek.gda.pl |url=http://www.amelek.gda.pl/avr/uisp/srecord.htm |access-date=2018-06-26}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;&amp;gt;{{cite web |title=Motorola S-records from Unix man pages |url=http://www.amelek.gda.pl/avr/uisp/srecord.htm |access-date=2014-06-30}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;&amp;gt;{{cite book |title=M68000 Family Programmer&#039;s Reference Manual |version=Revision 1 |publisher=[[Motorola]] ([[Freescale]]) |date=1992 |pages=C-1–C-5 |chapter=Appendix C |isbn=978-0-13723289-5 |url=http://www.freescale.com/files/archives/doc/ref_manual/M68000PRM.pdf}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;sf&amp;quot;&amp;gt;{{cite web |title=srec_examples |work=sourceforge.net |url=http://srecord.sourceforge.net/man/man1/srec_examples.html}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;CCS_2014&amp;quot;&amp;gt;{{citation |title=CCS Compiler Reference Manual PCB/PCM/PCH |publisher=[[Custom Computer Services, Inc.]] |date=May 2014 |page=107 |url=http://www.ccsinfo.com/downloads/ccs_c_manual.pdf |access-date=2015-02-08}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Xilinx_2010_EXO&amp;quot;&amp;gt;{{cite web |title=AR#476 PROMGen - Description of PROM/EEPROM file formats: MCS, EXO, HEX, and others |at=Motorola EXORmacs - File Format Code 87 |date=2010-03-08 |publisher=[[Xilinx]] |url=https://www.xilinx.com/support/answers/476.html |access-date=2020-03-03 |url-status=live |archive-url=https://web.archive.org/web/20200303085851/https://www.xilinx.com/support/answers/476.html |archive-date=2020-03-03}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://srecord.sourceforge.net/ SRecord] is a collection of tools for manipulating SREC format files.&lt;br /&gt;
* [http://www.keil.com/download/docs/4.asp BIN2MOT], BINARY to Motorola S-Record file converter utility.&lt;br /&gt;
* [https://github.com/BigWinston/SRecordizer/wiki SRecordizer] is a tool for viewing, editing, and error checking S19 format files.&lt;br /&gt;
* [https://pypi.python.org/pypi/bincopy bincopy] is a Python package for manipulating SREC format files.&lt;br /&gt;
* [https://github.com/arkku/srec kk_srec] is a C library and program for reading the SREC format.&lt;br /&gt;
{{DEFAULTSORT:Srec (File Format)}}&lt;br /&gt;
[[Category:Binary-to-text encoding formats]]&lt;br /&gt;
[[Category:Embedded systems]]&lt;br /&gt;
[[Category:Computer file formats]]&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=583</id>
		<title>SREC (file format)</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=SREC_(file_format)&amp;diff=583"/>
		<updated>2021-04-23T16:59:09Z</updated>

		<summary type="html">&lt;p&gt;Darren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Motorola S-record&#039;&#039;&#039; is a file format, created by [[Motorola]], that conveys binary information as [[hexadecimal|hex]] values in [[ASCII]] text form. This file format may also be known as &#039;&#039;&#039;SRECORD&#039;&#039;&#039;, &#039;&#039;&#039;SREC&#039;&#039;&#039;, &#039;&#039;&#039;S19&#039;&#039;&#039;, &#039;&#039;&#039;S28&#039;&#039;&#039;, &#039;&#039;&#039;S37&#039;&#039;&#039;. It is commonly used for programming [[flash memory]] in microcontrollers, [[EPROM]]s, [[EEPROM]]s, and other types of programmable logic devices. In a typical application, a compiler or assembler converts a program&#039;s source code (such as C or assembly language) to machine code and outputs it into a HEX file. The HEX file is then imported by a programmer to &amp;quot;burn&amp;quot; the machine code into [[non-volatile memory]], or is transferred to the target system for loading and execution.&lt;br /&gt;
==Overview==&lt;br /&gt;
[[File:Motorola SREC Chart.png|thumb|A quick reference chart for the Motorola SREC format. (Note that in the record example image the word &amp;quot;bytes&amp;quot; is alternatively used to specify characters.)&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename extension&lt;br /&gt;
|&amp;lt;code&amp;gt;.s19&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s28&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s37&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.s3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.sx&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.srec&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.exo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;.mxt&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Developed by&lt;br /&gt;
|Motorola&lt;br /&gt;
|}&lt;br /&gt;
]]&lt;br /&gt;
===History===&lt;br /&gt;
The S-record format was created in the mid-1970s for the [[Motorola 6800]] processor. [[Programming tool|Software development tools]] for that and other [[embedded processor]]s would make executable code and data in the S-record format. PROM programmers would then read the S-record format and &amp;quot;burn&amp;quot; the data into the PROMs or EPROMs used in the embedded system.&lt;br /&gt;
===Other hex formats===&lt;br /&gt;
There are other ASCII encoding with a similar purpose. [[BPNF]], [[BHLF]], and [[B10F]] were early binary formats, but they are neither compact nor flexible. Hexadecimal formats are more compact because they represent 4 bits rather than 1 bit per character. Many, such as S-record, are more flexible because they include address information so they can specify just a portion of a PROM. [[Intel HEX]] format was often used with Intel processors. [[TekHex]] is another hex format that can include a symbol table for debugging.&lt;br /&gt;
==Format==&lt;br /&gt;
===Record structure===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&#039;background: #FFCCCC&#039; | S || style=&#039;background: #FFCCCC&#039; | Type || style=&#039;background: #CCFFCC&#039; | Byte Count || style=&#039;background: #CCCCFF&#039; | Address || style=&#039;background: #CCFFFF&#039; | Data || style=&#039;background: #CCCCCC&#039; | Checksum&lt;br /&gt;
|}&lt;br /&gt;
An SREC format file consists of a series of ASCII text records. The records have the following structure from left to right:&lt;br /&gt;
# &#039;&#039;Record start&#039;&#039; - each record begins with an uppercase letter &amp;quot;S&amp;quot; character (ASCII 0x53) which stands for &amp;quot;Start-of-Record&amp;quot;.&amp;lt;ref&amp;gt;{{cite book |title=MCM6830L7 MIKBUG / MINIBUG ROM |author-first1=Mike |author-last1=Wiles |author-first2=Andre |author-last2=Felix |editor-first=Michael |editor-last=Holley |date=2000-10-21 |orig-year=1975 |type=Engineering note |id=Note 100 |publisher=[[Motorola Semiconductor Products, Inc.]] |url=http://www.swtpc.com/mholley/MP_A/MikbugEn100.pdf |access-date=2019-06-16 |url-status=dead |archive-url=https://web.archive.org/web/20190616115550/http://www.swtpc.com/mholley/MP_A/MikbugEn100.pdf |archive-date=2019-06-16}} (23 pages)&amp;lt;/ref&amp;gt;&lt;br /&gt;
# &#039;&#039;Record type&#039;&#039; - single numeric digit &amp;quot;0&amp;quot; to &amp;quot;9&amp;quot;, defining the type of record.&lt;br /&gt;
# &#039;&#039;Byte count&#039;&#039; - two hex digits, indicating the number of bytes (hex digit pairs) that follow in the rest of the record (address + data + checksum). This field has a minimum value of 3 for 16-bit address field plus 1 checksum byte, and a maximum value of 255 (0xFF).&lt;br /&gt;
# &#039;&#039;Address&#039;&#039; - four / six / eight hex digits as determined by the record type. The address bytes are arranged in [[Endianness|big endian]] format.&lt;br /&gt;
# &#039;&#039;Data&#039;&#039; - a sequence of 2&#039;&#039;n&#039;&#039; hex digits, for &#039;&#039;n&#039;&#039; bytes of the data. For S1/S2/S3 records, a maximum of 32 bytes per record is typical since it will fit on an 80 character wide terminal screen, though 16 bytes would be easier to visually decode each byte at a specific address.&lt;br /&gt;
# &#039;&#039;Checksum&#039;&#039; - two hex digits, the [[least significant byte]] of [[ones&#039; complement]] of the sum of the values represented by the two hex digit pairs for the byte count, address and data fields. See example section for a detailed checksum example.&lt;br /&gt;
===Text line terminators===&lt;br /&gt;
SREC records are separated by one or more ASCII line termination characters so that each record appears alone on a text line. This enhances legibility by visually [[delimiter|delimiting]] the records and it also provides padding between records that can be used to improve machine [[parsing]] efficiency.&lt;br /&gt;
&lt;br /&gt;
Programs that create HEX records typically use line termination characters that conform to the conventions of their [[operating system]]s. For example, Linux programs use a single LF character ([[Newline|line feed]], 0x0A as ASCII character value) character to terminate lines, whereas Windows programs use a CR character ([[carriage return]], 0x0D as ASCII character value) followed by a LF character.&lt;br /&gt;
===Record types===&lt;br /&gt;
The following table describes 10 possible S-records. S4 is reserved and not currently defined. S6 was originally reserved but was later redefined.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Record&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;purpose&lt;br /&gt;
! Address&amp;lt;br&amp;gt;field&lt;br /&gt;
! Data&amp;lt;br&amp;gt;field&lt;br /&gt;
! Record&amp;lt;br&amp;gt;description&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S0&#039;&#039;&lt;br /&gt;
| Header&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;&amp;quot;0000&amp;quot;&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains vendor specific ASCII text comment represented as a series of hex digit pairs. It is common to see the data for this record in the format of a [[null-terminated string]]. The text data can be anything including a mixture of the following information: file/module name, version/revision number, date/time, product name, vendor name, memory designator on PCB, copyright notice. It is common to see: 48 44 52 which is the ASCII H, D, and R - &amp;quot;HDR&amp;quot;.&amp;lt;ref name=&amp;quot;Tareski_2018&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S1&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at the 16-bit address field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is typically used for 8-bit microcontrollers, such as AVR, PIC, 8051, 68xx, 6502, 80xx, Z80. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 3 (that is, 2 bytes for &amp;quot;16-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S2&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 24-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 4 (that is, 3 bytes for &amp;quot;24-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S3&#039;&#039;&lt;br /&gt;
| Data&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Ya}}&lt;br /&gt;
| This record contains data that starts at a 32-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is typically used for 32-bit microcontrollers, such as ARM and 680x0. The number of bytes of data contained in this record is &amp;quot;Byte Count Field&amp;quot; minus 5 (that is, 4 bytes for &amp;quot;32-bit Address Field&amp;quot; and 1 byte for &amp;quot;Checksum Field&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S4&#039;&#039;&lt;br /&gt;
| Reserved&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| {{n/a}}&lt;br /&gt;
| This record is reserved.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S5&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 16-bit count of S1/S2/S3 records.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; This record is used if the record count is less than or equal to 65,535 (0xFFFF), otherwise S6 record would be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S6&#039;&#039;&lt;br /&gt;
| Count&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Count&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This optional record contains a 24-bit count of S1/S2/S3 records. This record is used if the record count is less than or equal to 16,777,215 (0xFFFFFF). If less than 65,536 (0x10000), then S5 record would be used. &#039;&#039;&#039;NOTE:&#039;&#039;&#039; This newer record is the most recent change (it may not be official).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S7&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 32-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 32-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S3 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S8&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 24-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 24-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S2 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | &#039;&#039;S9&#039;&#039;&lt;br /&gt;
| Start Address&amp;lt;br&amp;gt;(Termination)&lt;br /&gt;
| 16-bit&amp;lt;br&amp;gt;Address&lt;br /&gt;
| {{Na}}&lt;br /&gt;
| This record contains the starting execution location at a 16-bit address.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;/&amp;gt; This is used to terminate a series of S1 records. If a SREC file is only used to program a memory device and the execution location is ignored, then an address of zero could be used.&lt;br /&gt;
|}&lt;br /&gt;
===Record order===&lt;br /&gt;
Although some Unix documentation states &amp;quot;the order of S-records within a file is of no significance and no particular order may be assumed&amp;quot;,&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; in practice most software has ordered the SREC records. The typical record order starts with a (sometimes optional) S0 header record, continues with a sequence of one or more S1/S2/S3 data records, may have one optional S5/S6 count record, and ends with one appropriate S7/S8/S9 termination record.&lt;br /&gt;
; S19-style 16-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S1 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S9&lt;br /&gt;
; S28-style 24-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S2 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S8&lt;br /&gt;
; S37-style 32-bit address records&lt;br /&gt;
# S0&lt;br /&gt;
# S3 (one or more records)&lt;br /&gt;
# S5 (optional record)&lt;br /&gt;
# S7&lt;br /&gt;
===Limitations===&lt;br /&gt;
&#039;&#039;Record length&#039;&#039; - Unix manual page documentation states, &amp;quot;An S-record file consists of a sequence of specially formatted ASCII character strings. An S-record will be less than or equal to 78 bytes in length&amp;quot;. The manual page further limits the number of characters in the data field to 64 (or 32 data bytes).&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; A record with an 8-hex-character address and 64 data characters would be 78 (2 + 2 + 8 + 64 + 2) characters long (this count ignores possible end-of-line or string termination characters). The file could be printed on an 80-character wide teleprinter. A note at the bottom of the manual page states, &amp;quot;This [manual page] is the only place that a 78-byte limit on total record length or 64-byte limit on data length is documented. These values shouldn&#039;t be trusted for the general case&amp;quot;.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; If that limitation is ignored, the maximum length of an S-record is 514 characters: 2 for Record Type field + 2 for Byte Count field (whose value would be 0xFF=255) + 2 * 255 for Address, Data, and Checksum fields. Additional buffer space may be required for the line and string terminators. Using long line lengths has problems: &amp;quot;The Motorola S-record format definition permits up to 255 bytes of payload, or lines of 514 characters, plus the line termination. All EPROM programmers should have sufficiently large line buffers to cope with records this big. Few do.&amp;quot;&amp;lt;ref name=&amp;quot;sf&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Data field&#039;&#039; - Some documentation recommends a maximum of 32 bytes of data (64 hex characters) in this field.&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;/&amp;gt; The minimum amount of data for S0/S1/S2/S3 records is zero. The maximum amount of data varies depending on the size of the address field. Since the Byte Count field can&#039;t be higher than 255 (0xFF), then the maximum number of bytes of data is calculated by 255 minus (1 byte for checksum field) minus (number of bytes in the address field). S0/S1 records support up to 252 bytes of data. S2 record supports up to 251 bytes of data. S3 record supports up to 250 bytes of data.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Comments&#039;&#039; - The SREC file format does not support comments. Some software ignores all text lines that do not start with &amp;quot;S&amp;quot; and ignores all text after the checksum field; that extra text is sometimes used (incompatibly) for comments. For example, the CCS PIC compiler supports placing a &amp;quot;;&amp;quot; comment line at the top or bottom of an [[Intel HEX]] file, and its manuals states &amp;quot;some programmers (MPLAB in particular) do not like comments at the top of the hex file&amp;quot;, which is why the compiler has the option of placing the comment at the bottom of the hex file.&amp;lt;ref name=&amp;quot;CCS_2014&amp;quot;/&amp;gt;&lt;br /&gt;
==Examples==&lt;br /&gt;
; Color legend&lt;br /&gt;
{{legend inline| #FFCCCC |Record type}}&lt;br /&gt;
{{legend inline| #CCFFCC |Byte count}}&lt;br /&gt;
{{legend inline| #CCCCFF |Address}}&lt;br /&gt;
{{legend inline| #CCFFFF |Data}}&lt;br /&gt;
{{legend inline| #CCCCCC |Checksum}}&lt;br /&gt;
===Checksum calculation===&lt;br /&gt;
The following example record:&lt;br /&gt;
 {{SREC HEX|1|13|7AF0|0A0A0D00000000000000000000000000|61}}&lt;br /&gt;
is decoded to show how the checksum value is calculated as follows:&lt;br /&gt;
# Add: Add each byte 0x13 + 0x7A + 0xF0 + 0x0A + 0x0A + 0x0D + 0x00 + ... + 0x00 = 0x19E total.&lt;br /&gt;
# Mask: Keep the least significant byte of the total = 0x9E.&lt;br /&gt;
# Complement: Compute [[ones&#039; complement]] of least significant byte = 0x61.&lt;br /&gt;
===16-bit memory address===&lt;br /&gt;
 {{SREC HEX|0|0F|0000|68656C6C6F20202020200000|3C}}&lt;br /&gt;
 {{SREC HEX|1|1F|0000|7C0802A6900100049421FFF07C6C1B787C8C23783C60000038630000|26}}&lt;br /&gt;
 {{SREC HEX|1|1F|001C|4BFFFFE5398000007D83637880010014382100107C0803A64E800020|E9}}&lt;br /&gt;
 {{SREC HEX|1|11|0038|48656C6C6F20776F726C642E0A00|42}}&lt;br /&gt;
 {{SREC HEX|5|03|0003||F9}}&lt;br /&gt;
 {{SREC HEX|9|03|0000||FC}}&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Binary-to-text encoding]], a survey and comparison of encoding algorithms&lt;br /&gt;
* [[Intel hex format]]&lt;br /&gt;
* [[MOS Technology file format]]&lt;br /&gt;
* [[Tektronix hex format]]&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist|refs=&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Tareski_2018&amp;quot;&amp;gt;{{Cite web |title=Motorola S-record description |author-last=Tareski |author-first=Val |website=www.amelek.gda.pl |url=http://www.amelek.gda.pl/avr/uisp/srecord.htm |access-date=2018-06-26}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;SREC-Unix&amp;quot;&amp;gt;{{cite web |title=Motorola S-records from Unix man pages |url=http://www.amelek.gda.pl/avr/uisp/srecord.htm |access-date=2014-06-30}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;SREC-term&amp;quot;&amp;gt;{{cite book |title=M68000 Family Programmer&#039;s Reference Manual |version=Revision 1 |publisher=[[Motorola]] ([[Freescale]]) |date=1992 |pages=C-1–C-5 |chapter=Appendix C |isbn=978-0-13723289-5 |url=http://www.freescale.com/files/archives/doc/ref_manual/M68000PRM.pdf}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;sf&amp;quot;&amp;gt;{{cite web |title=srec_examples |work=sourceforge.net |url=http://srecord.sourceforge.net/man/man1/srec_examples.html}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;CCS_2014&amp;quot;&amp;gt;{{citation |title=CCS Compiler Reference Manual PCB/PCM/PCH |publisher=[[Custom Computer Services, Inc.]] |date=May 2014 |page=107 |url=http://www.ccsinfo.com/downloads/ccs_c_manual.pdf |access-date=2015-02-08}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Xilinx_2010_EXO&amp;quot;&amp;gt;{{cite web |title=AR#476 PROMGen - Description of PROM/EEPROM file formats: MCS, EXO, HEX, and others |at=Motorola EXORmacs - File Format Code 87 |date=2010-03-08 |publisher=[[Xilinx]] |url=https://www.xilinx.com/support/answers/476.html |access-date=2020-03-03 |url-status=live |archive-url=https://web.archive.org/web/20200303085851/https://www.xilinx.com/support/answers/476.html |archive-date=2020-03-03}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://srecord.sourceforge.net/ SRecord] is a collection of tools for manipulating SREC format files.&lt;br /&gt;
* [http://www.keil.com/download/docs/4.asp BIN2MOT], BINARY to Motorola S-Record file converter utility.&lt;br /&gt;
* [https://github.com/BigWinston/SRecordizer/wiki SRecordizer] is a tool for viewing, editing, and error checking S19 format files.&lt;br /&gt;
* [https://pypi.python.org/pypi/bincopy bincopy] is a Python package for manipulating SREC format files.&lt;br /&gt;
* [https://github.com/arkku/srec kk_srec] is a C library and program for reading the SREC format.&lt;br /&gt;
{{DEFAULTSORT:Srec (File Format)}}&lt;br /&gt;
[[Category:Binary-to-text encoding formats]]&lt;br /&gt;
[[Category:Embedded systems]]&lt;br /&gt;
[[Category:Computer file formats]]&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
	<entry>
		<id>https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Color_contrast&amp;diff=582</id>
		<title>Module:Color contrast</title>
		<link rel="alternate" type="text/html" href="https://www.darrenduncan.co.uk/mediawiki/index.php?title=Module:Color_contrast&amp;diff=582"/>
		<updated>2021-04-23T14:21:14Z</updated>

		<summary type="html">&lt;p&gt;Darren: 1 revision imported&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--&lt;br /&gt;
-- This module implements&lt;br /&gt;
--  {{Color contrast ratio}}&lt;br /&gt;
--  {{Greater color contrast ratio}}&lt;br /&gt;
--  {{ColorToLum}}&lt;br /&gt;
--  {{RGBColorToLum}}&lt;br /&gt;
--&lt;br /&gt;
local p = {}&lt;br /&gt;
local HTMLcolor = mw.loadData( &#039;Module:Color contrast/colors&#039; )&lt;br /&gt;
&lt;br /&gt;
local function sRGB (v)&lt;br /&gt;
	if (v &amp;lt;= 0.03928) then&lt;br /&gt;
		v = v / 12.92&lt;br /&gt;
	else&lt;br /&gt;
		v = math.pow((v+0.055)/1.055, 2.4)&lt;br /&gt;
	end&lt;br /&gt;
	return v&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function rgbdec2lum(R, G, B)&lt;br /&gt;
	if ( 0 &amp;lt;= R and R &amp;lt; 256 and 0 &amp;lt;= G and G &amp;lt; 256 and 0 &amp;lt;= B and B &amp;lt; 256 ) then&lt;br /&gt;
		return 0.2126 * sRGB(R/255) + 0.7152 * sRGB(G/255) + 0.0722 * sRGB(B/255)&lt;br /&gt;
	else&lt;br /&gt;
		return &#039;&#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function hsl2lum(h, s, l)&lt;br /&gt;
	if ( 0 &amp;lt;= h and h &amp;lt; 360 and 0 &amp;lt;= s and s &amp;lt;= 1 and 0 &amp;lt;= l and l &amp;lt;= 1 ) then&lt;br /&gt;
		local c = (1 - math.abs(2*l - 1))*s&lt;br /&gt;
		local x = c*(1 - math.abs( math.fmod(h/60, 2) - 1) )&lt;br /&gt;
		local m = l - c/2&lt;br /&gt;
&lt;br /&gt;
		local r, g, b = m, m, m&lt;br /&gt;
		if( 0 &amp;lt;= h and h &amp;lt; 60 ) then&lt;br /&gt;
			r = r + c&lt;br /&gt;
			g = g + x&lt;br /&gt;
		elseif( 60 &amp;lt;= h and h &amp;lt; 120 ) then&lt;br /&gt;
			r = r + x&lt;br /&gt;
			g = g + c&lt;br /&gt;
		elseif( 120 &amp;lt;= h and h &amp;lt; 180 ) then&lt;br /&gt;
			g = g + c&lt;br /&gt;
			b = b + x&lt;br /&gt;
		elseif( 180 &amp;lt;= h and h &amp;lt; 240 ) then&lt;br /&gt;
			g = g + x&lt;br /&gt;
			b = b + c&lt;br /&gt;
		elseif( 240 &amp;lt;= h and h &amp;lt; 300 ) then&lt;br /&gt;
			r = r + x&lt;br /&gt;
			b = b + c&lt;br /&gt;
		elseif( 300 &amp;lt;= h and h &amp;lt; 360 ) then&lt;br /&gt;
			r = r + c&lt;br /&gt;
			b = b + x&lt;br /&gt;
		end&lt;br /&gt;
		return rgbdec2lum(255*r, 255*g, 255*b)&lt;br /&gt;
	else&lt;br /&gt;
		return &#039;&#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function color2lum(c)&lt;br /&gt;
&lt;br /&gt;
	if (c == nil) then&lt;br /&gt;
		return &#039;&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- html &#039;#&#039; entity&lt;br /&gt;
	c = c:gsub(&amp;quot;&amp;amp;#35;&amp;quot;, &amp;quot;#&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	-- whitespace&lt;br /&gt;
	c = c:match( &#039;^%s*(.-)[%s;]*$&#039; )&lt;br /&gt;
&lt;br /&gt;
	-- unstrip nowiki strip markers&lt;br /&gt;
	c = mw.text.unstripNoWiki(c)&lt;br /&gt;
&lt;br /&gt;
	-- lowercase&lt;br /&gt;
	c = c:lower()&lt;br /&gt;
&lt;br /&gt;
	-- first try to look it up&lt;br /&gt;
	local L = HTMLcolor[c]&lt;br /&gt;
	if (L ~= nil) then&lt;br /&gt;
		return L&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- convert from hsl&lt;br /&gt;
	if mw.ustring.match(c,&#039;^hsl%([%s]*[0-9][0-9%.]*[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*%)$&#039;) then&lt;br /&gt;
		local h, s, l = mw.ustring.match(c,&#039;^hsl%([%s]*([0-9][0-9%.]*)[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*%)$&#039;)&lt;br /&gt;
		return hsl2lum(tonumber(h), tonumber(s)/100, tonumber(l)/100)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- convert from rgb&lt;br /&gt;
	if mw.ustring.match(c,&#039;^rgb%([%s]*[0-9][0-9]*[%s]*,[%s]*[0-9][0-9]*[%s]*,[%s]*[0-9][0-9]*[%s]*%)$&#039;) then&lt;br /&gt;
		local R, G, B = mw.ustring.match(c,&#039;^rgb%([%s]*([0-9][0-9]*)[%s]*,[%s]*([0-9][0-9]*)[%s]*,[%s]*([0-9][0-9]*)[%s]*%)$&#039;)&lt;br /&gt;
		return rgbdec2lum(tonumber(R), tonumber(G), tonumber(B))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- convert from rgb percent&lt;br /&gt;
	if mw.ustring.match(c,&#039;^rgb%([%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*%)$&#039;) then&lt;br /&gt;
		local R, G, B = mw.ustring.match(c,&#039;^rgb%([%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*%)$&#039;)&lt;br /&gt;
		return rgbdec2lum(255*tonumber(R)/100, 255*tonumber(G)/100, 255*tonumber(B)/100)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- remove leading # (if there is one) and whitespace&lt;br /&gt;
	c = mw.ustring.match(c, &#039;^[%s#]*([a-f0-9]*)[%s]*$&#039;)&lt;br /&gt;
&lt;br /&gt;
	-- split into rgb&lt;br /&gt;
	local cs = mw.text.split(c or &#039;&#039;, &#039;&#039;)&lt;br /&gt;
	if( #cs == 6 ) then&lt;br /&gt;
		local R = 16*tonumber(&#039;0x&#039; .. cs[1]) + tonumber(&#039;0x&#039; .. cs[2])&lt;br /&gt;
		local G = 16*tonumber(&#039;0x&#039; .. cs[3]) + tonumber(&#039;0x&#039; .. cs[4])&lt;br /&gt;
		local B = 16*tonumber(&#039;0x&#039; .. cs[5]) + tonumber(&#039;0x&#039; .. cs[6])&lt;br /&gt;
&lt;br /&gt;
		return rgbdec2lum(R, G, B)&lt;br /&gt;
	elseif ( #cs == 3 ) then&lt;br /&gt;
		local R = 16*tonumber(&#039;0x&#039; .. cs[1]) + tonumber(&#039;0x&#039; .. cs[1])&lt;br /&gt;
		local G = 16*tonumber(&#039;0x&#039; .. cs[2]) + tonumber(&#039;0x&#039; .. cs[2])&lt;br /&gt;
		local B = 16*tonumber(&#039;0x&#039; .. cs[3]) + tonumber(&#039;0x&#039; .. cs[3])&lt;br /&gt;
&lt;br /&gt;
		return rgbdec2lum(R, G, B)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- failure, return blank&lt;br /&gt;
	return &#039;&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This exports the function for use in other modules.&lt;br /&gt;
-- The colour is passed as a string.&lt;br /&gt;
function p._lum(color)&lt;br /&gt;
	return color2lum(color)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._greatercontrast(args)&lt;br /&gt;
	local bias = tonumber(args[&#039;bias&#039;] or &#039;0&#039;) or 0&lt;br /&gt;
	local css = (args[&#039;css&#039;] and args[&#039;css&#039;] ~= &#039;&#039;) and true or false&lt;br /&gt;
	local v1 = color2lum(args[1] or &#039;&#039;)&lt;br /&gt;
	local c2 = args[2] or &#039;#FFFFFF&#039;&lt;br /&gt;
	local v2 = color2lum(c2)&lt;br /&gt;
	local c3 = args[3] or &#039;#000000&#039;&lt;br /&gt;
	local v3 = color2lum(c3)&lt;br /&gt;
	local ratio1 = -1;&lt;br /&gt;
	local ratio2 = -1;&lt;br /&gt;
	if (type(v1) == &#039;number&#039; and type(v2) == &#039;number&#039;) then&lt;br /&gt;
		ratio1 = (v2 + 0.05)/(v1 + 0.05)&lt;br /&gt;
		ratio1 = (ratio1 &amp;lt; 1) and 1/ratio1 or ratio1&lt;br /&gt;
	end&lt;br /&gt;
	if (type(v1) == &#039;number&#039; and type(v3) == &#039;number&#039;) then&lt;br /&gt;
		ratio2 = (v3 + 0.05)/(v1 + 0.05)&lt;br /&gt;
		ratio2 = (ratio2 &amp;lt; 1) and 1/ratio2 or ratio2&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if css then&lt;br /&gt;
		local c1 = args[1] or &#039;&#039;&lt;br /&gt;
		if mw.ustring.match(c1, &#039;^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$&#039;) or&lt;br /&gt;
			mw.ustring.match(c1, &#039;^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$&#039;) then&lt;br /&gt;
				c1 = &#039;#&#039; .. c1&lt;br /&gt;
		end&lt;br /&gt;
		if mw.ustring.match(c2, &#039;^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$&#039;) or&lt;br /&gt;
			mw.ustring.match(c2, &#039;^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$&#039;) then&lt;br /&gt;
				c2 = &#039;#&#039; .. c2&lt;br /&gt;
		end&lt;br /&gt;
		if mw.ustring.match(v3, &#039;^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$&#039;) or&lt;br /&gt;
			mw.ustring.match(v3, &#039;^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$&#039;) then&lt;br /&gt;
				c3 = &#039;#&#039; .. c3&lt;br /&gt;
		end&lt;br /&gt;
		return &#039;background-color:&#039; .. c1 .. &#039;; color:&#039; .. ((ratio1 &amp;gt; 0) and (ratio2 &amp;gt; 0) and ((ratio1 + bias &amp;gt; ratio2) and c2 or c3) or &#039;&#039;) .. &#039;;&#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return (ratio1 &amp;gt; 0) and (ratio2 &amp;gt; 0) and ((ratio1 + bias &amp;gt; ratio2) and c2 or c3) or &#039;&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._ratio(args)&lt;br /&gt;
	local v1 = color2lum(args[1])&lt;br /&gt;
	local v2 = color2lum(args[2])&lt;br /&gt;
	if (type(v1) == &#039;number&#039; and type(v2) == &#039;number&#039;) then&lt;br /&gt;
		-- v1 should be the brighter of the two.&lt;br /&gt;
		if v2 &amp;gt; v1 then&lt;br /&gt;
			v1, v2 = v2, v1&lt;br /&gt;
		end&lt;br /&gt;
		return (v1 + 0.05)/(v2 + 0.05)&lt;br /&gt;
	else&lt;br /&gt;
		return args[&#039;error&#039;] or &#039;?&#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._styleratio(args)&lt;br /&gt;
	local style = (args[1] or &#039;&#039;):lower()&lt;br /&gt;
	local bg, fg = &#039;white&#039;, &#039;black&#039;&lt;br /&gt;
	local lum_bg, lum_fg = 1, 0&lt;br /&gt;
&lt;br /&gt;
	if args[2] then&lt;br /&gt;
		local lum = color2lum(args[2])&lt;br /&gt;
		if lum ~= &#039;&#039; then bg, lum_bg = args[2], lum end&lt;br /&gt;
	end&lt;br /&gt;
	if args[3] then&lt;br /&gt;
		local lum = color2lum(args[3])&lt;br /&gt;
		if lum ~= &#039;&#039; then fg, lum_fg = args[3], lum end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local slist = mw.text.split(mw.ustring.gsub(mw.ustring.gsub(style or &#039;&#039;, &#039;&amp;amp;#[Xx]23;&#039;, &#039;#&#039;), &#039;&amp;amp;#35;&#039;, &#039;#&#039;), &#039;;&#039;)&lt;br /&gt;
	for k = 1,#slist do&lt;br /&gt;
		local s = slist[k]&lt;br /&gt;
		local k,v = s:match( &#039;^[%s]*([^:]-):([^:]-)[%s;]*$&#039; )&lt;br /&gt;
		k = k or &#039;&#039;&lt;br /&gt;
		v = v or &#039;&#039;&lt;br /&gt;
		if (k:match(&#039;^[%s]*(background)[%s]*$&#039;) or k:match(&#039;^[%s]*(background%-color)[%s]*$&#039;)) then&lt;br /&gt;
			local lum = color2lum(v)&lt;br /&gt;
			if( lum ~= &#039;&#039; ) then bg, lum_bg = v, lum end&lt;br /&gt;
		elseif (k:match(&#039;^[%s]*(color)[%s]*$&#039;)) then&lt;br /&gt;
			local lum = color2lum(v)&lt;br /&gt;
			if( lum ~= &#039;&#039; ) then bg, lum_fg = v, lum end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if lum_bg &amp;gt; lum_fg then&lt;br /&gt;
		return (lum_bg + 0.05)/(lum_fg + 0.05)&lt;br /&gt;
	else&lt;br /&gt;
		return (lum_fg + 0.05)/(lum_bg + 0.05)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Use {{#invoke:Color contrast|somecolor}} directly or&lt;br /&gt;
{{#invoke:Color contrast}} from a wrapper template.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
	-- |1=	— required; A color to check.&lt;br /&gt;
--]]&lt;br /&gt;
function p.lum(frame)&lt;br /&gt;
	local color = frame.args[1] or frame:getParent().args[1]&lt;br /&gt;
	return p._lum(color)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.ratio(frame)&lt;br /&gt;
	local args = frame.args[1] and frame.args or frame:getParent().args&lt;br /&gt;
	return p._ratio(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.styleratio(frame)&lt;br /&gt;
	local args = frame.args[1] and frame.args or frame:getParent().args&lt;br /&gt;
	return p._styleratio(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.greatercontrast(frame)&lt;br /&gt;
	local args = frame.args[1] and frame.args or frame:getParent().args&lt;br /&gt;
	return p._greatercontrast(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Darren</name></author>
	</entry>
</feed>