bookish
bookish copied to clipboard
Symbols
We used to have a feature in the old implementation for binding some text with a name and then using that in the markup prior to parsing in order to avoid repeating something. This is used extensively in the Critically Conscious Computing book and needs to be reimplemented, perhaps in a way that's supported in parsing rather than pre-parsing.
Here are some old notes on this problem:
The problem here is the preprocessor. When rendering the WYWISYG view, we preprocess and there’s no trace of the symbols. But when editing, we want to actually see and edit the symbols. We need to preserve this somehow.
One possibility is remembering somehow during parsing that the replaced text is a symbol, and then when editing it, modifying the symbol definition with the edited text. That would involve basically preserving symbols during parsing, then reading the symbol text during parsing instead of the main text, transparently. We could make a little text stack to parse from to support recursive symbol references and check for stack errors. Then, when we parse the node, we could annotate any nodes generated with the symbol. But what makes all of this messy is that symbol text doesn’t map on neatly onto a node. For example, in Critically Conscious Computing, we have many symbols that are just table rows, which don’t correspond to a node, just part of a node. That would be incredibly messy to map back onto ndoes.
An alternative is that when we render the book, we only preprocess when viewing, not when editing. Then, we would just have the symbol references in the text, which we could render as part of text and could be arbitrarily included anywhere in text. Then it would be up to the author to view to see how it appears.