Skip to main content

Simple LaTeX parser providing latex-to-unicode and unicode-to-latex conversion

Project description

Simple LaTeX parser providing latex-to-unicode and unicode-to-latex conversion

https://img.shields.io/github/license/phfaist/pylatexenc.svg?style=flat https://img.shields.io/pypi/v/pylatexenc.svg?style=flat

Python: ≥ 3.4 or ≥ 2.7. The library is designed to be as backwards-compatible as reasonably possible and is able to run on old python verisons should it be necessary. (Use the setup.py script directly if you have python<3.7, poetry doesn’t seem to work with old python versions.)

Unicode Text to LaTeX code

The pylatexenc.latexencode module provides a function unicode_to_latex() which converts a unicode string into LaTeX text and escape sequences. It should recognize accented characters and most math symbols. A couple of switches allow you to alter how this function behaves.

You can also run latexencode in command-line to convert plain unicode text (from the standard input or from files given on the command line) into LaTeX code, written on to the standard output.

A third party plug-in for Vim vim-latexencode by @Konfekt provides a corresponding command to operate on a given range.

Parsing LaTeX code & converting to plain text (unicode)

The pylatexenc.latexwalker module provides a series of routines that parse the LaTeX structure of given LaTeX code and returns a logical structure of objects, which can then be used to produce output in another format such as plain text. This is not a replacement for a full (La)TeX engine, rather, this module provides a way to parse a chunk of LaTeX code as mark-up code.

The pylatexenc.latex2text module builds up on top of pylatexenc.latexwalker and provides functions to convert given LaTeX code to plain text with unicode characters.

You can also run latex2text in command-line to convert LaTeX input (either from the standard input, or from files given on the command line) into plain text written on the standard output.

Documentation

Full documentation is available at https://pylatexenc.readthedocs.io/.

To build the documentation manually, run:

> poetry install --with=builddoc
> cd doc/
doc> poetry run make html

License

See LICENSE.txt (MIT License).

NOTE: See copyright notice and license information for file tools/unicode.xml provided in tools/unicode.xml.LICENSE. (The file tools/unicode.xml was downloaded from https://www.w3.org/2003/entities/2007xml/unicode.xml as linked from https://www.w3.org/TR/xml-entity-names/#source.)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylatexenc-3.0a13.tar.gz (196.3 kB view details)

Uploaded Source

Built Distribution

pylatexenc-3.0a13-py3-none-any.whl (251.4 kB view details)

Uploaded Python 3

File details

Details for the file pylatexenc-3.0a13.tar.gz.

File metadata

  • Download URL: pylatexenc-3.0a13.tar.gz
  • Upload date:
  • Size: 196.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/22.2.0

File hashes

Hashes for pylatexenc-3.0a13.tar.gz
Algorithm Hash digest
SHA256 3b96dd51ac8d091719f31f904a825e004529d7d2c6d45b85218806e6cf01ade8
MD5 c997d8305e67f955d438fd1f9aabfbe4
BLAKE2b-256 ddf6956675a206cd88d8f514bb91fadac1309a88be1784577bc6c0313d3c5c58

See more details on using hashes here.

File details

Details for the file pylatexenc-3.0a13-py3-none-any.whl.

File metadata

  • Download URL: pylatexenc-3.0a13-py3-none-any.whl
  • Upload date:
  • Size: 251.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/22.2.0

File hashes

Hashes for pylatexenc-3.0a13-py3-none-any.whl
Algorithm Hash digest
SHA256 3d01bcae6fe293b253575ba5b2efc78e6b042262b34704c9f05ca702b64622bc
MD5 5b36e27887ff2f8ea0b78b7c945b1e84
BLAKE2b-256 7061e651b9aa84179551e55cfd637a858d2c1fa56abd2f91a720252ad0321bfa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page