Jump to content
Main menu
Main menu
move to sidebar
hide
འགྲུལ་བསྐྱོད།
མ་ཤོག།
མི་སྡེའི་སྒོ་ར།
འཕྲལ་གྱི་བསྒྱུར་བཅོས
གང་འབྱུང་ཤོག་ལེབ།
གྲོགས་རམ།
དམིགས་བསལ་ཤོག་ལེབ།
འཚོལ་ཞིབ།
འཚོལ་ཞིབ།
Appearance
ཕན་འདེབས།
ནང་བསྐྱོད
ནང་བསྐྱོད།
རང་དོན་ལག་ཆས།
ཕན་འདེབས།
ནང་བསྐྱོད
ནང་བསྐྱོད།
Pages for logged out editors
learn more
Contributions
Talk
Module:Format link/doc
ཞུན་དག་འབད་དོ།
Add languages
Module
གྲོས་བསྡུར།
ཇོང་ཁ
ལྷག
Edit source
View history
ལག་ཆས་ཚུ་
Tools
move to sidebar
hide
ལས་སྣ་ཚུ་
ལྷག
Edit source
View history
General
ནཱ་ལུ་ ག་ཅི་འབྲེལ་མཐུད་འོང་ནི་མས།
འབྲེལ་བ་ཅན་གྱི་བསྒྱུར་བཅོས།
ཡིག་སྣོད་སྐྱེལ་བཙུགས་འབད།
ཤོག་ངོས་བརྡ་དོན།
Get shortened URL
Download QR code
Appearance
move to sidebar
hide
ཉེན་བརྡ:
ཁྱོད་ཀྱིས་ ནང་བསྐྱོད་མ་འབད་བས། ཁྱོད་ཀྱི་ ཨའི་པི་ཁ་བྱང་འདི་ ཤོག་ལེབ་ཀྱི་ཞུན་དག་སྤྱོད་ཤུལ་འདི་ནང་ ཐོ་བཀོད་འབད་དེ་བཞག་འོང་།
Anti-spam check. Do
not
fill this in!
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata --> {{used in system|in [[MediaWiki:Perfcachedts]]}} {{Lua|Module:Arguments|Module:Error|Module:Yesno}} 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 ("§") 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]]. == Use from wikitext == 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. == Use from other Lua modules== To load this module from another Lua module, use the following code: <syntaxhighlight lang="lua"> local mFormatLink = require('Module:Format link') </syntaxhighlight> You can then use the functions as documented below. === _formatLink === <syntaxhighlight lang="lua"> mFormatLink._formatLink{ link = 'Link', display = 'Display', target = 'Target', italicizePage = true, italicizeSection = true, categorizeMissing = 'Pages using formatted red links' } </syntaxhighlight> Formats <var>link</var> 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''. Several options modify the output: * If the <var>display</var> value is present, then it will be used as a display value. Any manual piping (using the <code><nowiki>{{!}}</nowiki></code> magic word or similar) present in <var>link</var> will be overridden by the <var>display</var> value if present. * If the <var>target</var> value is present, then it will override <var>link</var> as a target, but the result will still be ''displayed'' using either the value from <var>display</var>, or the result of formatting <var>link</var>. * If <var>italicizePage</var> is true, then the page portion of the link is italicized if present. * If <var>italicizeSection</var> is true, then the section portion of the link is italicized if present. * If <var>categorizeMissing</var> 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 <var>link</var> or through <var>target</var>) doesn't exist. ;Examples: : <syntaxhighlight lang="lua" inline>mFormatLink._formatLink{link = 'Foo#Bar'}</syntaxhighlight> → <nowiki>[[:Foo#Bar|Foo §&nbsp;Bar]]</nowiki> → {{format link|Foo#Bar}} : <syntaxhighlight lang="lua" inline>mFormatLink._formatLink{link = 'Baz', display = 'Qux'}</syntaxhighlight> → <nowiki>[[:Baz|Qux]]</nowiki> → {{format link|Baz|Qux}} : <syntaxhighlight lang="lua" inline>mFormatLink._formatLink{link = 'Foo|Bar', display = 'Baz'}</syntaxhighlight> → <nowiki>[[:Foo|Baz]]</nowiki> → {{format link|Foo{{!}}Bar|Baz}} : <syntaxhighlight lang="lua" inline>mFormatLink._formatLink{link = '#Foo', target = 'Example#Foo'}</syntaxhighlight> → <nowiki>[[:Example#Foo|§&nbsp;Foo]]</nowiki> → {{format link|#Foo||Example#Foo}} : <syntaxhighlight lang="lua" inline>mFormatLink._formatLink{link = 'The Lord of the Rings#Plot', italicizePage = true}</syntaxhighlight> → <nowiki>[[:The Lord of the Rings#Plot|''The Lord of the Rings'' §&nbsp;Plot]]</nowiki> → {{format link|The Lord of the Rings#Plot|italicizepage=true}} : <syntaxhighlight lang="lua" inline>mFormatLink._formatLink{link = 'Cybercrime Prevention Act of 2012#Disini v. Secretary of Justice', italicizeSection = true}</syntaxhighlight> → <nowiki>[[:Cybercrime Prevention Act of 2012#Disini v. Secretary of Justice|Cybercrime Prevention Act of 2012 §&nbsp;''Disini v. Secretary of Justice'']]</nowiki> → {{format link|Cybercrime Prevention Act of 2012#Disini v. Secretary of Justice|italicizesection=true}} : <syntaxhighlight lang="lua" inline>mFormatLink._formatLink{link = 'Nonexistent page', categorizeMissing = 'Example'}</syntaxhighlight> → <nowiki>[[:Nonexistent page]][[Category:Example]]</nowiki> → {{format link|Nonexistent page}} : <syntaxhighlight lang="lua" inline>mFormatLink._formatLink{link = 'Existing', categorizeMissing = 'Example'}</syntaxhighlight> → <nowiki>[[:Existing]]</nowiki> → {{format link|Existing}} === formatPages === <syntaxhighlight lang="lua"> mFormatLink.formatPages(options, pages) </syntaxhighlight> 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 <var>options</var> table are applied, and use the same names as the options for <var>_formatLink</var>. ;Example :{{code|<nowiki>mFormatLink.formatPages({categorizeMissing = 'Example'}, {'Foo#Bar', 'Nonexistent page'})</nowiki>|lua}} → {{code|<nowiki>{'[[:Foo#Bar|Foo § Bar]]', '[[:Nonexistent page]][[Category:Example]]'}</nowiki>|lua}} == Errors == If <var>_formatLink</var> is used and neither a <var>link</var> nor a <var>target</var> argument is provided, then the module will produce an error message instead of its usual output, as it ''cannot'' then produce valid output. You can solve this error by providing appropriate parameters to <var>_formatLink</var>, or you may want to ensure that a more descriptive error is provided by a downstream template or module when it would otherwise call <var>_formatLink</var> with inadequate arguments. <includeonly>{{Sandbox other|| <!-- Categories below this line; interwikis at Wikidata --> }}</includeonly>
བཅུད་དོན།:
By saving changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
ཆ་མེད་གཏང་།
ཞུན་དག་གྲོགས་རམ།
(ཝིན་ཌོ་གསརཔ་ནང་ ཁ་ཕྱེཝ་ཨིན།)
Preview page with this template
ཤོག་ལེབ་འདི་གུ་ལག་ལེན་འཐབ་ཡོད་པའི་ཊེམ་པེལེཊི:
Template:Code
(
edit
)
Template:Format link
(
edit
)
Template:Lua
(
edit
)
Template:Nowrap
(
edit
)
Template:Sandbox other
(
edit
)
Template:Template link
(
edit
)
Template:Tl
(
edit
)
Template:Used in system
(
edit
)
Module:Arguments
(
edit
)
Module:Format link
(
edit
)
Module:High-use
(
edit
)
Module:List
(
edit
)
Module:Lua banner
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:String
(
edit
)
Module:TableTools
(
edit
)
Module:Transclusion count
(
edit
)
Module:Transclusion count/data/F
(
edit
)
Module:Yesno
(
edit
)
འཚོལ་ཞིབ།
འཚོལ་ཞིབ།
Module:Format link/doc
ཞུན་དག་འབད་དོ།
Add languages
Add topic