texrender

Crates.iotexrender
lib.rstexrender
version0.3.3
sourcesrc
created_at2020-10-19 17:56:19.690342
updated_at2020-11-18 10:37:53.696251
descriptionThin wrapper around running `latexmk` to render LaTeX documents. Also supports generating Tex documents.
homepage
repositoryhttps://github.com/mbr/texrender-rs
max_upload_size
id303005
size31,351
Marc Brinkmann (mbr)

documentation

https://docs.rs/texrender

README

texrender

A small crate to run latexmk from Rust, similar to latex, escape LaTeX code and generate LaTeX documents programmatically.

Example: Rendering latex

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");

Example: Generating latex code

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");
Commit count: 47

cargo fmt