by LAC-Tech · 6mo ago · 0 comments
> Last summer I spent a lot of time with Typst (at that point v0.11) and Pandoc, working on a flexible and reusable workflow to typeset markdown-formatted articles to PDF.
I understand that Typst is a markup language that can output a pdf file (big Typst fan btw).
I understand Pandoc is a thing that transforms documents of one kind to documents of another, ie markdown to html.
But the author wants to "typeset markdown-formatted article to PDF". Which makes me wonder what this has to do with typst at all.
--pdf-engine=typst
-V template=article.typ
Despite the input content being a .md file, we see that the .md contents populate the .typ file. Pandoc then understands how to convert the populated .typ file into a .pdf. The author also notes in their hyperlinked .typ document where the body content is placed: // THIS IS THE ACTUAL BODY:
What is not clear to me is the actual mechanism that tells pandoc where to place the body contents in the template. I presume it's some "magic" from the pandoc docs. The pandoc templates documentation[1] does reveal to us that `-V` is setting a variable called `template`. I don't have pandoc locally, but from another post[2] from the same author and a chatgpt query, it seems that the `body` symbol in the template is the chosen substitution symbol.[1]: https://pandoc.org/demo/example33/6-templates.html
[2]: https://imaginarytext.ca/posts/2024/pandoc-typst-tutorial/
(This actually interferes with Typst's math mode. But you can manually construct math blocks, so no real problem. Pandoc variables are only valid within templates anyway.)
I write Python, software engineering, and data science books in Jupyter. (Because I want both text and code). I've written my own toolchain (multiple times, don't ask, yes, I've tried the one you're thinking of and it didn't work for me).
I need to convert the notebooks into chapters in my books (PDF so I can print them). In the past, I used code to convert to LaTeX. (It was horrible).
Now, I use code to convert the Jupyter file to markdown, then (I use pandoc too) to typst. (It is 100x better than LaTeX).
(I also use pandoc to convert markdown to epub).
I know you didn't want questions, but maybe you can save me some trouble?
Assuming you're talking about quarto, may I ask what you didn't like about it? I've been converting some of my course materials to it and have been enjoying it immensely.
#import "@preview/callisto:0.2.5"
#callisto.render(nb: json("notebook.ipynb"))
though as the sibling comment says Quarto also works great for this, and Typst doesn't do epub (yet?)I mean this Typst package just lets you import the notebook content in your Typst document. All the formatting is done in Typst which is also what you use for your final output...