Crates.io | texrender |
lib.rs | texrender |
version | 0.3.3 |
source | src |
created_at | 2020-10-19 17:56:19.690342 |
updated_at | 2020-11-18 10:37:53.696251 |
description | Thin wrapper around running `latexmk` to render LaTeX documents. Also supports generating Tex documents. |
homepage | |
repository | https://github.com/mbr/texrender-rs |
max_upload_size | |
id | 303005 |
size | 31,351 |
A small crate to run latexmk
from Rust, similar to latex, escape LaTeX code and generate LaTeX documents programmatically.
let doc = r"
\documentclass{article}
\begin{document}
hello, world.
\end{document}
";
let tex = TexRender::from_bytes(doc.into());
let _pdf = tex.render().expect("latex rendering failed");
use texrender::elems;
use texrender::tpl::TexElement;
use texrender::tpl::elements::{N, doc, document, documentclass, section, t};
let tex = doc(elems!(
documentclass(N, "article"),
document(elems!(
section("Hello, world"),
t("This is fun & easy.")
))
));
let output = tex.render().expect("rendering failed");
assert_eq!(output,
"\\documentclass{article}\n\
\\begin{document}\n\
\\section{Hello, world}\n\
This is fun \\& easy.\n\
\\end{document}\n");