-
-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the two wikilinks extensions mutually exclusive (and other assorted improvements) #497
base: main
Are you sure you want to change the base?
Conversation
In general you're right, they should be mutually exclusive. But it seems reasonable that the behavior is undefined if you set both of them 😄 Also, doesn't this change break backward compatibility? 🤔 |
I see you're a fan of nasal demons.
Yes, unfortunately. I started out by deprecating the booleans in the builder and writing custom setters to make them behave properly, but I'm not particularly experienced with the bon crate. |
There is this guide about adding custom setters, although I pointed right in the middle of it. |
However do we need this backwards-compat crutch at all though? @digitalmoksha WDYT, maybe a breaking change is fine if this API is not widely used? |
TIL about nasal demons! @Veetaha @SamWilsn well, I don't know how many people are using it. I know I am. And commonmarker uses it, and I did see it integrated into at least one other package that uses comrak, but I can't find it right now. I modeled this off of Pandoc's syntax. And it mentions in the release notes
I think I would come down on the side of mimicking Pandoc's behavior, without a breaking change. |
You don't find that behaviour somewhat unexpected? IMO, if a weird state can be made impossible, it should be. |
Not really - it does something sensible. It's a forgiving interface. Same way in many systems if you specify an option multiple times, the last one gets used, as opposed to generating a hard error. (I checked, However I think it would be ok to generate an error for this. But what does that look like when using the API, where every entry point returns a |
Makes sense. However, I believe the path of least disruption would indeed be to keep the old boolean setters for backwards compat (they just set the internal enum value). Then, mark them with Note that this will still be a breaking change for people that have this pattern in their code: .wikilinks_title_after_pipe(true)
.wikilinks_title_before_pipe(true) I.e. if they call both setters. This is because |
wrong code posted before. what about let mut comrak_options = comrak::ComrakOptions::default();
comrak_options.extension.wikilinks_title_after_pipe = true;
comrak_options.extension.wikilinks_title_before_pipe = true; edit: the values are typically provided by another set of options |
Having to preserve the pub fields in the struct is why I abandoned backwards compatibility. |
Noticed some weirdness with the commonmark formatter and having both extensions enabled (
[[title|url|title]]
kind of thing.)