module documentation

Convert LaTex maths code into presentational MathML.

This module is provisional: the API is not settled and may change with any minor Docutils version.

Class math Base class for MathML elements and root of MathML trees.
Class ​Math​Row​Schema Base class for elements treating content as a single inferred mrow.
Class ​Math​Schema Base class for schemata expecting 2 or more children.
Class ​Math​Token Token Element: contains textual data instead of children.
Class menclose Undocumented
Class mfrac Undocumented
Class mi Undocumented
Class mn Undocumented
Class mo Undocumented
Class mover Undocumented
Class mphantom Undocumented
Class mroot Undocumented
Class mrow Group sub-expressions as a horizontal row.
Class mspace Undocumented
Class msqrt Undocumented
Class mstyle Undocumented
Class msub Undocumented
Class msubsup Undocumented
Class msup Undocumented
Class mtable Undocumented
Class mtd Undocumented
Class mtext Undocumented
Class mtr Undocumented
Class munder Undocumented
Class munderover Undocumented
Function align​_attributes Undocumented
Function begin​_environment Undocumented
Function end​_environment Undocumented
Function handle​_cmd Process LaTeX command name followed by string.
Function handle​_script​_or​_limit Append script or limit element to node.
Function parse​_latex​_math Append MathML conversion of string to node and return it.
Function tex2mathml Return string with MathML code corresponding to tex_math.
Function tex​_cmdname Return leading TeX command name and remainder of string.
Function tex​_equation​_columns Undocumented
Function tex​_group Return first TeX group or token and remainder of string.
Function tex​_number Return leading number literal and remainder of string.
Function tex​_optarg Return optional argument and remainder.
Function tex​_token Return first simple TeX token and remainder of string.
Function tex​_token​_or​_group Return first TeX group or token and remainder of string.
Variable accents Undocumented
Variable anomalous​_chars Undocumented
Variable bigdelimiters Undocumented
Variable delimiter​_sizes Undocumented
Variable fractions Undocumented
Variable functions Undocumented
Variable greek​_capitals Undocumented
Variable layout​_styles Undocumented
Variable math​_alphabets Undocumented
Variable mathbb Undocumented
Variable matrices Undocumented
Variable movablelimits Undocumented
Variable operators Undocumented
Variable over Undocumented
Variable small​_operators Undocumented
Variable spaces Undocumented
Variable stretchables Undocumented
Variable thick​_operators Undocumented
Variable under Undocumented
def align_attributes(rows):

Undocumented

def begin_environment(node, string):

Undocumented

def end_environment(node, string):

Undocumented

def handle_cmd(name, node, string):

Process LaTeX command name followed by string.

Append result to node. If needed, parse string for command argument. Return new current node and remainder of string:

>>> handle_cmd('hbar', math(), r'  rac')
(math(mi('ℏ')), ' \frac')
>>> handle_cmd('hspace', math(), r'{1ex} (x)')
(math(mspace(width='1ex')), ' (x)')
def handle_script_or_limit(node, c, limits=''):
Append script or limit element to node.
def parse_latex_math(node, string):

Append MathML conversion of string to node and return it.

>>> parse_latex_math(math(), r'\x07lpha')
math(mi('α'))
>>> parse_latex_math(mrow(), r'x_{n}')
mrow(msub(mi('x'), mi('n')))
def tex2mathml(tex_math, inline=True):

Return string with MathML code corresponding to tex_math.

Set inline to False for displayed math.

def tex_cmdname(string):

Return leading TeX command name and remainder of string.

>>> tex_cmdname('mymacro2') # up to first non-letter
('mymacro', '2')
>>> tex_cmdname('name 2') # strip trailing whitespace
('name', '2')
>>> tex_cmdname('_2') # single non-letter character
('_', '2')
def tex_equation_columns(rows):

Undocumented

def tex_group(string):

Return first TeX group or token and remainder of string.

>>> tex_group('{first group} returned without brackets')
('first group', ' returned without brackets')
def tex_number(string):

Return leading number literal and remainder of string.

>>> tex_number('123.4')
('123.4', '')
def tex_optarg(string):

Return optional argument and remainder.

>>> tex_optarg('[optional argument] returned without brackets')
('optional argument', ' returned without brackets')
>>> tex_optarg('{empty string, if there is no optional arg}')
('', '{empty string, if there is no optional arg}')
def tex_token(string):

Return first simple TeX token and remainder of string.

>>> tex_token('\command{without argument}')
('\command', '{without argument}')
>>> tex_token('or first character')
('o', 'r first character')
def tex_token_or_group(string):

Return first TeX group or token and remainder of string.

>>> tex_token_or_group('\command{without argument}')
('\command', '{without argument}')
>>> tex_token_or_group('first character')
('f', 'irst character')
>>> tex_token_or_group(' also whitespace')
(' ', 'also whitespace')
>>> tex_token_or_group('{first group} keep rest')
('first group', ' keep rest')
accents: dict =

Undocumented

anomalous_chars: dict[str, str] =

Undocumented

bigdelimiters: dict[str, int] =

Undocumented

delimiter_sizes: list[str] =

Undocumented

fractions =

Undocumented

functions: dict =

Undocumented

greek_capitals: dict[str, str] =

Undocumented

layout_styles: dict[str, dict] =

Undocumented

math_alphabets: dict[str, str] =

Undocumented

mathbb: dict[str, str] =

Undocumented

matrices: dict =

Undocumented

movablelimits: tuple[str, ...] =

Undocumented

operators: dict[str, str] =

Undocumented

over: dict[str, tuple] =

Undocumented

small_operators: dict[str, str] =

Undocumented

spaces: dict[str, str] =

Undocumented

stretchables: dict[str, str] =

Undocumented

thick_operators: dict[str, str] =

Undocumented

under: dict[str, tuple] =

Undocumented