jamespfennell / texcraft

Framework for building TeX engines and other kinds of TeX software
MIT License
6 stars 0 forks source link
tex

Texcraft

Texcraft is an experimental project to create a composable, LLVM-style framework for building TeX software.

Existing TeX engines (Knuth's original TeX '82, pdfTeX, XeTeX, etc.) all have monolithic software architectures and do not share code amongst themselves. The goal of Texcraft is change this by essentially doing for TeX engines what LLVM did for compilers. In Texcraft, a TeX engine is implemented as a loose collection of libraries that compose together using well-defined APIs. The same code can be shared between engines - for example, Texcraft's implementation of the \count primitive can be used both for TeX '82 (which has 256 memory registers) and pdfTeX (which has over 32,000 registers).

Initial work has focused on building a fast TeX language interpreter called Texlang, and a standard library of primitives such as \def that work with this interpreter. No typesetting work has been done yet.

Trying it out

The Texcraft playground is an example of TeX software built with Texcraft. It can be used to run TeX scripts in the browser.

Locally, with the Git repo checked out, the Texcraft binary can also be used to run TeX scripts; e.g.,

cargo run --bin texcraft run performance/benches/digits_of_pi.tex

The Texcraft binary also has a REPL for writing TeX interactively:

cargo run --bin texcraft repl

These all work with the limited subset of TeX commands that have been implemented. Run cargo run --bin texcraft doc for a list of available commands.

Note the main point of Texcraft is not to produce specific binaries, but rather to be a library for building TeX software. The documentation website will eventually beginner-friendly tutorials on working with Texcraft as a library.

Getting involved

There is a lot of low hanging fruit that is intentionally left unpicked so people who want to contribute to Texcraft have a good starting point. Right now the main focus is on completing the Texlang standard library, which is a collection of non-typesetting TeX commands like \def that every TeX distribution includes.

Related projects

TeX

Non-TeX Typesetting

There are number of active projects that are building typesetters based on non-TeX languages. The TeX language itself is very complex and certain features like incremental compilation are hard or impossible to implement.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

There is more information about our licensing on the documentation site.