-
Notifications
You must be signed in to change notification settings - Fork 18
Description
The Event enum of Jotdown is currently quite high-level. For example for this span:
what{a=test}
Jotdown generates the events:
(Start(Span, {a="test"}), 0..0)
(Str("what"), 0..4)
(End(Span), 4..12)
While djot.js generates the events:
,{ startpos: 0, endpos: 3, annot: "str" }
,{ startpos: 4, endpos: 4, annot: "+attributes" }
,{ startpos: 5, endpos: 5, annot: "key" }
,{ startpos: 6, endpos: 6, annot: "attr_equal_marker" }
,{ startpos: 7, endpos: 10, annot: "value" }
,{ startpos: 11, endpos: 11, annot: "-attributes" }
I think having more fine-grained events is quite valuable for all use cases that care about individual syntax tokens such as syntax highlighting or auto formatting. While it has been suggested to add more low-level details to Jotdown's existing Event types I think this would make for a rather awkward API. Also finer-grained events would enable API users to avoid unnecessary allocations, e.g. if you don't care about attributes at all you can simply skip over the events (whereas the current Event type always allocates a Vec for attributes). If you don't care about low-level events you probably want to use an AST anyway (#17), so I think it would be worthwhile to replace the current Event type with a more fine-grained one.