Can't parse right for **Bold_ItalicInlineCode_Bold** #721

Closed
opened 2026-01-29 14:43:51 +00:00 by claunia · 3 comments
Owner

Originally created by @idea-zone on GitHub (Feb 2, 2025).

If I try to run the code:

Case1: how can i use "_" to mark Italic

           string markdown="**Bold_Italic`InlineCode`_Bold**";
            var pipeline = new MarkdownPipelineBuilder()
                .UseEmphasisExtras()
                .UseAdvancedExtensions()
                .UseEmojiAndSmiley()
                .UseAutoLinks()
                .UseTaskLists()
                .UseMediaLinks()
                .Build();

            processedInlines.Clear();
            var text = Markdown.ToHtml(markdown, pipeline)

The result is: (But It's not what I want)

<p><strong>Bold_Italic<code>InlineCode</code>_Bold</strong></p>

I want

<p><strong>Bold<em>Italic<code>InlineCode</code><em>Bold</strong></p>

Case2: Why Can't I parse **Bold*Italic*Bold** to right style?

AND if I use

 string markdown="**Bold*Italic`InlineCode`*Bold**"`;
            var pipeline = new MarkdownPipelineBuilder()
                .UseEmphasisExtras()
                .UseAdvancedExtensions()
                .UseEmojiAndSmiley()
                .UseAutoLinks()
                .UseTaskLists()
                .UseMediaLinks()
                .Build();

            processedInlines.Clear();
            var text = Markdown.ToHtml(markdown, pipeline)

It's give me the wrong result here:

<p>**Bold<em>Italic<code>InlineCode</code><em>Bold</em></em></p>
Originally created by @idea-zone on GitHub (Feb 2, 2025). If I try to run the code: ## Case1: how can i use "_" to mark Italic ~~~C# string markdown="**Bold_Italic`InlineCode`_Bold**"; var pipeline = new MarkdownPipelineBuilder() .UseEmphasisExtras() .UseAdvancedExtensions() .UseEmojiAndSmiley() .UseAutoLinks() .UseTaskLists() .UseMediaLinks() .Build(); processedInlines.Clear(); var text = Markdown.ToHtml(markdown, pipeline) ~~~ The result is: (But It's not what I want) ~~~ <p><strong>Bold_Italic<code>InlineCode</code>_Bold</strong></p> ~~~ I want ~~~ <p><strong>Bold<em>Italic<code>InlineCode</code><em>Bold</strong></p> ~~~ ## Case2: Why Can't I parse `**Bold*Italic*Bold**` to right style? AND if I use ~~~ string markdown="**Bold*Italic`InlineCode`*Bold**"`; var pipeline = new MarkdownPipelineBuilder() .UseEmphasisExtras() .UseAdvancedExtensions() .UseEmojiAndSmiley() .UseAutoLinks() .UseTaskLists() .UseMediaLinks() .Build(); processedInlines.Clear(); var text = Markdown.ToHtml(markdown, pipeline) ~~~ It's give me the wrong result here: ~~~ <p>**Bold<em>Italic<code>InlineCode</code><em>Bold</em></em></p> ~~~
claunia added the invalid label 2026-01-29 14:43:51 +00:00
Author
Owner

@xoofx commented on GitHub (Feb 2, 2025):

The rule is not easy and detailed in the spec in Emphasis and strong emphasis (left-flanking / right-flanking rules).

So both results are correct according to the specs.

@xoofx commented on GitHub (Feb 2, 2025): The rule is not easy and detailed in the spec in [Emphasis and strong emphasis](https://spec.commonmark.org/0.31.2/#emphasis-and-strong-emphasis) (left-flanking / right-flanking rules). So both results are correct according to the specs.
Author
Owner

@xoofx commented on GitHub (Feb 2, 2025):

You can verify that all other CommonMark engine are generating the same correct result here

@xoofx commented on GitHub (Feb 2, 2025): You can verify that all other CommonMark engine are generating the same correct result [here](https://babelmark.github.io/?text=**Bold_Italic%60InlineCode%60_Bold**)
Author
Owner

@tats-u commented on GitHub (Nov 13, 2025):

For Chinese text:

@tats-u commented on GitHub (Nov 13, 2025): For Chinese text: - #890
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#721