/PyTeX

LaTeX i/o for Python

Primary LanguagePythonBSD 2-Clause "Simplified" LicenseBSD-2-Clause

PyTeX -- LaTeX i/o for Python

DOI Build Status codecov.io

Description

In development

Easy-ish translation between data objects and the DOM we know as LaTeX.

Usage

Compiling a .tex document to a json object:

from pprint import pprint
from PyTeX import latex

with open('data/simple.tex', 'r') as f:
    data = latex.load(f)
pprint(data)
[{'documentclass': {'arguments': ['article']}},
 {'document': {'data': ['This is a LaTeX document.']}}]

Compiling a .bib document to a json object

from pprint import pprint
from PyTeX import latex

with open('data/simple.bib', 'r') as f:
    data = latex.load(f)
pprint(data)
{'test': {'author': 'Dillon Niederhut',
          'title': 'Structured data with PyTeX',
          'type': 'article',
          'year': '2016'}}

Recursive, fuzzy searching of a json object:

for result in latex.find('data', data):
    pprint(result)
{'data': ['This is a LaTeX document.']}