Hi again,
TL;DR:
Authors using SB are asking for a short syntax to include metadata in the page or a custom Markdown syntax, which are requirements that I and others have found many times before while authoring in Markdown. And given that I have already approached such problems previously in Lua (and I don't know TS to go into the current markdown_parser) I wonder:
How can I reuse Lua Parser Expression Grammars (LPEG) and pure Lua libraries like Lustache and Lunamark to reuse Markdown syntax customizations, like page metadata tranclusions, Pandoc/Djot's div syntax for admonitions and others, without reimplementing them? In general, How can Space Lua reuse Lua scripts and libraries that are used in Markdown/document processing elsewhere so SB can integrate better to existing rich documentation workflows and ecosystems?
TIA
(The long version)
This inquiry concerns how to to integrate SB with Cardumem, a Lua based Static Site Generator (SSG) (still in alpha), that I have made to suit our documentation/publishing workflows in grassroots communities (like HackBo, our local Hackerspace) and at the university department, in the classes, workshops and research/prototyping projects across academic and non academic spaces/contexts. I'll explain how our documentation workflow looks like and where I would like to integrate SB. I will try to be pretty detailed as this particular concern could document how SB can be integrated into rich pre-existing documentation workflows and ecosystems.
Currently our publications workflow looks like this:
So, we write Markdown content in our workshops/classes using the real time collaborative editor HedgeDoc, Cardumem downloads/renames that information to the hard disk and parses (Markdown) content, (YAML) metadatada and Mustache (HTML + CSS) logicless templates to produce a HTML output that we store in a Fossil repository, kind of a GitHub/Gitea/Forgejo in a box (3 Mb), providing us collaboration, versioning, web server, ticketing/issues and forum. We use also Codium, the non-panoptic and telemetry disabled variant of VSCode, for wiki refactoring (more on that and the role of SB for our audiences later).
As many other SSGs, we need to parse, separate and process YAML metadata from Markdown content, while dealing with the popularity and insufficiency of the Markdown (sub)"standard" (despite of important efforts like CommonMark) by providing custom syntax for everything that plain Markdown doesn't allow, including transclusions, an important hypertext feature about how to make content modular and "assemblable", that has been historically overshadowed by linking...
Anyway, part of my thinking has been related with how to reuse the libraries and functionality we already have for Markdown processing to deal with this format's (many) limitations, making its syntax extensible, while offering a gentle curve to the authors, so they can traverse from content to functionality creation and viceversa, as they need.
For example, given that I already have Lua's Lustache to process logicless templates, Cardumem provides page metadata transclusions using the same Mustache syntax. So, given this page metadata:
---
# This is part of this page YAML metadata.
example: "**I'm just a brief text**."
mutabit: >
===== <br>
[mutabiT](https://mutabit.com/) is the small family enterprise that funds and sustains most of this long research and agile prototyping efforts, since 2003.
musketeers: ["Athos", "Aramis", "Porthos", "D'Artagnan"]
---
I can call those fields in Cardumem's Markdown with {{example}} , {{mutabit}} or {{#musketeers}} {{.}} {{/musketeers}}, to get them properly rendered inside the page.
Syntax extension reuse YAML + Mustache processing, so authors/collectives can create their own customized portable macros by defining them in a simple macros.yaml file, with nested keys containing the name of the macro, its input and how it is used in its output, again as a Mustache template. Similarly, global transclusion keys are defined in a transclusions.lua file, which allows, for example, to call {{_date}} in any page and get the current date when such page is exported as HTML.
Another example is the usage of Lunamark to process not only standard Markdown, but also its customizations, using Lua PEG, like in our admonitions, that follow Djot's div syntax, which is also used by Pandoc and HedgeDoc, as my policy regarding Markdown syntax extension is: "when in doubt, look at Pandoc/Djot as it's the variant that deals with most export/import scenarios.
Given the static/dynamic nature of Cardumem/SilverBullet, respectively, and that both have a Lua extension story, I would like to make each one the complement of the other: SB can be used for live coding and wiki refactoring of our documentation, instead of Codium, which suits better our general non-developers audience and Cardumem can work on the static site generation.
Finally, what I would like is to make SB to reuse Cardumem's syntax and hopefully some of its scripts. And make the bridge between both using Lua, not TypeScript. That's why I asked the short question at the beginning of this post.
Cheers,
Ps: While writing this, I remembered the Pascal quote: I made this one [letter] longer only because I have not had the leisure to make it shorter.
