xoofx / xoofx/markdig

[Question] Syntax re-arrangement

Open
#190 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

PR Welcome! question
Dominant language
C#
Stars
5.3k
Forks
510
Avg merge
8d 5h
Merged PRs (30d)
5

Description

I stumble over an exception in the following process:

  1. Parse a markdown document
    The following example:
    **#1** This is the most important thing *ever*.
    
    **#2** For sure not. `Coding` is more important
    
  2. Analyze the syntax tree for certain patterns (e.g. first inline of paragraph is bold => Foo.Name = "#2")
  3. Re-Align some syntax elements (e.g. restructure remaining paragraph inlines into new InlineContainer)
  4. Normalize the re-aligned content of the paragraph (e.g. remaining text or whatever => Foo.Text = "For sure not. .....")

I had the expectation that I can re-arrange the syntax in step (3) without any issues. Similar what I would do with Newtonsoft.Json or System.Xml.Linq.

Actually the ContainerInline.AppendChild has explicit guard preventing adding a child which already has a parent.

Is there a reason for this behavior? Is there something we can do here (Cloning? Removing Guards? New Syntax concept? Alternatively, are there utilities to help me utilizing the Span information to retrieve the original text?).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ContainerInline.AppendChild guard described in the issue, then compare the proposed cloning, guard removal, new syntax concept, and Span-based alternatives. There is no named file or test; done would require a decided approach and a concrete, agreed scope for rearranging syntax-tree elements.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.