[AutoIdentifiers] Not created when rendering a MarkdownDocument #545

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

Originally created by @hangar18rip on GitHub (Jun 24, 2022).

Hi,

I get the following issue with the AutoIdentifierExtension.

Repro step

Using this code:

var pipeline = new MarkdownPipelineBuilder().UseAutoIdentifiers(AutoIdentifierOptions.GitHub).Build();
var input = "# Hey Isabelle, nice to meet you";

var res = Markdig.Markdown.ToHtml(input, pipeline);
Trace.TraceInformation(res);

var doc = Markdig.Markdown.Parse(input);
var res2 = Markdig.Markdown.ToHtml(doc, pipeline);
Trace.TraceInformation(res2);

It gives me this result:

res = <h1 id=\"hey-isabelle-nice-to-meet-you\">Hey Isabelle, nice to meet you</h1>\n
res2 = <h1>Hey Isabelle, nice to meet you</h1>\n

The content of res is the expected result.

Workaround

var doc = MarkdownParser.Parse(content, pipeline, null);

or

var doc = Markdig.Markdown.Parse(content, pipeline);
Originally created by @hangar18rip on GitHub (Jun 24, 2022). Hi, I get the following issue with the `AutoIdentifierExtension`. # Repro step Using this code: ```csharp var pipeline = new MarkdownPipelineBuilder().UseAutoIdentifiers(AutoIdentifierOptions.GitHub).Build(); var input = "# Hey Isabelle, nice to meet you"; var res = Markdig.Markdown.ToHtml(input, pipeline); Trace.TraceInformation(res); var doc = Markdig.Markdown.Parse(input); var res2 = Markdig.Markdown.ToHtml(doc, pipeline); Trace.TraceInformation(res2); ``` It gives me this result: res = `<h1 id=\"hey-isabelle-nice-to-meet-you\">Hey Isabelle, nice to meet you</h1>\n` res2 = `<h1>Hey Isabelle, nice to meet you</h1>\n` The content of res is the expected result. # Workaround ```csharp var doc = MarkdownParser.Parse(content, pipeline, null); ``` or ```csharp var doc = Markdig.Markdown.Parse(content, pipeline); ```
claunia added the invalid label 2026-01-29 14:39:19 +00:00
Author
Owner

@MihaZupan commented on GitHub (Jun 24, 2022):

You have to pass the pipeline to Markdown.Parse as well

@MihaZupan commented on GitHub (Jun 24, 2022): You have to pass the pipeline to `Markdown.Parse` as well
Author
Owner

@hangar18rip commented on GitHub (Jun 24, 2022):

thanks @MihaZupan, I have it now but this was not very intuitive ;) Why should I pass the pipeline to both parse the document AND to render it. Maybe it can be a future improvment 😉

@hangar18rip commented on GitHub (Jun 24, 2022): thanks @MihaZupan, I have it now but this was not very intuitive ;) Why should I pass the pipeline to both parse the document AND to render it. Maybe it can be a future improvment 😉
Author
Owner

@xoofx commented on GitHub (Jun 26, 2022):

I have it now but this was not very intuitive ;) Why should I pass the pipeline to both parse the document AND to render it. Maybe it can be a future improvement

The pipeline contains both the configured parsers and the configured renderers.

For the case of the auto-identifier extension, the extension hooks into existing parsers.

5f80d86265/src/Markdig/Extensions/AutoIdentifiers/AutoIdentifierExtension.cs (L35-L51)

In that case, the renderer is not modified (because the heading renderer is registered by default), but for others, they require to register their renderers as well:

5f80d86265/src/Markdig/Extensions/Abbreviations/AbbreviationExtension.cs (L15-L26)

@xoofx commented on GitHub (Jun 26, 2022): > I have it now but this was not very intuitive ;) Why should I pass the pipeline to both parse the document AND to render it. Maybe it can be a future improvement The pipeline contains both the configured parsers and the configured renderers. For the case of the auto-identifier extension, the extension hooks into existing parsers. https://github.com/xoofx/markdig/blob/5f80d86265fbcfccc0c452ca88c46f35b31c4dfa/src/Markdig/Extensions/AutoIdentifiers/AutoIdentifierExtension.cs#L35-L51 In that case, the renderer is not modified (because the heading renderer is registered by default), but for others, they require to register their renderers as well: https://github.com/xoofx/markdig/blob/5f80d86265fbcfccc0c452ca88c46f35b31c4dfa/src/Markdig/Extensions/Abbreviations/AbbreviationExtension.cs#L15-L26
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#545