More actions
Created page with "{{wikipedia|page name}} {{High-use}} {{cascade-protected template}} {{Documentation subpage}} {{lua|Module:Delink}} <!-- Categories go at the bottom of this page and interwikis go in Wikidata. --> This template removes links from wikitext. It de-links wikilinks and URL links, removes HTML comments, and normalises whitespace. It handles most wikitext correctly, including category links, the colon trick, the pipe trick (normal and..." |
No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{wikipedia|page name}} | {{wikipedia|page name}} | ||
{{cascade-protected template}} | {{cascade-protected template}} | ||
{{Documentation subpage}} | {{Documentation subpage}} | ||
| Line 7: | Line 6: | ||
This template removes links from wikitext. It de-links wikilinks and URL links, removes HTML comments, and normalises whitespace. It handles most wikitext correctly, including category links, the | This template removes links from wikitext. It de-links wikilinks and URL links, removes HTML comments, and normalises whitespace. It handles most wikitext correctly, including category links, the colon trick, the pipe trick (normal and reverse), nested wikilinks, and invalid link characters. | ||
==Usage== | ==Usage== | ||
| Line 30: | Line 29: | ||
*<code>wikilinks</code> | *<code>wikilinks</code> | ||
*: - if set to "no", "n", "false", or "0", wikilinks are not de-linked. | *: - if set to "no", "n", "false", or "0", wikilinks are not de-linked. | ||
*: - if set to "target", wikilinks are reduced to the target portion of a wikilink ( | *: - if set to "target", wikilinks are reduced to the target portion of a wikilink ( → {{samp|{{vr|{{var|target}}}}}}) | ||
*<code>urls</code> - if set to "no", "n", "false", or "0", URL links are not de-linked. | *<code>urls</code> - if set to "no", "n", "false", or "0", URL links are not de-linked. | ||
*<code>comments</code> - if set to "no", "n", "false", or "0", HTML comments are not removed. | *<code>comments</code> - if set to "no", "n", "false", or "0", HTML comments are not removed. | ||
| Line 42: | Line 41: | ||
|- | |- | ||
| <syntaxhighlight lang="wikitext" inline>{{delink|[[Foo]]}}</syntaxhighlight> | | <syntaxhighlight lang="wikitext" inline>{{delink|[[Foo]]}}</syntaxhighlight> | ||
| {{delink| | | {{delink|Foo}} | ||
|- | |- | ||
| <syntaxhighlight lang="wikitext" inline>{{delink|[[Foo|Bar]]}}</syntaxhighlight> | | <syntaxhighlight lang="wikitext" inline>{{delink|[[Foo|Bar]]}}</syntaxhighlight> | ||
| {{delink | | {{delink|Bar}} | ||
|- | |- | ||
| <syntaxhighlight lang="wikitext" inline>{{delink|[[Foo|Bar]]|wikilinks=target}}</syntaxhighlight> | | <syntaxhighlight lang="wikitext" inline>{{delink|[[Foo|Bar]]|wikilinks=target}}</syntaxhighlight> | ||
| {{delink | | {{delink|Bar|wikilinks=target}} | ||
|- | |- | ||
| <syntaxhighlight lang="wikitext" inline>{{delink|[[Foo]], [[bar]], and [[baz]].}}</syntaxhighlight> | | <syntaxhighlight lang="wikitext" inline>{{delink|[[Foo]], [[bar]], and [[baz]].}}</syntaxhighlight> | ||
| {{delink| | | {{delink|Foo, bar, and baz.}} | ||
|- | |- | ||
| <syntaxhighlight lang="wikitext" inline>{{delink|I visited [https://www.example.com example.com].}}</syntaxhighlight> | | <syntaxhighlight lang="wikitext" inline>{{delink|I visited [https://www.example.com example.com].}}</syntaxhighlight> | ||
| Line 69: | Line 68: | ||
|} | |} | ||
<includeonly>{{sandbox other|| | <includeonly>{{sandbox other|| | ||
<!-- Categories go here and interwikis go in Wikidata. --> | <!-- Categories go here and interwikis go in Wikidata. --> | ||
[[Category:String manipulation templates]] | [[Category:String manipulation templates]] | ||
}}</includeonly> | }}</includeonly> | ||
Latest revision as of 17:39, 9 April 2025
| This page uses Creative Commons Licensed content from Wikipedia (view authors). |
| This template can only be edited by administrators because it is transcluded onto one or more cascade-protected pages. |
| This is a documentation subpage for Template:Delink It may contain usage information, categories and other content that is not part of the original template page. |
| This template uses Lua: |
This template removes links from wikitext. It de-links wikilinks and URL links, removes HTML comments, and normalises whitespace. It handles most wikitext correctly, including category links, the colon trick, the pipe trick (normal and reverse), nested wikilinks, and invalid link characters.
Usage
- Basic
{{delink|text}}
- All parameters
{{delink | 1 = | wikilinks = no | urls = no | comments = no | whitespace = no | refs = yes }}
Parameters
1- the text to be de-linked.wikilinks- - if set to "no", "n", "false", or "0", wikilinks are not de-linked.
- - if set to "target", wikilinks are reduced to the target portion of a wikilink ( → Template:Vr)
urls- if set to "no", "n", "false", or "0", URL links are not de-linked.comments- if set to "no", "n", "false", or "0", HTML comments are not removed.whitespace- if set to "no", "n", "false", or "0", whitespace is not normalised. The normalisation makes the whitespace of the resulting text look as if it had been put through the MediaWiki parser. For example, single newlines are converted to a single space, but double newlines are left alone.refs- (experimental) if set to "yes", "y", "true", or "1", removes references. This is not recommended, as only the [1], [2], etc. markers will be removed - the references themselves will still appear at the end of the page. There is no known workaround for this problem as of April 2014.
Examples
| Code | Output |
|---|---|
{{delink|[[Foo]]}}
|
Foo |
{{delink|[[Foo|Bar]]}}
|
Bar |
{{delink|[[Foo|Bar]]|wikilinks=target}}
|
Bar |
{{delink|[[Foo]], [[bar]], and [[baz]].}}
|
Foo, bar, and baz. |
{{delink|I visited [https://www.example.com example.com].}}
|
I visited example.com. |
{{delink|Foo}}
|
Foo |
Non-examples
| Code | Output |
|---|---|
{{delink|https://www.example.com}}
|
https://www.example.com |