Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion]: Allow Inline Carryover Tag Placement #37

Open
vhyrro opened this issue Jul 21, 2024 · 1 comment
Open

[Suggestion]: Allow Inline Carryover Tag Placement #37

vhyrro opened this issue Jul 21, 2024 · 1 comment

Comments

@vhyrro
Copy link
Member

vhyrro commented Jul 21, 2024

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 :)

@mrossinek
Copy link
Member

To be explicit about the coupling with #38:

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants