deniederhut / PyTeX

LaTeX i/o for Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.']}

About

LaTeX i/o for Python

License:BSD 2-Clause "Simplified" License


Languages

Language:Python 69.3%Language:TeX 30.7%