Skip to content

Conversation

@gjtorikian
Copy link
Collaborator

What the title says!

ComrakOptions::default() sets the header_ids option of extensions to ""; this means that, by default, headers are always given anchor tags (with an ID matching the text content of the header).

In C, there's currently no way of implementing the removal of the header_ids option. This won't work:

comrak_set_extension_option_header_ids(comrak_options, "", 0);

Because it reads just as default does: add the header IDs, but don't add any prefix.

This PR introduces (and tests) a different possibility:

comrak_set_extension_option_header_ids(comrak_options, NULL, 0);

Passing this ☝️ will effectively "turn off" header ID generation by checking to see if the incoming value is NULL. (Some kind of NULL check is necessary here, with or without this change. I was able to segfault the FFI.)

I'm happy to expose a different function to configure this if it doesn't look good!

@kivikakk
Copy link
Owner

kivikakk commented Aug 1, 2022

This is just perfect, thanks! We might want to be able to turn the other optional string options back off, too, and this allows for that nicely.

@kivikakk kivikakk merged commit f1222b3 into main Aug 1, 2022
@kivikakk kivikakk deleted the no-header-id-no-cry branch August 1, 2022 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants