[][src]Crate latexcompile

latexcompile

This library provides a basic enviroment to produce a clean latex build. It run the latex build within a Tempdir.

It also provides a simple templating feature which can be used to insert text fragements into the input files.

Example

use std::collections::HashMap;
use std::fs::write;
use latexcompile::{LatexCompiler, LatexInput, LatexError};

fn main() {
    // create the template map
    let mut dict = HashMap::new();
    dict.insert("test".into(), "Minimal".into());
    // provide the folder where the file for latex compiler are found
    let input = LatexInput::from("assets");
    // create a new clean compiler enviroment and the compiler wrapper
    let compiler = LatexCompiler::new(dict).unwrap();
    // run the underlying pdflatex or whatever
    let result = compiler.run("assets/test.tex", &input).unwrap();

    // copy the file into the working directory
    let output = ::std::env::current_dir().unwrap().join("out.pdf");
    assert!(write(output, result).is_ok());
}

Structs

LatexCompiler

The wrapper struct around some latex compiler. It provides a clean temporary enviroment for the latex compilation.

LatexInput

The latex input provides the needed files as tuple vector with name, buffer as tuple.

Enums

LatexError

Specify all error cases with the fail api.