Template:Encodefirst: Difference between revisions
MusikAnimal (talk | contribs) m Changed protection settings for "Template:Encodefirst": Highly visible template ([Edit=Require template editor access] (indefinite)) |
Swap out nested string functions for Module:MultiReplace, which is quicker. Maintains the behaviour of trimming the input string. |
||
Line 1: | Line 1: | ||
{{# |
{{#invoke:MultiReplace|main|1={{{1}}}|2=^:|3=:|4=^;|5=;|6=^*|7=*|8=^#|9=#}}<noinclude> |
||
{{Documentation}} |
{{Documentation}} |
||
</noinclude> |
</noinclude> |
Latest revision as of 18:26, 4 October 2021
{{{1}}}
![]() | This template is used on approximately 730,000 pages, or roughly 1% of all pages. To avoid major disruption and server load, any changes should be tested in the template's /sandbox or /testcases subpages, or in your own user subpage. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
This template replaces the first character of the argument with its HTML entity if it is one of four wiki markup characters :
;
*
#
. This can sometimes fix the issue at Help:Template#Problems and workarounds where a character may be processed as though it were at the beginning of a line.
Usage
{{Encodefirst|<string>}}
Examples
The output looks like the input whether a character is replaced or not.
{{Encodefirst|*Lisp}}
produces: *Lisp
But the output will behave differently from the input in some situations where it is processed. For example, {{la}} fails as of August 2017 if its argument starts with *
.
{{la|*Lisp}}
causes the asterisk to be processed as list markup and produces broken display.
{{la|{{Encodefirst|*Lisp}}}}
works correctly:
*Lisp (edit | talk | history | protect | delete | links | watch | logs | views)