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.See also
-
latexcodec.codec.
find_latex
(encoding: str) → Optional[codecs.CodecInfo][source]¶ Return a
codecs.CodecInfo
instance for the requested LaTeX encoding, which must be equal tolatex
, or tolatex+<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.
-
emptytoken
= Token(name='unknown', text='')¶ The empty token.
-
get_latex_chars
(unicode_: str, final: bool = False) → Iterator[str][source]¶ Encode every character. Override to process the unicode in some other way (for example, for character translation).
-
table
= <latexcodec.codec.LatexUnicodeTable object>¶ Translation table.
-
-
class
latexcodec.codec.
LatexIncrementalDecoder
(errors='strict')[source]¶ Bases:
latexcodec.lexer.LatexIncrementalDecoder
Translating incremental decoder for LaTeX.
-
get_unicode_tokens
(chars: str, final: bool = False) → Iterator[str][source]¶ Decode every token. Override to process the tokens in some other way (for example, for token translation).
-
setstate
(state: Any) → None[source]¶ Set state. The state must correspond to the return value of a previous
getstate()
call.
-
table
= <latexcodec.codec.LatexUnicodeTable object>¶ Translation table.
-
token_buffer
= None¶ The token buffer of this decoder.
-
-
class
latexcodec.codec.
LatexCodec
[source]¶ Bases:
codecs.Codec
-
class
latexcodec.codec.
LatexUnicodeTable
(lexer_)[source]¶ Tabulates a translation between LaTeX and unicode.