xoofx / xoofx/markdig

How can i print the original Inline code instead of the converted text?

Open
#766 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
C#
Stars
5.3k
Forks
510
Avg merge
11d 3h
Merged PRs (30d)
6

Description

What I am trying to do is to parse only headers and then get the original text without parsing the string.
Something like:

# This is a header
Hello **everyone** this is a list:
- Item 1;
- Item 2

And I've done something like this:

      string chapterContent = "";
      foreach (var element in document.Descendants()) {
                    if (element is HeadingBlock header) {
                        var chapterTitle = header.Inline.FirstChild.ToString().Trim();
                    }
                    else if(element is ParagraphBlock paragraph) {
                        chapterContent += paragraph.Inline.FirstChild.ToString()
                    }
      }

But The result is:
Hello everyone this is a list: Item 1; Item 2

Instead of:

Hello **everyone** this is a list:
- Item 1;
- Item 2

Because I want to maintain the original code, then I suppose the "ToString()" is not what I am looking for.

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 by tracing how HeadingBlock and ParagraphBlock expose their Inline content and what ToString() returns for those nodes. Determine whether the parser retains the original Markdown source for the requested elements; done means extracting the heading and surrounding text with emphasis and list markers preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, markdown
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.