Closed phillmv closed 2 years ago
I think in theory this makes sense, I'll have to think a little more on whether it could potentially affect downstream consumers (i.e. a breaking change). Regardless, though, adding a test to validate the behavior of the "mixing" of options would be great here.
Considering options were only added & not removed, I suspect we should be OK downstream. I'll add a test to exercise the options.
Test pass locally, so now CI should be more pliant.
I tweaked some minor tests & added a very basic smoke-test that just exercises receiving every parse & render option. I wasn't sure how else to structure it - writing a test case to exercise every single option is hard! - but I feel reasonably OK with this.
Thank you for your attention Garen, and do let me know if there's anything else you'd like me to add 😄.
Thanks, I'll push this out as a patch release now.
Hullo!
This PR "normalizes" the option bit mask flags that are made available as
parse
andrender
options respectively.Why?
When you use
CommonMarker.render_html
we load up:render
options, and when you useCommonMarker.render_doc
we load up:parse
options.This makes sense; some options are only available to the html renderer, and it doesn't make sense to pass them down to the parser.
However, both
render_html
andrender_doc
initialize the parser with the provided options masked integer. Assuming that I'm looking at the right code, bothrb_parse_document
andrb_markdown_to_html
take aVALUE rb_options
and pass it directly on toprepare_parser
alaConsequently, I think every parse option should also be available as a render option.
How?
I looked up each individual flag, sorted them by the order in which they appear in
cmark-gfm.h
, and then grepped to see whether the option is checked inside a)inlines.c
andblocks.c
(parse) or b) if insidehtml.c
or a relevant extension (render).I then copied over all of the parse flags into the render hash and sorted them by the order in which they appear in
cmark-gfm.h
. I applied the same sorting to the README.I have left comments accordingly tracing this. Hopefully this PR passes CI!
Cheers,