Unable to set AutoIdentifierOptions to None / disable
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.
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.
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).
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).
I guess it is just here because the enum is a flag and it is recommended to always define (name) the
0value. That said I would have named itUndefinedto make sure nobody uses it.Alternatively the
UseAutoIdentifiersextension method could just check the option and if it isNonedo not add (or even remove in case it was already added).
Exactly, if I have time this weekend I'll write up a PR.
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.
...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.
yes, that's true 😉... so let's keep it as it is today with a proper comment on the None enum.