The dom.tex module

Elements needed for Latex documents.

Note

This module does not create DOM nodes for all Latex content.

You can build a full Latex document from scratch using the available nodes, but parce supports much more syntax than makes sense to build DOM nodes for.

LilyPond music is always in a lily.Document nodes, and can occur in a braced command or an environment.

class Document(*children, **attrs)[source]

Bases: Document

A full LaTeX source document.

space_between = ''

whitespace between children

class Option(*children, **attrs)[source]

Bases: BlockElement

An option block: [].

head = '['
tail = ']'
class Brace(*children, **attrs)[source]

Bases: BlockElement

A braced expression: {}.

head = '{'
tail = '}'
class Math(*children, **attrs)[source]

Bases: BlockElement

Abstract Math block. Subclasses define the start/end delimiters.

class MathInlineParen(*children, **attrs)[source]

Bases: Math

Inline math \(...\).

head = '\\('
tail = '\\)'
class MathInlineDollar(*children, **attrs)[source]

Bases: Math

Inline math $...$.

head = '$'
tail = '$'
class MathDisplayBracket(*children, **attrs)[source]

Bases: Math

Display math \[...\].

head = '\\['
tail = '\\]'
class MathDisplayDollar(*children, **attrs)[source]

Bases: Math

Display math $$...$$ (discouraged).

head = '$$'
tail = '$$'
class Command(head, *children, **attrs)[source]

Bases: BackslashCommand

A backslash-prefixed command.

The backslash is not in the head value, but added on write().

Arguments may be appended as children.

class Text(head, *children, **attrs)[source]

Bases: TextElement

Common text.

class Environment(*children, **attrs)[source]

Bases: Element

A LaTeX environment.

Starts with a Command \begin, with zero or more Option nodes, then an EnvironmentName; then the contents, and finally an \end Command with and again an EnvironmentName().

space_before = '\n'

whitespace before this element

space_after = '\n'

whitespace after this element

classmethod with_name(name, *children, **kwargs)[source]

Convenience method to create an Environment.

Zero or more child nodes can be specified, and keyboard arguments are given to the constructor.

class EnvironmentName(head, *children, **attrs)[source]

Bases: TextElement

The name of an environment.

The name is in the head value, the braces are added on write().

classmethod read_head(origin)[source]

Return the value as computed from the specified origin Tokens.

The default implementation concatenates the text from all tokens.

write_head()[source]

Return the textual output that represents our head value.

The default implementation just returns the head attribute, assuming it is text.

class Comment(head, *children, **attrs)[source]

Bases: SinglelineComment

A singleline comment after %.

space_after = '\n'

whitespace after this element

classmethod read_head(origin)[source]

Return the value as computed from the specified origin Tokens.

The default implementation concatenates the text from all tokens.

write_head()[source]

Return the textual output that represents our head value.

The default implementation just returns the head attribute, assuming it is text.