Last active
November 9, 2021 16:44
-
-
Save zot/579003a404d8b7c421923d17d63bc640 to your computer and use it in GitHub Desktop.
format markdown docs with https://jez.io/pandoc-markdown-css-theme/ and add TOC sidebar
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 | |
# format markdown docs with https://jez.io/pandoc-markdown-css-theme/ and add TOC sidebar | |
# removes the large margin at the top of the body | |
if [ $# = 0 -o "$1" = --help ]; then | |
cat <<here | |
Usage: $(basename $(realpath "$0")) [--help] MARKDOWNFILE | |
Outputs HTML file from MARKDOWNFILE. | |
Formats MARKDOWNFILE with jez's template. | |
Shows a table of contents on the side. | |
here | |
exit | |
fi | |
iid=$(mktemp) | |
docker build - --iidfile=$iid -q >/dev/null <<here | |
FROM debian:buster | |
RUN apt-get update \ | |
&& apt-get install -y pandoc git | |
RUN mkdir /work /md \ | |
&& cd /md \ | |
&& git clone https://github.com/jez/pandoc-markdown-css-theme.git | |
RUN sed 's/^.*--title-margin-top:.*$/ --title-margin-top: 0;/' < /md/pandoc-markdown-css-theme/public/css/theme.css > /tmp/theme.css \ | |
&& mv /tmp/theme.css /md/pandoc-markdown-css-theme/public/css | |
here | |
image=$(cat $iid) | |
dir=$(dirname $(realpath "$1")) | |
file=$(basename "$1") | |
config=/md/pandoc-markdown-css-theme | |
docker run --rm --read-only -v "$dir":/work $image pandoc \ | |
--katex \ | |
--from markdown+tex_math_single_backslash \ | |
--to html5+smart \ | |
--template=$config/template \ | |
--css=$config/public/css/theme.css \ | |
--css=$config/public/css/skylighting-solarized-theme.css \ | |
--self-contained \ | |
--resource-path=/work \ | |
--metadata=title-margin-top:0px \ | |
--variable=fontsize:72 \ | |
--toc \ | |
"/work/$file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This uses docker for a spiffy "zero-install" experience...