Created
April 19, 2023 06:08
-
-
Save luckylittle/ebb46b2f4663df7c1dc0fc257ee1ef89 to your computer and use it in GitHub Desktop.
Beautiful PDF generator out of Markdown powered by podman
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/zsh | |
######################################## | |
######################################## | |
## ## | |
## Author: [email protected] ## | |
## Takes Markdown file `in.md` and ## | |
## converts it into a LaTeX PDF !! ## | |
## ## | |
######################################## | |
######################################## | |
# Create a listings setup for code blocks | |
cat <<EOF > listings-setup.tex | |
\usepackage{xcolor} | |
\lstset{ | |
basicstyle=\ttfamily, | |
keywordstyle=\color[rgb]{0.13,0.29,0.53}\bfseries, | |
stringstyle=\color[rgb]{0.31,0.60,0.02}, | |
commentstyle=\color[rgb]{0.56,0.35,0.01}\itshape, | |
backgroundcolor=\color[RGB]{248,248,248}, | |
showspaces=false, | |
showstringspaces=false, | |
showtabs=false, | |
tabsize=2, | |
captionpos=b, | |
breaklines=true, | |
breakatwhitespace=true, | |
breakautoindent=true, | |
escapeinside={\%*}{*)}, | |
linewidth=\textwidth, | |
basewidth=0.5em, | |
} | |
EOF | |
# Create a Containerfile | |
cat <<EOF > Containerfile | |
FROM registry.redhat.io/rhel7:7.9-983.1679306060 | |
RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm | |
RUN yum install -y pandoc pandoc-citeproc texlive | |
COPY in.md /tmp/ | |
COPY listings-setup.tex /tmp/ | |
RUN pandoc -f markdown_github --listings -H /tmp/listings-setup.tex -V geometry:margin=0.3in -o /tmp/out.pdf /tmp/in.md | |
EOF | |
# Build a container | |
podman build -t pandoc-citeproc -f Containerfile . | |
# Run the container | |
podman run --name pandoc-citeproc pandoc-citeproc | |
# Copy the out.pdf from inside the container | |
podman cp pandoc-citeproc:/tmp/out.pdf . | |
# Cleanup | |
podman rm pandoc-citeproc | |
podman rmi localhost/pandoc-citeproc | |
rm -vf listings-setup.tex Containerfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment