Difference between revisions of "Template:Delink/doc"

From blackwiki
Jump to navigation Jump to search
test>PrimeHunter
(Undid revision 855399021 by 2605:E000:7F58:9100:8CA6:34:4A7D:8BB3 (talk))
m (12 revisions imported)
 
(5 intermediate revisions by 5 users not shown)
Line 3: Line 3:
 
<!-- Categories go at the bottom of this page and interwikis go in Wikidata. -->
 
<!-- Categories go at the bottom of this page and interwikis go in Wikidata. -->
  
{{High-risk|800,000+ pages, which is 2% of all}}
+
{{High-use|800,000+|all-pages=yes}}
  
This template removes links from wikitext. It de-links wikilinks, URL links, removes HTML comments, and normalises whitespace. It handles most wikitext correctly, including category links, the [[Help:Colon trick|colon trick]], the [[Help:Pipe trick|pipe trick]] (normal and reverse), nested wikilinks, and invalid link characters.
+
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 [[Help:Colon trick|colon trick]], the [[Help:Pipe trick|pipe trick]] (normal and reverse), nested wikilinks, and invalid link characters.
 
 
== Usage ==
 
  
 +
==Usage==
 
; Basic
 
; Basic
  
Line 17: Line 16:
 
<pre>
 
<pre>
 
{{delink
 
{{delink
| 1          =  
+
| 1          =
 
| wikilinks  = no
 
| wikilinks  = no
 
| urls      = no
 
| urls      = no
Line 26: Line 25:
 
</pre>
 
</pre>
  
== Parameters ==
+
==Parameters==
  
* <code>1</code> - the text to be de-linked.
+
*<code>1</code> - the text to be de-linked.
* <code>wikilinks</code> - if set to "no", "n", "false", or "0", wikilinks are not de-linked.
+
*<code>wikilinks</code> - if set to "no", "n", "false", or "0", wikilinks are not de-linked.
* <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.
* <code>whitespace</code> - 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 new lines are converted to a single space, but double new lines are left alone.  
+
*<code>whitespace</code> - 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.
* <code>refs</code> - (experimental) if set to "yes", "y", "true", or "1", removes references. This is not recommended, as only the <sup>[1]</sup>, <sup>[2]</sup>, 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.
+
*<code>refs</code> - (experimental) if set to "yes", "y", "true", or "1", removes references. This is not recommended, as only the <sup>[1]</sup>, <sup>[2]</sup>, 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 ==
 
  
 +
==Examples==
 
{| class="wikitable"
 
{| class="wikitable"
 
! Code
 
! Code
Line 44: Line 42:
 
| {{delink|[[Foo]]}}
 
| {{delink|[[Foo]]}}
 
|-
 
|-
| <code><nowiki>{{delink|[[Foo]], [[bar]] and [[baz]].}}</nowiki></code>
+
| <code><nowiki>{{delink|[[Foo|Bar]]}}</nowiki></code>
| {{delink|[[Foo]], [[bar]] and [[baz]].}}
+
| {{delink|[[Foo|Bar]]}}
 +
|-
 +
| <code><nowiki>{{delink|[[Foo]], [[bar]], and [[baz]].}}</nowiki></code>
 +
| {{delink|[[Foo]], [[bar]], and [[baz]].}}
 +
|-
 +
| <code><nowiki>{{delink|I visited [https://www.example.com example.com].}}</nowiki></code>
 +
| {{delink|I visited [https://www.example.com example.com].}}
 
|-
 
|-
| <code><nowiki>{{delink|I visited [http://www.example.com example.com].}}</nowiki></code>
+
| <code><nowiki>{{delink|Foo}}</nowiki></code>
| {{delink|I visited [http://www.example.com example.com].}}
+
| {{delink|Foo}}
 
|}
 
|}
 
+
<!-- not blank -->
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
 
<!-- Categories go here and interwikis go in Wikidata. -->
 
<!-- Categories go here and interwikis go in Wikidata. -->
  
 
}}</includeonly>
 
}}</includeonly>
 +
 +
==Non-examples==
 +
{| class="wikitable"
 +
! Code
 +
! Output
 +
|-
 +
| <code><nowiki>{{delink|https://www.example.com}}</nowiki></code>
 +
| {{delink|https://www.example.com}}
 +
|}
  
 
==See also==
 
==See also==
 
*{{tl|trim brackets}}
 
*{{tl|trim brackets}}
 
*{{tl|delink question hyphen-minus}}
 
*{{tl|delink question hyphen-minus}}
{{String-handling templates |delink}}
+
 
 +
{{String-handling templates|delink}}

Latest revision as of 07:50, 6 September 2020

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.
  • 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]], 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

See also