Markdig outputs headings with id attribute and content #376

Closed
opened 2026-01-29 14:35:17 +00:00 by claunia · 9 comments
Owner

Originally created by @Abrahamlet on GitHub (Jul 1, 2020).

Hello,

When using Markdig, any headings I create get output as html with an id attribute. Not only that, the value of the id attribute is equivalent to the value of the headings themselves.

Here's some sample code:

var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().DisableHtml().Build();
var result = Markdig.Markdown.ToHtml("# Congrats, you're a million dollars richer -- in Monopoly money!", pipeline);

And here's the output:

<h1 id="Congrats, you're a million dollars richer -- in Monopoly money!">Congrats, you're a million dollars richer -- in Monopoly money!</h1>

Can someone tell me what I'm doing wrong here?

Thanks,
Abrahamlet

PS: If it helps, I'm using Markdig version 0.17.0

Originally created by @Abrahamlet on GitHub (Jul 1, 2020). Hello, When using Markdig, any headings I create get output as html with an id attribute. Not only that, the value of the id attribute is equivalent to the value of the headings themselves. Here's some sample code: ```c# var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().DisableHtml().Build(); var result = Markdig.Markdown.ToHtml("# Congrats, you're a million dollars richer -- in Monopoly money!", pipeline); ``` And here's the output: ```html <h1 id="Congrats, you're a million dollars richer -- in Monopoly money!">Congrats, you're a million dollars richer -- in Monopoly money!</h1> ``` Can someone tell me what I'm doing wrong here? Thanks, Abrahamlet PS: If it helps, I'm using Markdig version 0.17.0
claunia added the invalid label 2026-01-29 14:35:17 +00:00
Author
Owner

@xoofx commented on GitHub (Jul 10, 2020):

Don't know, maybe something is conflicting with DisableHtml, can you try without it?

@xoofx commented on GitHub (Jul 10, 2020): Don't know, maybe something is conflicting with `DisableHtml`, can you try without it?
Author
Owner

@Abrahamlet commented on GitHub (Jul 10, 2020):

Don't know, maybe something is conflicting with DisableHtml, can you try without it?

@xoofx I tried that. Issue persists.

@Abrahamlet commented on GitHub (Jul 10, 2020): > Don't know, maybe something is conflicting with `DisableHtml`, can you try without it? @xoofx I tried that. Issue persists.
Author
Owner

@xoofx commented on GitHub (Jul 10, 2020):

Can you try with latest version and show exactly the program you are running?

@xoofx commented on GitHub (Jul 10, 2020): Can you try with latest version and show exactly the program you are running?
Author
Owner

@xoofx commented on GitHub (Jul 10, 2020):

For instance on babelmark here Markdig is working correctly.

@xoofx commented on GitHub (Jul 10, 2020): For instance on babelmark [here](https://babelmark.github.io/?text=%23+Congrats%2C+you%27re+a+million+dollars+richer+--+in+Monopoly+money!) Markdig is working correctly.
Author
Owner

@Abrahamlet commented on GitHub (Jul 10, 2020):

Can you try with latest version and show exactly the program you are running?

For instance on babelmark here Markdig is working correctly.

Issue still persists.

My code looks like this (using VB.NET in LinqPad):

Dim pipeline = New MarkdownPipelineBuilder().UseAdvancedExtensions().DisableHtml().Build()
Dim value As String = Markdown.ToHtml("# Hey Isabelle, nice to meet you", pipeline)
Console.WriteLine("MarkdownToHtml...")
value.dump()

It doesn't matter if I use .DisableHtml or not. I get the same thing. And this is after upgrading from version 0.17.0 to 0.20.0.

@Abrahamlet commented on GitHub (Jul 10, 2020): > Can you try with latest version and show exactly the program you are running? > For instance on babelmark [here](https://babelmark.github.io/?text=%23+Congrats%2C+you%27re+a+million+dollars+richer+--+in+Monopoly+money!) Markdig is working correctly. Issue still persists. My code looks like this (using VB.NET in LinqPad): ``` Dim pipeline = New MarkdownPipelineBuilder().UseAdvancedExtensions().DisableHtml().Build() Dim value As String = Markdown.ToHtml("# Hey Isabelle, nice to meet you", pipeline) Console.WriteLine("MarkdownToHtml...") value.dump() ``` It doesn't matter if I use .DisableHtml or not. I get the same thing. And this is after upgrading from version 0.17.0 to 0.20.0.
Author
Owner

@xoofx commented on GitHub (Jul 10, 2020):

I just ran it and it is working:

image

So I don't know, maybe it is an issue with VB, maybe something else on your side.

@xoofx commented on GitHub (Jul 10, 2020): I just ran it and it is working: ![image](https://user-images.githubusercontent.com/715038/87172969-5e0db280-c2d5-11ea-934e-86d339646757.png) So I don't know, maybe it is an issue with VB, maybe something else on your side.
Author
Owner

@Abrahamlet commented on GitHub (Jul 10, 2020):

I just ran it and it is working:

image

So I don't know, maybe it is an issue with VB, maybe something else on your side.

It's not working. The h1 tag isn't supposed to have an ID attribute at all. Your results are the same as mine.

@Abrahamlet commented on GitHub (Jul 10, 2020): > I just ran it and it is working: > > ![image](https://user-images.githubusercontent.com/715038/87172969-5e0db280-c2d5-11ea-934e-86d339646757.png) > > So I don't know, maybe it is an issue with VB, maybe something else on your side. It's not working. The h1 tag isn't supposed to have an ID attribute at all. Your results are the same as mine.
Author
Owner

@xoofx commented on GitHub (Jul 11, 2020):

It's not working. The h1 tag isn't supposed to have an ID attribute at all. Your results are the same as mine.

Yes, it is working and it is super confusing.

You said:

the value of the id attribute is equivalent to the value of the headings themselves.

This is not what I see above when running it, and now you are saying "same as mine"

But also, why are you using advanced extensions in the first place then? Advanced extensions are activating - among others - the AutoIdentifier extension, so it is doing what you are asking for.

If you don't want ids, you should not use advanced extensions in your pipeline:

var pipeline = new MarkdownPipelineBuilder().Build();
@xoofx commented on GitHub (Jul 11, 2020): > It's not working. The h1 tag isn't supposed to have an ID attribute at all. Your results are the same as mine. Yes, it is working and it is super confusing. You said: > the value of the id attribute is equivalent to the value of the headings themselves. This is not what I see above when running it, and now you are saying "same as mine" But also, why are you using advanced extensions in the first place then? Advanced extensions are activating - among others - the [AutoIdentifier](https://github.com/lunet-io/markdig/blob/master/src/Markdig.Tests/Specs/AutoIdentifierSpecs.md) extension, so it is doing what you are asking for. If you don't want ids, you should not use advanced extensions in your pipeline: ``` var pipeline = new MarkdownPipelineBuilder().Build(); ```
Author
Owner

@Abrahamlet commented on GitHub (Jul 12, 2020):

It's not working. The h1 tag isn't supposed to have an ID attribute at all. Your results are the same as mine.

Yes, it is working and it is super confusing.

You said:

the value of the id attribute is equivalent to the value of the headings themselves.

This is not what I see above when running it, and now you are saying "same as mine"

But also, why are you using advanced extensions in the first place then? Advanced extensions are activating - among others - the AutoIdentifier extension, so it is doing what you are asking for.

If you don't want ids, you should not use advanced extensions in your pipeline:

var pipeline = new MarkdownPipelineBuilder().Build();

I didn't know using the advanced extensions made ids appear. I removed it and now it works as expected.

Thanks for your help, @xoofx

@Abrahamlet commented on GitHub (Jul 12, 2020): > > It's not working. The h1 tag isn't supposed to have an ID attribute at all. Your results are the same as mine. > > Yes, it is working and it is super confusing. > > You said: > > > the value of the id attribute is equivalent to the value of the headings themselves. > > This is not what I see above when running it, and now you are saying "same as mine" > > But also, why are you using advanced extensions in the first place then? Advanced extensions are activating - among others - the [AutoIdentifier](https://github.com/lunet-io/markdig/blob/master/src/Markdig.Tests/Specs/AutoIdentifierSpecs.md) extension, so it is doing what you are asking for. > > If you don't want ids, you should not use advanced extensions in your pipeline: > > ``` > var pipeline = new MarkdownPipelineBuilder().Build(); > ``` I didn't know using the advanced extensions made ids appear. I removed it and now it works as expected. Thanks for your help, @xoofx
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#376