Module:WikitextParser/doc: Difference between revisions

Content deleted Content added
No edit summary
 
(8 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 cannotshouldn't be called directly by templates.
 
== Usage ==
Line 84:
 
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 ==