pylatexenc Package¶
latex2text
Module¶
-
core.pylatexenc.latex2text.
latex2text
(content, tolerant_parsing=False, keep_inline_math=False, keep_comments=False)[source]¶ Extracts text from content meant for database indexing. content is some LaTeX code.
latexencode
Module¶
latexwalker
Module¶
-
class
core.pylatexenc.latexwalker.
LatexCharsNode
(chars, **kwargs)[source]¶ Bases:
core.pylatexenc.latexwalker.LatexNode
A string of characters in the LaTeX document, without any special meaning.
-
class
core.pylatexenc.latexwalker.
LatexEnvironmentNode
(envname, nodelist, optargs=[], args=[], **kwargs)[source]¶
-
class
core.pylatexenc.latexwalker.
LatexGroupNode
(nodelist, **kwargs)[source]¶ Bases:
core.pylatexenc.latexwalker.LatexNode
A LaTeX group, i.e. {...}.
-
class
core.pylatexenc.latexwalker.
LatexMacroNode
(macroname, nodeoptarg=None, nodeargs=[], **kwargs)[source]¶ Bases:
core.pylatexenc.latexwalker.LatexNode
Represents a ‘macro’ type node, e.g. ‘textbf’
-
class
core.pylatexenc.latexwalker.
LatexNode
(**kwargs)[source]¶ Bases:
object
Represents an abstract ‘node’ of the latex document.
Use
nodeType()
to figure out what type of node this is.
-
class
core.pylatexenc.latexwalker.
LatexToken
(tok, arg, pos, len, pre_space)¶ Bases:
tuple
-
arg
¶ Alias for field number 1
-
len
¶ Alias for field number 3
-
pos
¶ Alias for field number 2
-
pre_space
¶ Alias for field number 4
-
tok
¶ Alias for field number 0
-
-
class
core.pylatexenc.latexwalker.
MacrosDef
(macname, optarg, numargs)¶ Bases:
tuple
-
macname
¶ Alias for field number 0
-
numargs
¶ Alias for field number 2
-
optarg
¶ Alias for field number 1
-
-
core.pylatexenc.latexwalker.
get_latex_braced_group
(s, pos, brace_type='{', **parse_flags)[source]¶ Reads a latex expression enclosed in braces {...}. The first token of s[pos:] must be an opening brace.
Returns a tuple (node, pos, len). pos is the first char of the expression (which has to be an opening brace), and len is its length, including the closing brace.
-
core.pylatexenc.latexwalker.
get_latex_environment
(s, pos, environmentname=None, **parse_flags)[source]¶ Reads a latex expression enclosed in a begin{environment}...end{environment}. The first token in the stream must be the begin{environment}.
Returns a tuple (node, pos, len) with node being a
LatexEnvironmentNode
.
-
core.pylatexenc.latexwalker.
get_latex_expression
(s, pos, strict_braces=False, **parse_flags)[source]¶ Reads a latex expression, e.g. macro argument. This may be a single char, an escape sequence, or a expression placed in braces.
Returns a tuple (<LatexNode instance>, pos, len). pos is the first char of the expression, and len is its length.
-
core.pylatexenc.latexwalker.
get_latex_maybe_optional_arg
(s, pos, **parse_flags)[source]¶ Attempts to parse an optional argument. Returns a tuple (groupnode, pos, len) if success, otherwise returns None.
-
core.pylatexenc.latexwalker.
get_latex_nodes
(s, pos=0, stop_upon_closing_brace=None, stop_upon_end_environment=None, stop_upon_closing_mathmode=None, keep_inline_math=False, tolerant_parsing=False)[source]¶ Parses latex content s.
Returns a tuple (nodelist, pos, len) where nodelist is a list of LatexNode ‘s.
If stop_upon_closing_brace is given, then len includes the closing brace, but the closing brace is not included in any of the nodes in the nodelist.