MichaelHatherly / CommonMark.jl

A CommonMark-compliant Markdown parser for Julia.
Other
84 stars 11 forks source link

Make sure enable! and disable! do not duplicate rules #46

Closed mortenpi closed 2 years ago

mortenpi commented 2 years ago

I believe this should fix #45.

However, in order to use in to determine if a particular rule is present in p.rules, I also have to add some overloads for == for the *Rules that have some internal fields. I assume it is fine to consider two e.g. FootnoteRules equal, even in their caches differ? For now, I only added the overloads for FootnoteRule and TableRule, but if these overloads are fine, I can also add them to other rules that have fields.

MichaelHatherly commented 2 years ago

Unsure about overloading == here, perhaps it would make sense to just have a separate internal function for checking whether a rule already exists.

mortenpi commented 2 years ago

Unsure about overloading == here, perhaps it would make sense to just have a separate internal function for checking whether a rule already exists.

That also crossed my mind, will change to that.

mortenpi commented 2 years ago

Updated. Added a function is_same_rule that could be overloaded if need be, but I assume the default implementation should work for all the current rules. Do you want me to add override! right away too?