Ludus should have a notebook or literate format #99
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: twc/ludus#99
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Ultimately, when we're publishing The History of Computing by Example or The History of Generative Art by Example, we'll be wanting to combine prose, code, graphics, and interaction all together.
My fantasy for this would be to have a format, e.g.,
.ldn
, that integrates these meaningfully. A Ludus notebook format.With djot as textual format, SVG as the graphics format, and with something on the frontend that allows for interacting with code, graphics, and text interaction.
A few different models/touchpoints/inspirations for this:
So, a few different fantasies and goals here:
I believe that djot+mdbook gives us a really good place to start, here. There's a Rust parser for mdbook: https://github.com/hellux/jotdown. There's an mdbook plugin for djot now that uses said parser: https://github.com/dcampbell24/mdbook-djot. And, as it turns out, mdbook includes a "Rust playground" feature for runnable code, and people have hacked up other-language REPLs: https://github.com/MR-Addict/mdbook-repl.
One thought I have, in addition, is the fact that djot lets you decorate block-level elements with ids, so that you could easily (perhaps trivially) do something like this:
The idea being that we don't pollute toplevel bindings with bindings from other code blocks. Instead, each one gets an id which can then be referred to in an
import
form in another code block.There are perhaps some titchy questions about state (what happens to sketches or
box
es when code is re-run?). But this feels like a pretty good start.My sense is that we may well wish to develop this first with Visual Modelling with Ludus.
It occurs to me that the thing is to develop a
.ldj
format, which is ludus-djot, which can then be more or less moved into anything: pandoc makes that doable. So we have a ldj -> djot -> typst -> pdf pipeline, and an ldj -> djot -> mdbook(+repl) -> website pipeline, we can build from the same text.That, to me, suggests that what we really need, anticipating later stages in the pipeline, are ways of naming cells and ensuring that their output is in the correct modalities, e.g.:
The first block,
foo
, would draw turtle graphics and show the stdout from theprint!
call.The second block,
bar
, would only show the result,44
.This would allow a reasonable pipeline:
ldj
files would be run, generating relevant output which is then inserted statically into djot files, which can then be inserted into any number of places.So the first step here is to develop an
ldj
spec and develop the build process from ldj to djot.The above, translating to djot, would simply desugar the first code block to:
Which is a pretty simple transformation!
As for running the code, the idea would be to develop a Rust program that would generate the console, turtle graphics, and results of the relevant programs, using
import
s as needed.Each cell would run as its own script.
SVG files would be built and saved, result and console output would be inserted in some way, likely with div headings, like so (for the first example):
We should probably also allow for captions, but those would probably simply be their own divs, written inline.
See also: https://sr.ht/~bitfehler/dmos/
Oh, and pandoc and dmos use sublime text highlighting, so that's another highlighter to have to maintain: https://www.sublimetext.com/docs/syntax.html.
That means: treesitter, lezer, sublime, and highlight.js. ::headdesk::