Parsing triple backticks with langage name #358

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

Originally created by @NikRimington on GitHub (Apr 4, 2020).

Hi,

This is more of a help question than an issue, however markdig indicates that it works to the CommonMark standard which, as I understand it, is capable of parsing code in the format of:
image

However when I parse it, this is the output:
image

I'm trying to parse my markdown code so I can use something like Prism for front end syntax higlighting, however it's not parsing the block at all when I add the language name.

This is how I'm parsing it:

var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
var result = Markdown.ToHtml(inter == null ? string.Empty : (string)inter, pipeline);

Where inter is a string value passed into an object, e.g. public object ParseValue(object inter) (the method is part of an interface hence the object return type and input type however it cannot be changed.

Any ideas why it's not parsing the codeblock would be greatly appreciated.

Many thanks,

Nik

Originally created by @NikRimington on GitHub (Apr 4, 2020). Hi, This is more of a help question than an issue, however markdig indicates that it works to the CommonMark standard which, as I understand it, is capable of parsing code in the format of: ![image](https://user-images.githubusercontent.com/13313745/78454814-5618f380-7692-11ea-8bbb-ff417c54b3be.png) However when I parse it, this is the output: ![image](https://user-images.githubusercontent.com/13313745/78454836-7648b280-7692-11ea-9a9f-beab4d756153.png) I'm trying to parse my markdown code so I can use something like Prism for front end syntax higlighting, however it's not parsing the block at all when I add the language name. This is how I'm parsing it: ``` var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build(); var result = Markdown.ToHtml(inter == null ? string.Empty : (string)inter, pipeline); ``` Where inter is a string value passed into an object, e.g. `public object ParseValue(object inter)` (the method is part of an interface hence the object return type and input type however it cannot be changed. Any ideas why it's not parsing the codeblock would be greatly appreciated. Many thanks, Nik
claunia added the invalid label 2026-01-29 14:34:50 +00:00
Author
Owner
@AdmiringWorm commented on GitHub (Apr 4, 2020): Seems to be reproducible on babelmark as well: https://babelmark.github.io/?text=%23+This+is+a+header%0A%23%23+This+is+a+level+2+heading%0A%0A%3Cp+class%3D%22text-xl%22%3E%0AThis+is+a+normal+paragraph%0A%3C%2Fp%3E%0A%60%60%60css%0AThis+is+code+in+three+%60%27s%0A%60%60%60 However, it works as expected when there is an empty line between the `</p>` and ```` ```css```` https://babelmark.github.io/?text=%23+This+is+a+header%0A%23%23+This+is+a+level+2+heading%0A%0A%3Cp+class%3D%22text-xl%22%3E%0AThis+is+a+normal+paragraph%0A%3C%2Fp%3E%0A%0A%60%60%60css%0AThis+is+code+in+three+%60%27s%0A%60%60%60 I don't know if this is intended or a bug in markdig though.
Author
Owner

@NikRimington commented on GitHub (Apr 4, 2020):

Ohh, I can work with that as a work around if it is a bug. I'm fairly new to markdown in general (at least the nuances of it at least) so if it's meant to have the extra space that's no problem :) Thanks you!

@NikRimington commented on GitHub (Apr 4, 2020): Ohh, I can work with that as a work around if it is a bug. I'm fairly new to markdown in general (at least the nuances of it at least) so if it's meant to have the extra space that's no problem :) Thanks you!
Author
Owner

@xoofx commented on GitHub (Apr 4, 2020):

It's not a bug, you need an empty line after the closing html tag. Other CommonMark have similar behavior.

@xoofx commented on GitHub (Apr 4, 2020): It's not a bug, you need an empty line after the closing html tag. Other CommonMark have similar behavior.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#358