A clean Latex preprocessor.
- GO
1.7+
- PEG generator has to be in the
PATH
(https://github.com/pointlander/peg)
go get github.com/pointlander/peg
go get github.com/shurcooL/vfsgen
go generate
go get
go build
untex -output [destination .tex file] [source file]
If no -output
is set, the output will be written to STDOUT
.
This can be useful to pipe the generated LaTeX to pdflatex
like so:
untex [source file] | pdflatex
Templates can link to local paths or http(s)
urls.
If no template is set, a default one is provided from assets/default.xml
.
The preamble
, prefix
, suffix
and every attribute is rendered as a
text/template with every value of the
meta section available.
<template>
<!-- translates to \documentclass[options]{type} -->
<document type="scrartcl" options="a4paper,10pt">
<preamble>
inserted at the end of the preamble
</preamble>
<prefix>
inserted right after \begin{document}
</prefix>
<suffix>
inserted right before \end{document}
</suffix>
</document>
<packages>
<!-- translates to \usepackage[options]{name} -->
<package name="inputenc" options="utf8" />
</packages>
</template>
The root file can (and should) have a meta section. This section contains of a key-value configuration, that will be used to render the template.
---
template: mytemplate.xml
title: My first Untex document
---
Subfiles can be imported and trandformed as well.
@import(sections/my-other-file.tex)
Headlines start with one to three #
's and get translated to
\section
, \subsection
or \subsubsection
respectively.
# This is a section
## This is a subsection
There are three types of lists, that can be nested into each other.
- This is an unordered list
1. This is an
3. ordered list
Red) This is a named list
Blue) :-)
Plain LaTeX can be used as is, if needed.
%%%
\begin{tabular}{c|c|c}
1 & 2 & 3
\end{tabular}
%%%
In paragraphs, as well as in list items the following can be used.
*bold text*
/italic text/
$ inline math $
$$ display math $$
[link text](url)