<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.prismparty.net/history/Module:Format_link/doc?feed=atom</id>
	<title>Module:Format link/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.prismparty.net/history/Module:Format_link/doc?feed=atom"/>
	<link rel="alternate" type="text/html" href="https://www.prismparty.net/history/Module:Format_link/doc"/>
	<updated>2026-05-07T04:35:18Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://www.prismparty.net/index.php?title=Module:Format_link/doc&amp;diff=194&amp;oldid=prev</id>
		<title>BakiDance: Created page with &quot;{{Documentation}} {{Wikipedia template}}  This module, migrated from origins in Module:Hatnote, provides functionality for formatting links for display, including that powering the {{tl|format link}} template.  It can pretty-format section links with the section symbol (&quot;§&quot;) and appropriate whitespace, it automatically escapes category and file names with the colon trick, and includes functionality for italicizing the page or section name, and f...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.prismparty.net/index.php?title=Module:Format_link/doc&amp;diff=194&amp;oldid=prev"/>
		<updated>2023-01-25T21:03:34Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Documentation}} {{Wikipedia template}}  This module, migrated from origins in &lt;a href=&quot;/Module:Hatnote&quot; title=&quot;Module:Hatnote&quot;&gt;Module:Hatnote&lt;/a&gt;, provides functionality for formatting links for display, including that powering the {{tl|format link}} template.  It can pretty-format section links with the section symbol (&amp;quot;§&amp;quot;) and appropriate whitespace, it automatically escapes category and file names with the &lt;a href=&quot;/edit/Help:Colon_trick?redlink=1&quot; class=&quot;new&quot; title=&quot;Help:Colon trick (page does not exist)&quot;&gt;colon trick&lt;/a&gt;, and includes functionality for italicizing the page or section name, and f...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Documentation}}&lt;br /&gt;
{{Wikipedia template}}&lt;br /&gt;
&lt;br /&gt;
This module, migrated from origins in [[Module:Hatnote]], provides functionality for formatting links for display, including that powering the {{tl|format link}} template.&lt;br /&gt;
&lt;br /&gt;
It can pretty-format section links with the section symbol (&amp;quot;§&amp;quot;) and appropriate whitespace, it automatically escapes category and file names with the [[Help:Colon trick|colon trick]], and includes functionality for italicizing the page or section name, and for detecting and categorizing results that produce [[Wikipedia:Red link|red links]].&lt;br /&gt;
&lt;br /&gt;
== Use from wikitext ==&lt;br /&gt;
The functions in this module cannot be used directly from #invoke, and must be used through templates instead. Please see [[Template:Format link]] for documentation on usage of that template. &lt;br /&gt;
&lt;br /&gt;
== Use from other Lua modules==&lt;br /&gt;
To load this module from another Lua module, use the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local mFormatLink = require('Module:Format link')&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then use the functions as documented below.&lt;br /&gt;
&lt;br /&gt;
=== _formatLink ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
mFormatLink._formatLink{&lt;br /&gt;
    link = 'Link',&lt;br /&gt;
    display = 'Display',&lt;br /&gt;
    target = 'Target',&lt;br /&gt;
    italicizePage = true,&lt;br /&gt;
    italicizeSection = true,&lt;br /&gt;
    categorizeMissing = 'Pages using formatted red links'&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Formats &amp;lt;var&amp;gt;link&amp;lt;/var&amp;gt; as a wikilink. Categories and files are automatically escaped with the [[Help:Colon trick|colon trick]], and links to sections are automatically formatted as ''page § section'', rather than the MediaWiki default of ''page#section''.&lt;br /&gt;
&lt;br /&gt;
Several options modify the output:&lt;br /&gt;
* If the &amp;lt;var&amp;gt;display&amp;lt;/var&amp;gt; value is present, then it will be used as a display value. Any manual piping (using the &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{!}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; magic word or similar) present in &amp;lt;var&amp;gt;link&amp;lt;/var&amp;gt; will be overridden by the &amp;lt;var&amp;gt;display&amp;lt;/var&amp;gt; value if present.&lt;br /&gt;
* If the &amp;lt;var&amp;gt;target&amp;lt;/var&amp;gt; value is present, then it will override &amp;lt;var&amp;gt;link&amp;lt;/var&amp;gt; as a target, but the result will still be ''displayed'' using either the value from &amp;lt;var&amp;gt;display&amp;lt;/var&amp;gt;, or the result of formatting &amp;lt;var&amp;gt;link&amp;lt;/var&amp;gt;.&lt;br /&gt;
* If &amp;lt;var&amp;gt;italicizePage&amp;lt;/var&amp;gt; is true, then the page portion of the link is italicized if present.&lt;br /&gt;
* If &amp;lt;var&amp;gt;italicizeSection&amp;lt;/var&amp;gt; is true, then the section portion of the link is italicized if present.&lt;br /&gt;
* If &amp;lt;var&amp;gt;categorizeMissing&amp;lt;/var&amp;gt; is a non-empty string, then that value is used as a category name, and that category will be applied if the resulting target of the link (no matter whether through &amp;lt;var&amp;gt;link&amp;lt;/var&amp;gt; or through &amp;lt;var&amp;gt;target&amp;lt;/var&amp;gt;) doesn't exist.&lt;br /&gt;
&lt;br /&gt;
;Examples:&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; inline&amp;gt;mFormatLink._formatLink{link = 'Foo#Bar'}&amp;lt;/syntaxhighlight&amp;gt; &amp;amp;rarr; &amp;lt;nowiki&amp;gt;[[:Foo#Bar|Foo §&amp;amp;amp;nbsp;Bar]]&amp;lt;/nowiki&amp;gt; &amp;amp;rarr; {{format link|Foo#Bar}}&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; inline&amp;gt;mFormatLink._formatLink{link = 'Baz', display = 'Qux'}&amp;lt;/syntaxhighlight&amp;gt; &amp;amp;rarr; &amp;lt;nowiki&amp;gt;[[:Baz|Qux]]&amp;lt;/nowiki&amp;gt; &amp;amp;rarr; {{format link|Baz|Qux}}&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; inline&amp;gt;mFormatLink._formatLink{link = 'Foo|Bar', display = 'Baz'}&amp;lt;/syntaxhighlight&amp;gt; &amp;amp;rarr; &amp;lt;nowiki&amp;gt;[[:Foo|Baz]]&amp;lt;/nowiki&amp;gt; &amp;amp;rarr; {{format link|Foo{{!}}Bar|Baz}}&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; inline&amp;gt;mFormatLink._formatLink{link = '#Foo', target = 'Example#Foo'}&amp;lt;/syntaxhighlight&amp;gt; &amp;amp;rarr; &amp;lt;nowiki&amp;gt;[[:Example#Foo|§&amp;amp;amp;nbsp;Foo]]&amp;lt;/nowiki&amp;gt; &amp;amp;rarr; {{format link|#Foo||Example#Foo}}&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; inline&amp;gt;mFormatLink._formatLink{link = 'The Lord of the Rings#Plot', italicizePage = true}&amp;lt;/syntaxhighlight&amp;gt; &amp;amp;rarr; &amp;lt;nowiki&amp;gt;[[:The Lord of the Rings#Plot|''The Lord of the Rings'' §&amp;amp;amp;nbsp;Plot]]&amp;lt;/nowiki&amp;gt; &amp;amp;rarr; {{format link|The Lord of the Rings#Plot|italicizepage=true}}&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; inline&amp;gt;mFormatLink._formatLink{link = 'Cybercrime Prevention Act of 2012#Disini v. Secretary of Justice', italicizeSection = true}&amp;lt;/syntaxhighlight&amp;gt; &amp;amp;rarr; &amp;lt;nowiki&amp;gt;[[:Cybercrime Prevention Act of 2012#Disini v. Secretary of Justice|Cybercrime Prevention Act of 2012 §&amp;amp;amp;nbsp;''Disini v. Secretary of Justice'']]&amp;lt;/nowiki&amp;gt; &amp;amp;rarr; {{format link|Cybercrime Prevention Act of 2012#Disini v. Secretary of Justice|italicizesection=true}}&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; inline&amp;gt;mFormatLink._formatLink{link = 'Nonexistent page', categorizeMissing = 'Example'}&amp;lt;/syntaxhighlight&amp;gt; &amp;amp;rarr; &amp;lt;nowiki&amp;gt;[[:Nonexistent page]][[Category:Example]]&amp;lt;/nowiki&amp;gt; &amp;amp;rarr; {{format link|Nonexistent page}}&lt;br /&gt;
: &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; inline&amp;gt;mFormatLink._formatLink{link = 'Existing', categorizeMissing = 'Example'}&amp;lt;/syntaxhighlight&amp;gt; &amp;amp;rarr; &amp;lt;nowiki&amp;gt;[[:Existing]]&amp;lt;/nowiki&amp;gt; &amp;amp;rarr; {{format link|Existing}}&lt;br /&gt;
&lt;br /&gt;
=== formatPages ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
mFormatLink.formatPages(options, pages)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This derived function is useful for lists that format many links. It formats an array of pages using the [[#_formatLink|_formatLink]] function, and returns the result as an array. Options in the &amp;lt;var&amp;gt;options&amp;lt;/var&amp;gt; table are applied, and use the same names as the options for &amp;lt;var&amp;gt;_formatLink&amp;lt;/var&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;Example&lt;br /&gt;
:{{code|&amp;lt;nowiki&amp;gt;mFormatLink.formatPages({categorizeMissing = 'Example'}, {'Foo#Bar', 'Nonexistent page'})&amp;lt;/nowiki&amp;gt;|lua}} &amp;amp;rarr; {{code|&amp;lt;nowiki&amp;gt;{'[[:Foo#Bar|Foo §&amp;amp;nbsp;Bar]]', '[[:Nonexistent page]][[Category:Example]]'}&amp;lt;/nowiki&amp;gt;|lua}}&lt;br /&gt;
&lt;br /&gt;
== Errors ==&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;var&amp;gt;_formatLink&amp;lt;/var&amp;gt; is used and neither a &amp;lt;var&amp;gt;link&amp;lt;/var&amp;gt; nor a &amp;lt;var&amp;gt;target&amp;lt;/var&amp;gt; argument is provided, then the module will produce an error message instead of its usual output, as it ''cannot'' then produce valid output.&lt;br /&gt;
&lt;br /&gt;
You can solve this error by providing appropriate parameters to &amp;lt;var&amp;gt;_formatLink&amp;lt;/var&amp;gt;, or you may want to ensure that a more descriptive error is provided by a downstream template or module when it would otherwise call &amp;lt;var&amp;gt;_formatLink&amp;lt;/var&amp;gt; with inadequate arguments.&lt;/div&gt;</summary>
		<author><name>BakiDance</name></author>
	</entry>
</feed>