class lira.parsers.BaseParser(content: str, source: pathlib.Path = None)

Base class for a parser.

The parser should parse the metadata from the file as a dictionary, and the content should be a list of nodes that subclass lira.parsers.nodes.Node.

  • content – Content to parse

  • source – Source file of the content

class lira.parsers.rst.RSTParser(*args, **kwargs)

reStructuredText parser for lira, powered by docutils.


class lira.parsers.nodes.Node(content=None, *, children=None, attributes=None)

Base class for a node.

  • content – Content for this node (usually only for terminal nodes).

  • children – List of children.

  • attributes – Dictionary of valid attributes.

If it’s a terminal node, it doesn’t have children. Only attributes from valid_attributes are recognized.

is_terminal = False

If it’s a terminal node (without children)

valid_attributes = {}

A set of valid attributes for this node.


Raw content of the node


List of children of this node.


Named tuple with the attributes for this node


Parent node


Reset attributes and content of the node to their initial values.


Text representation of the node.

property tagname

Name of the node.

class lira.parsers.nodes.Paragraph(content=None, *, children=None, attributes=None)

Container for inline nodes.

Inline nodes are:

class lira.parsers.nodes.Text(content=None, *, children=None, attributes=None)

Plain text node.

class lira.parsers.nodes.Strong(content=None, *, children=None, attributes=None)

Text represented as bold.

class lira.parsers.nodes.Emphasis(content=None, *, children=None, attributes=None)

Text represented as italics.

class lira.parsers.nodes.Literal(content=None, *, children=None, attributes=None)

Text represented with a mono space font.

class lira.parsers.nodes.Section(content=None, *, children=None, attributes=None)

Section representation.


  • title

Children can be any of:

class lira.parsers.nodes.Admonition(content=None, *, children=None, attributes=None)

Text inside a box, usually to give a warning or a note to the user.


  • title: The title of the admonition, defaults to type.

  • type: one of note, warning, or tip.

Children can be any of:

class lira.parsers.nodes.CodeBlock(content=None, *, children=None, attributes=None)

Syntax highlighted block.

The content of this node should be a list of lines.


  • language

class lira.parsers.nodes.TestBlock(*args, **kwargs)

Challenge/response block to interact with the user.



Run the validator for this node.

class lira.parsers.nodes.Prompt(content=None, *, children=None, attributes=None)