diff options
author | Minijackson <minijackson@riseup.net> | 2022-03-09 10:42:04 +0100 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2022-03-09 10:42:04 +0100 |
commit | 0b3000e5eae26ad1a2458cc1ae230d98148e0248 (patch) | |
tree | bd8ac49e68e6d4a788dce4f8d20bbb86ee037db5 | |
parent | 0b88d0aefb1901312406a13a978dec8ad9ee2c19 (diff) | |
download | pandoc-nix-templates-0b3000e5eae26ad1a2458cc1ae230d98148e0248.tar.gz pandoc-nix-templates-0b3000e5eae26ad1a2458cc1ae230d98148e0248.zip |
latex: factor pandoc and latex cmds in env var for devshell
-rw-r--r-- | latex.nix | 43 |
1 files changed, 27 insertions, 16 deletions
@@ -1,4 +1,5 @@ | |||
1 | { runCommand | 1 | { lib |
2 | , runCommand | ||
2 | , makeFontsConf | 3 | , makeFontsConf |
3 | , fira | 4 | , fira |
4 | , fira-code | 5 | , fira-code |
@@ -13,7 +14,9 @@ | |||
13 | , documentType ? "latex" | 14 | , documentType ? "latex" |
14 | }: | 15 | }: |
15 | 16 | ||
16 | { name, src }: | 17 | { name, src, extraPandocArgs ? [ ], extraLatexArgs ? [ ] }: |
18 | |||
19 | with lib; | ||
17 | 20 | ||
18 | runCommand name | 21 | runCommand name |
19 | { | 22 | { |
@@ -46,26 +49,34 @@ runCommand name | |||
46 | FONTCONFIG_FILE = makeFontsConf { | 49 | FONTCONFIG_FILE = makeFontsConf { |
47 | fontDirectories = [ lmodern freefont_ttf fira fira-code ]; | 50 | fontDirectories = [ lmodern freefont_ttf fira fira-code ]; |
48 | }; | 51 | }; |
52 | |||
53 | pandocCmd = '' | ||
54 | pandoc ${name}.md -t ${documentType} -so document.tex | ||
55 | --template=${pandoc-templates}/default.latex | ||
56 | --lua-filter=${pandoc-lua-filters}/share/pandoc/filters/minted.lua | ||
57 | --pdf-engine=xelatex | ||
58 | --pdf-engine-opt=-aux-directory=./build | ||
59 | --pdf-engine-opt=-shell-escape ${escapeShellArgs extraPandocArgs} | ||
60 | ''; | ||
61 | |||
62 | latexmkCmd = '' | ||
63 | latexmk | ||
64 | -shell-escape | ||
65 | -xelatex | ||
66 | -8bit | ||
67 | -interaction=nonstopmode | ||
68 | -verbose | ||
69 | -file-line-error | ||
70 | -output-directory=./build document.tex ${escapeShellArgs extraLatexArgs} | ||
71 | ''; | ||
49 | } '' | 72 | } '' |
50 | unpackFile $src | 73 | unpackFile $src |
51 | cd */ | 74 | cd */ |
52 | chmod -R u+w . | 75 | chmod -R u+w . |
53 | 76 | ||
54 | pandoc ${name}.md -t ${documentType} -so document.tex \ | 77 | $pandocCmd |
55 | --template=${pandoc-templates}/default.latex \ | ||
56 | --lua-filter=${pandoc-lua-filters}/share/pandoc/filters/minted.lua \ | ||
57 | --pdf-engine=xelatex \ | ||
58 | --pdf-engine-opt=-aux-directory=./build \ | ||
59 | --pdf-engine-opt=-shell-escape | ||
60 | 78 | ||
61 | latexmk \ | 79 | $latexmkCmd |
62 | -shell-escape \ | ||
63 | -xelatex \ | ||
64 | -8bit \ | ||
65 | -interaction=nonstopmode \ | ||
66 | -verbose \ | ||
67 | -file-line-error \ | ||
68 | -output-directory=./build document.tex | ||
69 | 80 | ||
70 | cp build/document.pdf $out | 81 | cp build/document.pdf $out |
71 | '' | 82 | '' |