Last active
October 7, 2015 19:57
-
-
Save kgadek/3216960 to your computer and use it in GitHub Desktop.
Makefile: for Literate Haskell, Markdown/LaTeX mixed 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
# sauce of original Makefile magic: | |
# http://passingcuriosity.com/2008/literate-haskell-with-markdown-syntax-hightlighting/ | |
# modified by kgadek | |
# Ok, so I found Markdown+Bird style to be nice BUT editors have problems with Haskell code (indenting & stuff) when | |
# each line starts with ">". | |
# On the other hand LaTeX style is ok but LaTeX is often too powerful - distracts me all the time from actual code. | |
# But don't worry, I'm (nearly) an Engineer. Solution: | |
# Write Markdown style, enclose code with \begin{code}..\end{code} block and use small sed script to convert it to Markdown+Bird. | |
# What is cool, GHC does not complain at all! | |
.SUFFIXES: .lhs .mkd .html .tex .pdf | |
.PHONY: all clean | |
PANDOC := pandoc --no-wrap -sS | |
HSCOLOUR := hscolour -lit | |
SED_CONVERT := sed '/\\begin{code}/,/\\end{code}/s/^/> /g' | |
# grep filter could be amended (more general regex) but works well for me | |
GREP_FILTER := grep -ve '\\\(begin\|end\){code}' | |
all: problem_0001.html problem_0002.html problem_0003.html problem_0004.html problem_0005.html problem_0006.html | |
clean: | |
rm -f *.html | |
# get mathjax (http://www.mathjax.org/) and hscolour.css (http://www.cs.york.ac.uk/fp/darcs/hscolour/) | |
.lhs.html: | |
cat $< | $(SED_CONVERT) | $(GREP_FILTER) | \ | |
$(HSCOLOUR) -css | $(PANDOC) -t html -c hscolour.css --mathjax='mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML' > $@ | |
# TODO: all below | |
.lhs.mkd: | |
cat $< | $(HSCOLOUR) -css > $@ | |
.lhs.tex: | |
cat $< | $(HSCOLOUR) -latex -lit-tex -partial | $(PANDOC) -t latex> $@ | |
.tex.pdf: | |
pdflatex $< && pdflatex $< && pdflatex $< |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment