title: Statebox -- A monographic overview lang: en pagesize: a4 classoption: 12pt author: The Statebox Team ---⏎
Last active
March 11, 2019 15:49
-
-
Save wires/0e3573b090189e9d2a83c0990483861f to your computer and use it in GitHub Desktop.
Monograph latex & HTML tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
OUTDIR=build/html | |
OUTPUT=out.html | |
INPUT=$(cat inputs.txt) | |
rm -f src/$OUTPUT | |
rm -rf $OUTDIR | |
mkdir -p $OUTDIR | |
cd src \ | |
&& pandoc --filter ../tikz.py \ | |
--verbose --read markdown --write html --toc \ | |
--include-in-header=../headers.html --mathjax \ | |
-o ../$OUTDIR/$OUTPUT \ | |
$INPUT \ | |
&& cp -Rv tikz-images ../$OUTDIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
OUTDIR=build/pdf | |
OUTPUT=out.tex | |
INPUT=$(cat inputs.txt) | |
rm -f src/$OUTPUT | |
rm -rf $OUTDIR | |
mkdir -p $OUTDIR | |
cd src \ | |
&& pandoc --filter ../tikz.py \ | |
--read markdown --write latex --toc \ | |
--include-in-header=../headers.tex -s -o $OUTPUT \ | |
$INPUT \ | |
&& latexmk -pdf -output-directory=../$OUTDIR \ | |
&& rm $OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
PWD=$(pwd) | |
DIR=/monograph | |
TAG=statebox/booktools | |
BASH=/bin/bash | |
#docker run -i -t -v $PWD:$DIR $TAG $BASH -c "cd $DIR && ./build-pdf.sh" | |
docker run -i -t -v $PWD:$DIR $TAG $BASH -c "cd $DIR && ./build-html.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
TAG=statebox/booktools | |
docker build -t $TAG . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian:9-slim | |
RUN apt -y update | |
RUN apt -y install --no-install-recommends texlive-base pandoc latexmk | |
RUN apt -y install --no-install-recommends texlive-latex-extra texlive-fonts-extra texlive-fonts-recommended lmodern | |
RUN apt -y install --no-install-recommends python-pip python-setuptools && pip install bdist-venv pandocfilters | |
RUN apt -y install --no-install-recommends imagemagick ghostscript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/x-mathjax-config"> | |
MathJax.Hub.Config({ | |
TeX: { | |
extensions: ["AMScd.js"] | |
} | |
}); | |
</script> | |
<style> | |
body { | |
font-size: 1.3em; | |
font-family:georgia,serif; | |
line-height: 150%; | |
padding-left: 2em; | |
padding-top: 2em; | |
padding-right: 3em; | |
padding-bottom: 2em; | |
} | |
/* | |
body > :not(nav) { | |
padding-left: 30%; | |
} | |
nav { | |
position: sticky; | |
width: 26%; | |
overflow-wrap: break-word; | |
overflow-x: hidden; | |
overflow-y: scroll; | |
top: 0px; | |
left: 0px; | |
padding-top: 2em; | |
font-size: 100%; | |
line-height: 110%; | |
} | |
nav > ul > li > a { | |
background-color: rgba(25, 163, 163, 0.3); | |
} | |
nav a { | |
padding: 3px 6px; | |
text-decoration: none; | |
color: black; | |
} | |
nav ul { | |
display: block; | |
text-decoration: none; | |
padding: 0px; | |
list-style-type: none; | |
margin: 4px; | |
padding-left: 10px; | |
} | |
nav > ul > li > ul > li > ul { | |
font-size: 70%; | |
border-left: 10px solid rgba(149, 172, 19, 0.3); | |
} | |
nav > ul > li > ul { | |
font-size: 85%; | |
} | |
*/ | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\usepackage{amsmath,amscd} | |
\usepackage{fullpage} | |
\usepackage[bitstream-charter]{mathdesign} | |
\usepackage[T1]{fontenc} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.md | |
1-intro/0-index.md | |
1-intro/1-credits.md | |
1-intro/2-process-languages.md | |
1-intro/3-current-solutions.md | |
1-intro/4-why-statebox.md | |
1-intro/5-monograph-overview.md | |
2-ethics/0-index.md | |
3-legal/0-index.md | |
4-business/0-index.md | |
5-statebox/0-index.md | |
5-statebox/1-core/0-index.md | |
5-statebox/1-core/1-category_theory_intro.md | |
5-statebox/1-core/2-petri_nets.md | |
5-statebox/1-core/3-petri_nets_compositionally.md | |
5-statebox/1-core/4-petri_nets_logically.md | |
5-statebox/1-core/5-petri_nets_executions.md | |
5-statebox/1-core/9-petri_nets_folds.md | |
5-statebox/9-index.md | |
6-conclusion/0-index.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Pandoc filter to process raw latex tikz environments into images. | |
Assumes that pdflatex is in the path, and that the standalone | |
package is available. Also assumes that ImageMagick's convert | |
is in the path. Images are put in the tikz-images directory. | |
""" | |
import os | |
import re | |
import shutil | |
import sys | |
from subprocess import call | |
from tempfile import mkdtemp | |
from pandocfilters import toJSONFilter, Para, Image, get_filename4code, get_extension | |
head = """\\documentclass{standalone} | |
\\def\\xcolorversion{2.00} | |
\\def\\xkeyvalversion{1.8} | |
\\usepackage[version=0.96]{pgf} | |
\\usepackage{tikz} | |
\\usetikzlibrary{arrows,shapes,snakes,automata,backgrounds,petri} | |
\\usepackage[latin1]{inputenc} | |
\\usepackage{verbatim} | |
\\begin{document} | |
""" | |
def tikz2image(tikz_src, filetype, outfile): | |
tmpdir = mkdtemp() | |
olddir = os.getcwd() | |
os.chdir(tmpdir) | |
f = open('tikz.tex', 'w') | |
f.write(head) | |
f.write(tikz_src) | |
f.write("\n\\end{document}\n") | |
f.close() | |
call(["pdflatex", 'tikz.tex'], stdout=sys.stderr) | |
os.chdir(olddir) | |
if filetype == 'pdf': | |
shutil.copyfile(tmpdir + '/tikz.pdf', outfile + '.pdf') | |
else: | |
call(["convert", "-interlace", "none", "-quality", "80", "-density", "400", tmpdir + '/tikz.pdf', outfile + '.' + filetype]) | |
shutil.rmtree(tmpdir) | |
def tikz(key, value, format, _): | |
if key == 'RawBlock': | |
[fmt, code] = value | |
if fmt == "latex" and re.match("\\\\begin{tikzpicture}", code): | |
outfile = get_filename4code("tikz", code) | |
filetype = get_extension(format, "png", html="png", latex="pdf") | |
src = outfile + '.' + filetype | |
if not os.path.isfile(src): | |
tikz2image(code, filetype, outfile) | |
sys.stderr.write('Created image ' + src + '\n') | |
return Para([Image(['', [], []], [], [src, ""])]) | |
if __name__ == "__main__": | |
toJSONFilter(tikz) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment