The lang.latex module

LaTeX language and transformation definition.

class Latex[source]

Bases: Latex

Latex language definition.

classmethod get_environment_target(name)[source]

Return environment target for environment name.

Can be overridden to support special environments.

classmethod common()[source]
option = Latex.option
test_lilypond_option = Latex.test_lilypond_option
class LatexTransform[source]

Bases: Transform

Transform Latex quickly.dom.


Process the root context.


Process the brace context; returns a Brace node.


Process the option context.

Returns a two-tuple(options, head_origin).

The options is a list of objects that are finished Option nodes, only the first might be incomplete because of a missing opening token. In that case the first object is a tuple (contents, tail_origin). (The tail_origin might be empty in the case of an imcomplete source text).

The head_origin is normally empty, only for the \lilypond[opts]{ command, it is the brace that starts the braced expression.


Process the environment_option context.

Returns a tuple(option, envname), where option is a list like the first value returned by option() and envname an EnvironmentName node it it was there at the end of the options list, otherwise None.


Process the environment_math context.


Process the environment context.

Returns a list of nodes, the last is the \end command.


Process the math context; return a Math node.


Process the comment context.

test_lilypond_option = None

Compose and yield Latex nodes; used in most contexts.

class LatexAdHocTransform[source]

Bases: AdHocTransform, LatexTransform

LatexTransform that does not keep the origin tokens.