Module:HTMLParse/doc: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 37: | Line 37: | ||
== strip_formatting == | == strip_formatting == | ||
Strips HTML tags from the input string. For example, < | 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: | ||
Line 45: | Line 45: | ||
Result: | Result: | ||
{{#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> }} | {{#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>}} | ||
<includeonly> | <includeonly> | ||
<!-- Template categories/interwiki here --> | <!-- Template categories/interwiki here --> |
Revision as of 19:56, 4 September 2019
Documentation
[purge]
This module parses and manipulates HTML strings.
There is currently 3 functions:
- pluralize
- make_possessive
- strip_formatting
pluralize
Pluralizes an HTML string by inserting an "s" between the final alphabetic character and closing tag </
For example, <span>book</span>
becomes <span>books</span>
.
Notes:
- Won't pluralize anything that already ends in "s".
- Won't pluralize anything that doesn't lua pattern match
%a</
- If passing a template that uses a cargo query as the html parameter, be sure that the cargo query is marked with
no html
or this Module might not be able to expand the template correctly.
Usage
{{#invoke: HTMLParse | pluralize | html = (html string here) }}
Examples
wikitext | result |
---|---|
{{#invoke: HTMLParse | pluralize | html = {{Qud text|&Cultra-light &brobot| notxml }} }}
|
ultra-light robots |
{{#invoke: HTMLParse | pluralize | html = <span style="color:red">big </span><span style="color:blue">book</span> }}
|
big books |
make_possessive
Identical to pluralize
except that instead of inserting an s
, make_possessive inserts an 's
strip_formatting
Strips HTML tags from the input string. For example, <span style="color:red;">help!</span>
becomes help!
.
Example:
{{#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> }}
Result:
crayons