commonmark / cmark

CommonMark parsing and rendering library and program in C
Other
1.63k stars 546 forks source link

Make `CMARK_OPT_UNSAFE` settable during runtime #477

Closed hinell closed 1 year ago

hinell commented 1 year ago

Hi. I'm linking against library and would like to be able to set CMARK_OPT_UNSAFE via method options,

Currently it's respected only during compile time and in cli binary.

Thanks!

nwellnhof commented 1 year ago

Currently it's respected only during compile time and in cli binary, which.

This isn't true. CMARK_OPT_UNSAFE can be passed to several API functions at runtime.

hinell commented 1 year ago

@nwellnhof No doubt about that but is there any way oen can pass it to the ... cmark_markdown_to_html(...) call? Thanks.

nwellnhof commented 1 year ago

Here's the declaration of cmark_markdown_to_html:

char *cmark_markdown_to_html(const char *text, size_t len, int options);

Just pass CMARK_OPT_UNSAFE, maybe ORed with other flags, as options argument.

hinell commented 1 year ago

@nwellnhof Sorry, didn't notice the definitions. They are buried below, which is kinda surprising:

https://github.com/commonmark/cmark/blob/7195c6735f29be947ddc41f86c9ddfc8621d33b9/src/cmark.h#L545-L571

Thanks!