Content deleted Content added
Sophivorus (talk | contribs) No edit summary |
Sophivorus (talk | contribs) |
||
(11 intermediate revisions by the same user not shown) | |||
Line 1:
{{Module rating|alpha}}
This module is a general-purpose wikitext parser. It's designed to be used by other Lua modules and
== Usage ==
Line 39:
==== getSection ====
<code>getSection( wikitext,
Returns the content of the section with the given section 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,
Returns the contents of the <nowiki><section></nowiki> tag with the given tag name (see [[Help:Labeled section transclusion]]). If the tag is not found, nil will be returned.
==== getLists ====
Line 53:
<code>getLists( wikitext )</code>
Returns a table with each value being a list (ordered or unordered).
==== getParagraphs ====
<code>getParagraphs( wikitext )</code>
Returns a table with each value being a paragraph. Paragraphs are defined as block-level elements that are not lists, templates, files, categories, tables or section titles.
==== getTemplates ====
<code>getTemplates( wikitext )</code>
Returns a table with each value being a template.
==== getTemplate ====
<code>getTemplate( wikitext, templateName )</code>
Returns the template with the given template name.
==== getTemplateName ====
<code>getTemplateName( templateWikitext )</code>
Returns the name of the given template. If the given wikitext is not recognized as that of a template, nil will be returned.
==== getTemplateParameters ====
<code>getTemplateParameters( templateWikitext )</code>
Returns a table with the parameter names as keys and the parameter values as values. For unnamed parameters, the keys are numerical. If the given wikitext is not recognized as that of a template, nil will be returned.
==== getTags ====
<code>getTags( wikitext )</code>
Returns a table with each value being a tag and its contents (like <nowiki><div></nowiki>, <nowiki><gallery></nowiki>, <nowiki><ref></nowiki>, <nowiki><noinclude></nowiki>). Tags inside tags will be ignored. If you're interested in getting them, run this method again for each of the returned tags.
==== getTagName ====
<code>getTagName( tagWikitext )</code>
Returns the name of the tag in the given wikitext. For example 'div', 'span', 'gallery', 'ref', etc.
==== getTagAttribute ====
<code>getTagAttribute( tagWikitext, attribute )</code>
Returns the value of an attribute in the given tag. For example the id of a div or the name of a reference.
==== getGalleries ====
<code>getGalleries( wikitext )</code>
Returns a table with each value being a gallery.
==== getReferences ====
<code>getReferences( wikitext )</code>
Returns a table with each value being a reference. This includes self-closing references (like <nowiki><ref name="foo" /></nowiki>) as well as full references.
==== getTables ====
<code>getTables( wikitext )</code>
Returns a table with each value being a wiki table.
==== getTableAttribute ====
<code>getTableAttribute( tableWikitext, attribute )</code>
Returns the value of an attribute in the given wiki table. For example the id or the class.
==== getTable ====
<code>getTable( wikitext, id )</code>
Returns the wiki table with the given id. If not found, nil will be returned.
==== getTableData ====
<code>getTableData( tableWikitext )</code>
Returns a Lua table representing the data of the given wiki table.
==== getLinks ====
<code>getLinks( wikitext )</code>
Returns a Lua table with each value being a wiki link. For external links, use [[#getExternalLinks|getExternalLinks]] instead.
==== getFileLinks ====
<code>getFileLinks( wikitext )</code>
Returns a Lua table with each value being a file link.
==== getFileName ====
<code>getFileName( fileWikitext )</code>
Returns the name of the given template. If the given wikitext is not recognized as that of a file, nil will be returned.
==== getCategories ====
<code>getCategories( wikitext )</code>
Returns a Lua table with each value being a category link.
==== getExternalLinks ====
<code>getExternalLinks( wikitext )</code>
Returns a Lua table with each value being an external link. For internal links, use [[#getLinks|getLinks]] instead.
== See also ==
|