Module:WikitextParser/doc: Difference between revisions

Content deleted Content added
Usage: Add methods
No edit summary
Line 25:
== Methods ==
 
==== getLead ====
* <code>getLead( wikitext )</code> — Returns the lead section from the given wikitext. The lead section is defined as everything before the first section title. If there's no lead section, an empty string will be returned.
* <code>getSections( wikitext )</code> — Returns a Lua table with the section titles as keys and the section contents as values. This method doesn't get the lead section (use getLead for that).
* <code>getSection( wikitext, title )</code> — Returns the content of the section with the given title, including subsections. If you don't want subsections, use getSections instead. If the given section title appears more than once, only the first will be returned. If the section is not found, nil will be returned.
* <code>getSectionTag( wikitext, name )</code> — Returns the contents of the <nowiki><section></nowiki> tag with the given name (see [[Help:Labeled section transclusion]]). If the tag is not found, nil will be returned.
* <code>getLists( wikitext )</code> — Returns a sequence of lists, that is, a Lua table with each entry a list.
 
<code>getLead( wikitext )</code>
For the ultimate documentation, see the source code below.
 
* <code>getLead( wikitext )</code> — Returns the lead section from the given wikitext. The lead section is defined as everything before the first section title. If there's no lead section, an empty string will be returned.
 
==== getSections ====
 
<code>getSections( wikitext )</code>
 
* <code>getSections( wikitext )</code> — Returns a Lua table with the section titles as keys and the section contents as values. This method doesn't get the lead section (use [[#getLead|getLead]] for that).
 
==== getSection ====
 
<code>getSection( wikitext, title )</code>
 
* <code>getSection( wikitext, title )</code> — Returns the content of the section with the given title, including subsections. If you don't want subsections, use [[#getSections|getSections]] instead. If the given section title appears more than once, only the first will be returned. If the section is not found, nil will be returned.
 
==== getSectionTag ====
 
<code>getSectionTag( wikitext, name )</code>
 
* <code>getSectionTag( wikitext, name )</code> — Returns the contents of the <nowiki><section></nowiki> tag with the given name (see [[Help:Labeled section transclusion]]). If the tag is not found, nil will be returned.
 
==== getLists ====
 
<code>getLists( wikitext )</code>
 
Returns a table with each value a list.
 
== See also ==