Module:WikitextParser/doc: Difference between revisions

Content deleted Content added
mNo edit summary
Usage: Add methods
Line 13:
</syntaxhighlight>
 
Then, use and combine the available methods freely. For example:
 
<syntaxhighlight lang="lua">
Line 23:
</syntaxhighlight>
 
== Methods ==
Here's a list of available methods:
 
* <code>getLead( wikitext )</code> — Returns the lead section from the given wikitext. The lead section is defined as everything before the first section title. May be empty ifIf there's no lead section, an empty string will be returned.
* <code>getSections( wikitext )</code> — Returns the sections from the given wikitext, as a Lua table with the section titles as keys and the section contentcontents as values. This method doesn't get the lead section (use <code>getLead</code> 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 <code>getSections</code> instead. If the given section title appears more than once, only the first will be returned. If the section is not found, <code>nil</code> 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.
 
For the ultimate documentation, see the source code below.