-
Notifications
You must be signed in to change notification settings - Fork 16
Description
We can't just say "There will be parsers not following the spec eventually" and let them do what they want. That's exactly what happened to Markdown (every parser claims to support CommonMark & GFM. Which means they don't) and I hope Norg to be better than that.
Yes, there will be parsers not following the rules. But if they don't follow the rule, they should be defined as non-compliant parsers.
ー from #53 (comment)
Current 5 layers are overlapping each other in a very complex way. Many grammars are spread all over the 5 layers to satisfy expected use-cases of each layers. Linkables are introduced from layer 1 but finalized in layer 5.
Having generalized, extendable, simpler definition of layer system would be better.
If proper adaptation is easier, we will have less incomplete, dialect specs.
Background ideas:
v1 spec tried to include as much syntax as possible, but end up having massive inline grammar while still missing things like citations.
So new spec should better follow:
- All layers should be extendable because we can't expect every use-cases.
- Have less first-class syntax as possible. Generalize more with macros.
Rearranged layer system
- Layer 1: only inline spec. But complete implementation of it. This even includes inline macros but doesn't force to implement same macro system using Janet.
- Layer 2: all, complete syntax. Parser should be able to parse all grammars. Macro system is still not forced.
- Layer 3: all complete syntax and janet-based macro system.
| Syntax compatibility | Macro system compatibility | |
|---|---|---|
| Layer 1 | Only inline spec | No |
| Layer 2 | Yes | No |
| Layer 3 | Yes | Yes |
Most implementations will safely fall to one of these three layers.
If they don't satisfy syntax compatibility, they are just different syntax.
If they don't implement macro system, it's fine. They still have place called "Layer 2".
With less, generalized syntax, we can make it easier to implement complete (or inline-complete) norg syntax. Resulting easier adoptaion. All hard parts are belonged to the macro system which can be packed as standard library.
Some ground works:
- [Suggestion]: Rethinking footnotes/definitions #48 will completely remove the range-able detached modifier from spec.
- [Suggestion]: Multi line heading #51 and [Suggestion]: Table syntax proposal #55 are attempt to implement table without creating completely new category.
- [Suggestion]: Allow all unclosed inline markups #53 will define strict rule for unclosed inline markups. Establishing strict rule for layer 1.
- [Discussion]: Inline macro with
\macrostyle #54 can potentially replace niche inline syntax like spoiler, superscript, subscript, extendable link, inline target and so on. - [Suggestion]: Reimplement wikilinks with anchors #56 will remove wiki link target