You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, within Norg, there are two ways of applying a macro onto an object. The weak carryover tag (+this) and the strong carryover tag (#this). These exist because a user may want to apply a macro non-recursively as well as recursively.
There are many problems with this old syntax. In the end, it boils down to the following snippet:
- Hello
-- Hello
+color red
- World!
According to the specification, this should be a single list. A parser like tree-sitter cannot parse this, however - when parsing list items, a DEDENT node can optionally be produced by the parser to specify that a list has "dedented". To determine if such a dedent should be produced, the parser can look ahead to the next line to count the number of -s and determine the nesting level of the next item.
When there is a tag above the list item, the parser cannot look ahead to the next set of -s and parse the carryover tag simultaneously. Thus, the best it can do is create a separate list in the syntax tree. This is not desired behaviour.
This proposal makes carryover tags inline, thus permitting new placement in the AST. When a tag is placed above an object (like a list), that list is then treated separately, as it should be. Therefore:
- List item one
#tag
- List item two
are two completely separate lists.
To alter the list item itself, one can inline the tag:
- List item one
- #tag
List item two
Now parsing succeeds, and the example creates one single list.
Further Considerations
This change is highly coupled with a different change called "Make Attributes and Macros Separate". In that change we will describe a third way of applying a macro to an object.
With this new proposal, there are only two ways of invoking a macro. Either:
On a whole object (like a whole list)
On the paragraph inside a list item (but not the item itself).
The attribute/macro proposal will introduce the third way :)
The text was updated successfully, but these errors were encountered:
This proposal will only allow the placement of + and # "inline" where inline means at the beginning of a line with an optional detached modifier in front, correct?
Currently, within Norg, there are two ways of applying a macro onto an object. The weak carryover tag (
+this
) and the strong carryover tag (#this
). These exist because a user may want to apply a macro non-recursively as well as recursively.There are many problems with this old syntax. In the end, it boils down to the following snippet:
According to the specification, this should be a single list. A parser like tree-sitter cannot parse this, however - when parsing list items, a DEDENT node can optionally be produced by the parser to specify that a list has "dedented". To determine if such a dedent should be produced, the parser can look ahead to the next line to count the number of
-
s and determine the nesting level of the next item.When there is a tag above the list item, the parser cannot look ahead to the next set of
-
s and parse the carryover tag simultaneously. Thus, the best it can do is create a separate list in the syntax tree. This is not desired behaviour.This proposal makes carryover tags inline, thus permitting new placement in the AST. When a tag is placed above an object (like a list), that list is then treated separately, as it should be. Therefore:
are two completely separate lists.
To alter the list item itself, one can inline the tag:
Now parsing succeeds, and the example creates one single list.
Further Considerations
This change is highly coupled with a different change called "Make Attributes and Macros Separate". In that change we will describe a third way of applying a macro to an object.
With this new proposal, there are only two ways of invoking a macro. Either:
The attribute/macro proposal will introduce the third way :)
The text was updated successfully, but these errors were encountered: