Module:HTMLParse/doc: Difference between revisions

From Caves of Qud Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 18: Line 18:
<nowiki>{{#invoke: HTMLParse | pluralize | html = (html string here) }}</nowiki>
<nowiki>{{#invoke: HTMLParse | pluralize | html = (html string here) }}</nowiki>
===Examples===
===Examples===
{| class="wikitable" |
{| class="wikitable"
|<nowiki>{{#invoke: HTMLParse | pluralize | html = {{favilink | antimatter cell}} }}</nowiki>
!style="padding:10px;text-align:left;"|wikitext
|{{#invoke: HTMLParse | pluralize | html = {{favilink | antimatter cell}} }}
!style="padding:10px;text-align:left;"|result
|-
|-
|<nowiki>{{#invoke: HTMLParse | pluralize | html = <span style="color:red">big </span><span style="color:blue">book</span> }}</nowiki>
|style="padding:10px;"|<syntaxhighlight lang="html">{{#invoke: HTMLParse | pluralize | html = {{Qud text|&Cultra-light &brobot| notxml }} }}</syntaxhighlight>
|{{#invoke: HTMLParse | pluralize | html = <span style="color:red">big </span><span style="color:green">book</span> }}
|style="padding:10px;"|{{#invoke: HTMLParse | pluralize | html = {{Qud text|&Cultra-light &brobot| notxml }} }}
|-
|style="padding:10px;"|<syntaxhighlight lang="html">{{#invoke: HTMLParse | pluralize | html = <span style="color:red">big </span><span style="color:blue">book</span> }}</syntaxhighlight>
|style="padding:10px;"|{{#invoke: HTMLParse | pluralize | html = <span style="color:red">big </span><span style="color:green">book</span> }}
|-
|-
|}
|}

Revision as of 20:20, 20 August 2019

Template-info.png Documentation

This module parses and manipulates HTML strings.

There is currently only 1 function:

  • pluralize


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</

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