Unable to set AutoIdentifierOptions to None / disable #238

Closed
opened 2026-01-29 14:31:06 +00:00 by claunia · 7 comments
Owner

Originally created by @olafdemol on GitHub (Nov 7, 2018).

var pipeline = new MarkdownPipelineBuilder() .UseAutoIdentifiers(Markdig.Extensions.AutoIdentifiers.AutoIdentifierOptions.None) .Build();

Does not seem to do anything compared to Default or any of the other options. Maybe something is broken? My use case is that I want to use all of the AdvancedExtensions but disable the auto-identifier option.

Originally created by @olafdemol on GitHub (Nov 7, 2018). `var pipeline = new MarkdownPipelineBuilder() .UseAutoIdentifiers(Markdig.Extensions.AutoIdentifiers.AutoIdentifierOptions.None) .Build();` Does not seem to do anything compared to Default or any of the other options. Maybe something is broken? My use case is that I want to use all of the AdvancedExtensions but disable the auto-identifier option.
claunia added the question label 2026-01-29 14:31:06 +00:00
Author
Owner

@xoofx commented on GitHub (Nov 7, 2018):

new MarkdownPipelineBuilder(); will build only a CommonMark pipeline without any advanced extensions.

If you want to remove one extension, you could just create a builder with advanced, and remove the extension manually, something like this:

var builder = new MarkdownPipelineBuilder().UseAdvancedExtensions();
builder.Extensions.Remove(pipeline.Extensions.Find<AutoIdentifierExtension>());
var pipeline = builder.Build();

There is a missing method pipeline.Extensions.Remove<AutoIdentifierExtension>(); but otherwise, you should be able to do what you are looking for.

@xoofx commented on GitHub (Nov 7, 2018): `new MarkdownPipelineBuilder();` will build only a CommonMark pipeline without any advanced extensions. If you want to remove one extension, you could just create a builder with advanced, and remove the extension manually, something like this: ```C# var builder = new MarkdownPipelineBuilder().UseAdvancedExtensions(); builder.Extensions.Remove(pipeline.Extensions.Find<AutoIdentifierExtension>()); var pipeline = builder.Build(); ``` There is a missing method `pipeline.Extensions.Remove<AutoIdentifierExtension>();` but otherwise, you should be able to do what you are looking for.
Author
Owner

@olafdemol commented on GitHub (Nov 8, 2018):

Thanks for the quick reply!

One thing I'm wondering about is what Markdig.Extensions.AutoIdentifiers.AutoIdentifierOptions.None actually does. In my case it did not seem to be any different from Markdig.Extensions.AutoIdentifiers.AutoIdentifierOptions.Default. I assumed none would mean the option was disabled, however it acts the same as default. Is this a bug? (I was not using .UseAdvancedExtensions() in this case).

@olafdemol commented on GitHub (Nov 8, 2018): Thanks for the quick reply! One thing I'm wondering about is what `Markdig.Extensions.AutoIdentifiers.AutoIdentifierOptions.None` actually does. In my case it did not seem to be any different from `Markdig.Extensions.AutoIdentifiers.AutoIdentifierOptions.Default`. I assumed _none_ would mean the option was disabled, however it acts the same as _default_. Is this a bug? (I was not using `.UseAdvancedExtensions()` in this case).
Author
Owner

@Kryptos-FR commented on GitHub (Nov 8, 2018):

I guess it is just here because the enum is a flag and it is recommended to always define (name) the 0 value. That said I would have named it Undefined to make sure nobody uses it.

Alternatively the UseAutoIdentifiers extension method could just check the option and if it is None do not add (or even remove in case it was already added).

@Kryptos-FR commented on GitHub (Nov 8, 2018): I guess it is just here because the enum is a flag and it is recommended to always define (name) the `0` value. That said I would have named it `Undefined` to make sure nobody uses it. Alternatively the `UseAutoIdentifiers` extension method could just check the option and if it is `None` do not add (or even remove in case it was already added).
Author
Owner

@olafdemol commented on GitHub (Nov 8, 2018):

I guess it is just here because the enum is a flag and it is recommended to always define (name) the 0 value. That said I would have named it Undefined to make sure nobody uses it.

Alternatively the UseAutoIdentifiers extension method could just check the option and if it is None do not add (or even remove in case it was already added).

Exactly, if I have time this weekend I'll write up a PR.

@olafdemol commented on GitHub (Nov 8, 2018): > I guess it is just here because the enum is a flag and it is recommended to always define (name) the `0` value. That said I would have named it `Undefined` to make sure nobody uses it. > > Alternatively the `UseAutoIdentifiers` extension method could just check the option and if it is `None` do not add (or even remove in case it was already added). Exactly, if I have time this weekend I'll write up a PR.
Author
Owner

@xoofx commented on GitHub (Nov 8, 2018):

Not sure I want to change the name (it would be a breaking change). We should maybe better just throw an exception if None is passed.

@xoofx commented on GitHub (Nov 8, 2018): Not sure I want to change the name (it would be a breaking change). We should maybe better just throw an exception if None is passed.
Author
Owner

@stevehurcombe commented on GitHub (Nov 8, 2018):

...but that too would be a breaking change, a worse one because it's at runtime instead of compile time. Probably best to update the documentation or rename it. It's an easy compile time edit.

@stevehurcombe commented on GitHub (Nov 8, 2018): ...but that too would be a breaking change, a worse one because it's at runtime instead of compile time. Probably best to update the documentation or rename it. It's an easy compile time edit.
Author
Owner

@xoofx commented on GitHub (Nov 8, 2018):

yes, that's true 😉... so let's keep it as it is today with a proper comment on the None enum.

@xoofx commented on GitHub (Nov 8, 2018): yes, that's true 😉... so let's keep it as it is today with a proper comment on the None enum.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#238