Module:HTMLParse/doc: Difference between revisions

369 bytes added ,  02:47, 5 January 2021
document capitalize
mNo edit summary
(document capitalize)
 
(2 intermediate revisions by one other user not shown)
Line 3: Line 3:
This module parses and manipulates HTML strings.
This module parses and manipulates HTML strings.


There is currently 3 functions:
There is currently 4 functions:
* pluralize
* pluralize
* make_possessive
* make_possessive
* strip_formatting
* strip_formatting
* capitalize




Line 37: Line 38:


== strip_formatting ==
== strip_formatting ==
Strips HTML tags from the input string. For example, <pre><span style="color:red;">help!</span></pre> becomes <pre>help!</pre>
Strips HTML tags from the input string. For example, <code><nowiki><span style="color:red;">help!</span></nowiki></code> becomes <code>help!</code>.


Example:
Example:


<pre>{{#invoke: HTMLParse | make_possessive | html = <span style="color: #d74200;">c</span><span style="color: #cfc041;">r</span><span style="color: #00c420;">a</span><span style="color: #0096ff;">y</span><span style="color: #da5bd6;">o</span><span style="color: #77bfcf;">n</span><span style="color: #FFFFFF;">s</span> }}</pre>
<pre>{{#invoke: HTMLParse | strip_formatting | html = <span style="color: #d74200;">c</span><span style="color: #cfc041;">r</span><span style="color: #00c420;">a</span><span style="color: #0096ff;">y</span><span style="color: #da5bd6;">o</span><span style="color: #77bfcf;">n</span><span style="color: #FFFFFF;">s</span> }}</pre>


Result:
Result:


{{#invoke: HTMLParse | make_possessive | html = <span style="color: #d74200;">c</span><span style="color: #cfc041;">r</span><span style="color: #00c420;">a</span><span style="color: #0096ff;">y</span><span style="color: #da5bd6;">o</span><span style="color: #77bfcf;">n</span><span style="color: #FFFFFF;">s</span> }}
{{#invoke: HTMLParse|strip_formatting|html=<span style="color: #d74200;">c</span><span style="color: #cfc041;">r</span><span style="color: #00c420;">a</span><span style="color: #0096ff;">y</span><span style="color: #da5bd6;">o</span><span style="color: #77bfcf;">n</span><span style="color: #FFFFFF;">s</span>}}
 
== capitalize ==
Capitalizes the word while preserving HTML formatting. It only takes one argument.
<pre><nowiki>{{#invoke: HTMLParse | capitalize | html = {{qud text|&Cbrinestalk &Gstalks}} }}</nowiki></pre>
{{qud text|&Cbrinestalk &Gstalks}} turns into:
{{#invoke: HTMLParse | capitalize | html = {{qud text|&Cbrinestalk &Gstalks}} }}
<includeonly>
<includeonly>
<!-- Template categories/interwiki here -->
<!-- Template categories/interwiki here -->