Hacker News new | ask | show | jobs
by cbolton 14 days ago
I'm curious what would be a good example of something where this falls short of what you need?

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...

1 comments

Sidebars, front matter, index entries...
(Callisto author here)

Front matter would be fine I think. The static parts you would write directly in Typst. For the outline you would call #outline() as usual in the Typst document: notebook content is converted to Typst content (using cmarker), including the headings which become Typst headings so they show up as expected in the outline.

For sidebars I guess you use pandoc-Markdown extensions such as Divs that you transform with a Lua filter? What I would do then is use raw cells in the notebook to define sidebars (using Typst code in the raw cells) and configure Callisto to eval the raw cells.

For index entries, for example using the in-dexter package you could use HTML comments to insert index references where appropriate:

  <!--raw-typst #index[Entry]!-->
but I would just write #index[Entry] directly in the Markdown text, and use a show rule in the Typst document to convert them:

  #show regex("#index\[.*\]"): it => eval(it.text, mode: "markup", scope: in-dexter)
Overall, I think pandoc-Markdown + filters + Typst template is powerful and conceptually straightforward: you define the data structure with Markdown, you transform it with filters and render with Typst. Having the document as a well-defined data structure you can manipulate is especially powerful and something I wish we had in Typst.

In practice though it often feels overly complicated for little gains, when you can get things done with one tool and a single language (well, two since we're talking about including Jupyter notebooks).

Also working directly in Typst has advantages like live preview (also for content imported from notebooks), and some things that are a bit involved with pandoc, like maybe showing a cell output in a sidebar, become super easy: just add "#| label: my-cell" and "#| output: false" in the cell header, and #output("my-cell") in the side bar.