LaTeX Codec
The latexcodec.codec module
contains all classes and functions for LaTeX code
translation. For practical use,
you should only ever need to import the latexcodec module,
which will automatically register the codec
so it can be used by str.encode(), str.decode(),
and any of the functions defined in the codecs module
such as codecs.open() and so on.
The other functions and classes
are exposed in case someone would want to extend them.
-
latexcodec.codec.register()[source]
Register the find_latex() codec search function.
-
latexcodec.codec.find_latex(encoding)[source]
Return a codecs.CodecInfo instance for the requested
LaTeX encoding, which must be equal to latex,
or to latex+<encoding>
where <encoding> describes another encoding.
-
class latexcodec.codec.LatexIncrementalEncoder(errors='strict')[source]
Bases: latexcodec.lexer.LatexIncrementalEncoder
Translating incremental encoder for latex. Maintains a state to
determine whether control spaces etc. need to be inserted.
-
get_space_bytes(bytes_)[source]
Inserts space bytes in space eating mode.
-
table = <latexcodec.codec.LatexUnicodeTable instance at 0x3f85290>
Translation table.
-
class latexcodec.codec.LatexIncrementalDecoder(errors='strict')[source]
Bases: latexcodec.lexer.LatexIncrementalDecoder
Translating incremental decoder for LaTeX.
-
table = <latexcodec.codec.LatexUnicodeTable instance at 0x3f85290>
Translation table.
-
class latexcodec.codec.LatexCodec[source]
Bases: codecs.Codec
-
decode(bytes_, errors='strict')[source]
Convert LaTeX bytes to unicode string.
-
encode(unicode_, errors='strict')[source]
Convert unicode string to LaTeX bytes.
-
class latexcodec.codec.LatexUnicodeTable(lexer)[source]
Tabulates a translation between LaTeX and unicode.
-
register(unicode_text, latex_text, mode='text', package=None, decode=True, encode=True)[source]
Register a correspondence between unicode_text and latex_text.
Parameters: |
- unicode_text (str) – A unicode string.
- latex_text (bytes) – Its corresponding LaTeX translation.
- mode (str) – LaTeX mode in which the translation applies
('text' or 'math').
- package (str) – LaTeX package requirements (currently ignored).
- decode (bool) – Whether this translation applies to decoding
(default: True).
- encode (bool) – Whether this translation applies to encoding
(default: True).
|
-
register_all()[source]
Register all symbols and their LaTeX equivalents
(called by constructor).