by sillysaurusx · 7mo ago · 0 comments
Is there a single "document containing all the words," and it updates the website, pdf, and epub whenever you change it?
What struck me was that the presentation is beautiful. It seems worth emulating. But that raises the question of what format you'd write your original words in. Do you suppose they just use Markdown files, or something more elaborate?
For my blog, I write posts in Markdown. Then the build process uses Pandoc to convert the posts into web pages and, for certain pages, PDF files typeset with TeX. For example, here is a post in both web and PDF versions:
(Web) https://blog.moertel.com/posts/2024-08-23-sampling-with-sql....
(Typeset PDF) https://blog.moertel.com/images/public_html/blog/pix-2024060...
The best I was able to do was http://github.com/shawwn/wiki, which has been broken since 2020. You can't spell Haskell without Hell.
If you wouldn't mind pulling up a `claude` in your repo and running `/init` and showing the result, that'd give me at least a vague idea of what to do.
match "posts/*" $ do
route $ setExtension "html"
let ctx = postCtx tags
compile $ pandocMathCompiler
>>= loadAndApplyTemplate "templates/post.html" ctx
>>= saveSnapshot "content"
>>= loadAndApplyTemplate "templates/add-comments.html" ctx
>>= loadAndApplyTemplate "templates/default.html" ctx
>>= relativizeUrls
The `pandocMathCompiler` bit invokes Hakyll's Pandoc subsystem with support for rendering formulas using MathJax.The site Makefile also has rules to build PDF versions of the articles that I want to typeset. The rules just invoke Pandoc directly. For example, here's the rule used to generate the PDF file in my prior comment:
sampling-with-sql.pdf: posts/2024-08-23-sampling-with-sql.md
( cd posts && pandoc --metadata-file=../templates/latex-header-includes.yaml -t pdf -o ../$@.tmp --pdf-engine=pdflatex ../$< && mv -f ../$@.tmp ../$@ )
It's basically a straightforward invocation of Pandoc with a little shell boilerplate to prevent the PDF file from being moved into its final location unless Pandoc exits with success.The Makefile has a final "push" target that makes sure the site's assets are up to date (invoking Hakyll if needed) and then pushes the static site up to the content distribution network I'm using to publish my website.
Would you be willing to paste your entire Makefile here? Or are there secrets in it?
It would help me greatly — I don't have much experience with pandoc or hakyll. I understand the basics, but the actual usage in practice isn't so easy to set up from first principles.
I've been using Claude to help me with a lot of this, but I'm extremely curious to compare notes vs your setup.
If not, thank you anyway for your time.
> This piece, like most all my words and software, was written by hand—mainly in Vim. I composed a Markdown outline in a mix of headers, bullet points, and prose, then reorganized it in a few passes. With the structure laid out, I rewrote the outline as prose, typeset with Pandoc. I went back to make substantial edits as I wrote, then made two full edit passes on typeset PDFs. For the first I used an iPad and stylus, for the second, the traditional pen and paper, read aloud.
https://gist.github.com/aphyr/6f0cd6910ccfe2cd7828d1ade2eac5...