feat: Initial Markdown support #396

Merged
wetneb merged 1 commit from wetneb/mergiraf:markdown into main 2025-05-20 22:31:04 +02:00
Owner

There isn't much structured merging I could think of here - the potential lies more in the merging inside code blocks via #5.

Sadly it requires to add a lot of atomic nodes, because otherwise the parser analyzes parts of tree like this:

      ├_section3
      │ ├atx_heading
      │ │ ├atx_h3_marker ###
      │ │ └heading_content: _line
      │ │   ├[
      │ │   ├]
      │ │   ├(
      │ │   ├:
      │ │   ├/
      │ │   ├/
      │ │   ├.
      │ │   ├/
      │ │   ├-
      │ │   ├/
      │ │   ├-
      │ │   ├-
      │ │   └)

This means that Mergiraf would ignore the text contents of paragraphs and other parts of prose, because it only sees the punctuation signs added as children underneath.

Given that the parser also gives up on creating nodes for inline links or other formatting marks, we also can't do commutative merging of those, but I guess that's not a big deal.

The atomic nodes I added come from parsing the demo markdown file at https://markdown-it.github.io/ and making sure all textual contents appear as they should. It can well be that I have missed some constructs not used in this demo - one could also go through the grammar definition to make sure everything needed is there.

There isn't much structured merging I could think of here - the potential lies more in the merging inside code blocks via #5. Sadly it requires to add a lot of atomic nodes, because otherwise the parser analyzes parts of tree like this: ``` ├_section3 │ ├atx_heading │ │ ├atx_h3_marker ### │ │ └heading_content: _line │ │ ├[ │ │ ├] │ │ ├( │ │ ├: │ │ ├/ │ │ ├/ │ │ ├. │ │ ├/ │ │ ├- │ │ ├/ │ │ ├- │ │ ├- │ │ └) ``` This means that Mergiraf would ignore the text contents of paragraphs and other parts of prose, because it only sees the punctuation signs added as children underneath. Given that the parser also gives up on creating nodes for inline links or other formatting marks, we also can't do commutative merging of those, but I guess that's not a big deal. The atomic nodes I added come from parsing the demo markdown file at https://markdown-it.github.io/ and making sure all textual contents appear as they should. It can well be that I have missed some constructs not used in this demo - one could also go through the grammar definition to make sure everything needed is there.
Author
Owner

@ada4a any concerns about this one?

@ada4a any concerns about this one?
Owner

Oh, sorry. I was meaning to look at grammar.js, but couldn't find the time.. But maybe we could enhance the grammar later on, and merge this one as is, since it looks fine to me.

Oh, sorry. I was meaning to look at `grammar.js`, but couldn't find the time.. But maybe we could enhance the grammar later on, and merge this one as is, since it looks fine to me.
ada4a approved these changes 2025-05-20 22:11:09 +02:00
wetneb merged commit c5c4362535 into main 2025-05-20 22:31:04 +02:00
wetneb referenced this pull request from a commit 2025-05-20 22:31:05 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: mergiraf/mergiraf#396
No description provided.