The core converter.
Main class to process Markdown source files and render HTML files.
parser (Optional) – a BaseParser-derived object. If both parser_name and parser are defined, parser takes the priority.
parser_name (Optional) – The parser name. See
switch_parser()for which ones are currently implemented.
Process a string into a variable dictionary to use e.g. with
The string is processed according to a parser that converts it to HTML and extracts any MDiocre “commands”. For Markdown and HTML, these are stuff that is prefixed with <!–:, for RST, it’s :mdiocre:.
More details about the conversion process can be found in
As of 3.1, this is really a wrapper for all the parsers.
string (string) – A string containing MDiocre commands.
ignore_content (bool, Optional) – If True, it will not convert the string to the content variable.
A VariableManager object containing the processed variables, that also contains the converted HTML under the
contentvariable, if ignore_content is False.
Renders a template with the specified variables.
Due to the mechanism, template variables are separate from the page’s variables. The converted page is defined in the
contentvariable, and can be used by templates to render the documents.
template (string) – A string containing formatted comments.
variables (VariableManager) – Variable object to use with the template.
The processed string.
Switch parsers by using an identifier. To implement a new parser, it must be a class with inherited from
BaseParser, Its name and file name must also match, e.g. a parser with the html identifier must be in html.py and have the class name of HtmlParser.
name (string) – Parser name. Currently implemented: markdown, html, rst
This stores information that can be set and or replaced in a text.
Variables are stored as a dictionary under self.variables. The identifiers can be any character except the = operator, which serves to separate the identifier and the value.
- There are a few reserved variables, which their names cannot be used, namely:
content : The contents of a page that will be put into a template
mdiocre-gen-timestamp : Timestamp of the generated content
mdiocre-templatevariable is required when using the
Assigns a variable to a value.
The variable name has almost no limitations (especially not limitations usually posed by a programming language), but it is terminated by the = symbol.
- The value can be one of the following:
- Stringif the value has quotes (single or double) around it.
My Variable = "Toast"
- Concatenationif two or more variable names are specified, with a comma separating each.
My Variable = Var 1, Var 2
- Math expressionif the value is in the form of a simple math expression e.g. 1 * 2 + 3
My Variable = 1 + 4 * 7 + 4 * 0
Value assignment : if the value is a variable name. This is assumed to be the default. Will assign to an empty string if the variable is not found.
My Variable = Something else
query (string) – Expects a string in the form of
variable = value.
None (or SyntaxError). If the variable is successfully assigned, its value will be added to the object’s
Gets a variable from the variables list and returns its value.
variable (string) – Name of the variable.
String contents of the variable, or an empty string if the variable is not found.