Created
May 23, 2016 20:28
-
-
Save anonymous/2f0b993190fd95e9749454903fc89931 to your computer and use it in GitHub Desktop.
an easy way to turn formatted text files into PDFs.
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 | |
# a pandoc script to easily turn formatted text files into PDFs - May 2016. | |
# based on a script by @pdfkungfoo, minor changes by Ange Albertini | |
# requires pandoc http://pandoc.org/ | |
# and either XeTeX http://xetex.sourceforge.net/ or LuaTeX http://www.luatex.org/ | |
# Xelatex supports all system fonts by default, and UTF8. | |
# standard PDFLateX doesn't. LuaLaTex also does but is slower. | |
# warning: you may have to change manually EOLs to match your OS. | |
in="${1}" | |
out="${in}".pdf | |
fontname="Ubuntu Mono" | |
paperwidth="11.5 cm" | |
paperheight="15 cm" | |
# 1- declare your favorite monospace font | |
# 2- tweak paperwidth (and paperheight? see below) according to your font | |
# example: | |
# for an 40 columns Apple II style output for an E-book screen | |
# fontname="Print Char 21" | |
# paperwidth="9cm" | |
# paperheight="125mm" | |
# if you are are not sure which exact font name | |
# to use for XeLaTeX or LuaLaTeX, | |
# you can use `luaotfload-tool` like this: | |
# luaotfload-tool --find "Similar Fontname" --fuzzy | |
# wrap the text file around code marker | |
echo '~~~' > fence.txt | |
echo "" >> fence.txt | |
# you can give paperheight a very big value | |
# to read with 'fit width' and minimize page changes. | |
pandoc \ | |
-o "${out}" \ | |
-f markdown \ | |
fence.txt \ | |
"${1}" \ | |
fence.txt \ | |
--latex-engine=xelatex \ | |
-V monofont="${fontname}" \ | |
-V geometry:"paperwidth=${paperwidth}, paperheight=${paperheight}, margin=3mm" | |
# recommended URLs about programming and old-school fonts: | |
# http://www.slant.co/topics/67/~programming-fonts | |
# http://int10h.org/oldschool-pc-fonts/fontlist/ | |
# https://damieng.com/blog/2011/02/20/typography-in-8-bits-system-fonts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment