refactor: express custom directives with standard markdown constructs
This commit is contained in:
parent
e5583bbd89
commit
46f12b10da
7 changed files with 558 additions and 454 deletions
22
README.md
22
README.md
|
|
@ -72,15 +72,25 @@ Everything the schema cannot express is checked here rather than on first reques
|
|||
|
||||
## Markdown
|
||||
|
||||
Markdown is parsed once per document into one representation that every output format reads, rather than once per format. Four directives sit outside CommonMark and are recognised before parsing, each occupying a whole line:
|
||||
Markdown is parsed once per document into one representation that every output format reads, rather than once per format. Everything itsybitsy adds to CommonMark is either a construct other tools already understand or invisible to them, so a document stays portable:
|
||||
|
||||
| Directive | Means |
|
||||
| Written | Means |
|
||||
| --- | --- |
|
||||
| `{.include path}` or `![[path]]` | splice that file's lines in here |
|
||||
| `#[label](art.txt)` | a verbatim block read from that file |
|
||||
| `{.card Title}` | a divider for formats that paginate; nothing for the rest |
|
||||
| `![[path]]` | splice that file's lines in here |
|
||||
| `` | an image whose target is a text file, inlined verbatim |
|
||||
| `<!-- card Title -->` | a card divider, for formats that paginate |
|
||||
| `---` | an untitled divider |
|
||||
| `<!-- center -->`, `<!-- right margin=4 -->` | alignment for the block that follows |
|
||||
|
||||
Include and art targets resolve relative to the including file and must stay inside the content root. Expansion is bounded on three axes — nesting depth, total lines, and total bytes — because a cycle check alone does not stop a long chain, and neither stops a diamond where two branches include the same file without ever repeating one on a single path.
|
||||
Only the include is non-standard, and it is the spelling Obsidian and its relatives established; CommonMark renders it as literal text, which is why it is the one construct handled before parsing. The rest are ordinary HTML comments and images, interpreted after parsing — so an HTML comment that is not a recognised directive stays a comment, at the cost of a misspelled one doing nothing rather than complaining.
|
||||
|
||||
Alignment only reaches the fixed-width text formats; gemtext and HTML have no way to express it. An art label may carry its own `:center`, `:left` or `:right` token, which is removed from the label so it does not leak into the fallback text a gemtext or HTML client shows.
|
||||
|
||||
Include and art targets resolve relative to the file holding the reference and must stay inside the content root. Expansion is bounded on three axes — nesting depth, total lines, and total bytes — because a cycle check alone does not stop a long chain, and neither stops a diamond where two branches include the same file without ever repeating one on a single path.
|
||||
|
||||
### Differences from smolweb
|
||||
|
||||
smolweb inherits five invented directives from its two renderer libraries: `{.card}`, `{.include}`, `![[ ]]`, `#[label](art.txt)` and MultiMarkdown attribute lists (`{: .center}`) — two incompatible brace grammars, with art alignment expressible two different ways in one line. None of it appeared in real content, so itsybitsy expresses the same capabilities with standard constructs instead. Parsing once rather than once per library also means the text formats gain setext headings and the WAP formats gain tables and ASCII art, none of which their original parser handled.
|
||||
|
||||
## URLs
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue