Parsers¶
Base Parser¶
- class mdiocre.parsers.BaseParser¶
This is the base class of which every MDiocre parser must be inheriting from. Even though this doesn’t do much at the moment…
- to_variables(text, v, ignore_content=False)¶
Converts a string to a
VariableManager
object. This should be reimplemented.- Parameters
text (string) – The source file from which to process and extract MDiocre commands from.
v (VariableManager) – The object to which the variables is processed and stored to.
- Returns
A
VariableManager
object.
HTML¶
- class mdiocre.parsers.html.HtmlParser¶
In HTML, MDiocre commands are HTML comments prefixed with
<!--:
.- to_variables(html, v, ignore_content=False)¶
Converts a string to a
VariableManager
object. This should be reimplemented.- Parameters
text (string) – The source file from which to process and extract MDiocre commands from.
v (VariableManager) – The object to which the variables is processed and stored to.
- Returns
A
VariableManager
object.
Markdown¶
- class mdiocre.parsers.markdown.MarkdownParser¶
In Markdown, MDiocre commands are HTML comments prefixed with
<!--:
.- to_variables(markdown, v, ignore_content=False)¶
Converts a string to a
VariableManager
object. This should be reimplemented.- Parameters
text (string) – The source file from which to process and extract MDiocre commands from.
v (VariableManager) – The object to which the variables is processed and stored to.
- Returns
A
VariableManager
object.
ReStructuredText¶
- class mdiocre.parsers.rst.RstParser¶
In ReStructuredText, MDiocre commands are its’ own RST role, “mdiocre”.
- to_variables(markup, v, ignore_content=False)¶
Converts a string to a
VariableManager
object. This should be reimplemented.- Parameters
text (string) – The source file from which to process and extract MDiocre commands from.
v (VariableManager) – The object to which the variables is processed and stored to.
- Returns
A
VariableManager
object.
Helper Functions¶
- mdiocre.parsers.sub_func(match, v)¶
Substitution function for use with re.sub.
- Parameters
match (re.Match) – object containing the string to be processed.
v (VariableManager) – target variable manager object
- Returns
If the string is in the form variable = something, it will return a blank string, but stores the new value within v.variables. Otherwise, it attempts to display the value of the variable described, by running it through
VariableManager.get()
.