nvim-neorg / rust-norg

A robust parser for Norg for tools that don't use tree-sitter.
11 stars 3 forks source link

WIP - Unflatten the norg AST #3

Closed benlubas closed 1 month ago

benlubas commented 1 month ago

I was unable to get chumsky to do this without it absolutely destroying my sanity, so I just wrote this part manually.

I figure this is fine b/c, well. This step can never fail (with a parsing error). Assuming that the chumsky parser is correct, and this stage_4 is correct, there will never be an error here b/c there is no more room for a parsing error. We just have to make sure that stage_4 is always given the output of the chumsky parser.


This is the simplest thing I could think to do, it's not the fastest, but it's really easy.

Supports nestable detached mods and headings.

Currently, multiple level one list items that follow each other do not get grouped in any way. I'm not sure if this is technically the correct thing to do for all nestable detached modifiers, I can add this functionality if it is, in fact, correct.


--- and === syntax isn't currently parsed by the original parser. I'll work on that separately.


cc: @NTBBloodbath

benlubas commented 1 month ago

@vhyrro given the recent conversations, how should parse_tree handle carry over tags applied to headings like:

CarryoverTag {
    tag_type: Macro,
    name: [
        "something",
    ],
    parameters: [
        "hi",
    ],
    next_object: Heading {
        level: 1,
        title: [
            Text(
                "heading",
            ),
        ],
        extensions: [],
    },
},

My thought is that they should just be treated like a normal heading, right?

currently they're not supported

benlubas commented 1 month ago

reopening stacked on top of #4