The latextree Package
Creates a document object model for LaTeX and provides some useful functions. The parser understands the syntax of most common macros but is NOT a replacement for a full LaTeX engine. The parser should only be invoked only after the input has been successfully compiled under LaTeX.
Example:
>>> from latextree.parser import LatexParser
>>> pa = LatexParser()
>>> filename = "/path/to/main.tex""
>>> doc = pa.parse_latex_file(filename)
>>> doc.make_website() # create website
>>> bbqs = doc.bbq() # extract mc/ma questions in Blackboard format (plain text)
>>> docx = doc.root.get_xml() # create xml document
>>> from lxml import etree
>>> print(etree.tostring(docx, pretty_print=True))
If latextree is installed as a package:
>>> import latextree
>>> filename = "/path/to/main.tex""
>>> doc = load(filename)
>>> doc.make_website() # create website
>>> bbqs = doc.bbq() # extract mc/ma questions in Blackboard format (plain text)
>>> exit()
Standards
The following are yet to be implemented properly.
- Exception handling
- Testing
- Logging
- Documentation
make_website
>>> doc.make_website(copy_static=True, copy_figures=True, WEB_ROOT=None)
By default, the website is created in a folder called web-latexmainfilename in the directory containing the main latex source file. . The output directory can be changed by setting the WEB_ROOT variable.
- html files are written to WEB_ROOT
- style files are copied to WEB_ROOT/static/css. These can be modified post-production.
- figures are copied to WEB_ROOT/static/img
- urls are constructed from chapter and/or section numbers (if any)
Templates
The LatexDocument.make_website() function uses jinja2 templates.
scripts.htmlloads theMathJaxandjqueryCDNs from cloudflare.node.htmldoes most of the work. This needs to be broken up.
Static files
css/: The stylesheets are rough-and-ready and need a lot of work (especially for phones and tablets).img/: Image files are copied into here.js/: Currently contains only a simple show/hide function.
Modules
bibliography: wrapper forbibtexparsercontent: content nodesdocument:LatexDocumentclass and output functionsfactory: creates node classes and objectsltree: command line toolsmacrosdef: macro definitions forpylatexenc.latexwalkernode: base class forLatexTreeNodeobjects.parser:LatexParserclass. CreatesLatexDocumentobjects.preprocessor: prepare latex source forpylatexenc.latexwalker(replace $$...$$ etc.)reader: input functions and utilitiessettings: website settings (e.g. mathjax cdn)tabular: parse tabular environments.taxonomy: register of species (e.g.list) and genera (e.g.itemize).walker: wrapper forpylatexenc.latexwalker.
Dependencies
bibtexparserjinja2lxmlpylatexenc
Test files
The tex directory contains:
LatexTreeTestBookfor testing thebookdocument classLatexTreeTestArticlefor testing thearticledocument classLatexTreeTestExamfor testing theexamdocument class
Existing software for Latex processing
-
pylatexenc
- LaTeX -> Unicode
- python package
-
plasTeX
- LaTeX -> XML and XHTML
- python package
-
tex4ht
- LaTeX -> XML, HTML and Braille!
- java and c libraries
- provides a
htlatexcmd to replace latex.
-
pandoc
- LaTeX -> HTML
- haskell library
-
tralics (INRIA)
- LaTeX -> XML
Metadata
Release files for latextree 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| latextree-0.2.tar.gz | 35.4 kB | Without provenance | Details for latextree-0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| latextree-0.2-py3-none-any.whl | Python 3 | none | any | Details for latextree-0.2-py3-none-any.whl |
Total release size: 76.8 kB
Release files / latextree-0.2.tar.gz
| Download URL | latextree-0.2.tar.gz |
|---|---|
| Size | 35.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a33738f469e5759730526291050a9e2f45b658be64850262c1fd236ed82f3de3
|
|
BLAKE2b-256 checksum How to use checksums |
1918f9b118866e38e3829f96dab632f2e6b8eac5db74ace0ce8e59492e3426d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / latextree-0.2-py3-none-any.whl
| Download URL | latextree-0.2-py3-none-any.whl |
|---|---|
| Size | 41.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5e084fac37421f2513bf93a56336855bc55bcef5553609af01bc9d411d08bc3
|
|
BLAKE2b-256 checksum How to use checksums |
6a07379c8363d9b6926147e947ebd97dbdfa8cb55b76b66b2ca7b2d8da7e314c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for latextree 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.