-
-
Notifications
You must be signed in to change notification settings - Fork 553
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
Export cmark_is_inline, cmark_is_block, cmark_is_leaf. #562
Conversation
[Non-breaking API change]
@nwellnhof @ioquatix how does this look to you? |
It looks okay, the only thing I'd suggest is (1) whether it can be inline and (2) how it will be compatible with forks like cmark-gfm. |
I'd prefer to name the functions
Inlining functions hardcodes the implementation in downstream code and makes it harder to change things without breaking the ABI.
What do you mean by "compatible"? What's the problem with different node type enum values? |
Presumably they will want to pull this change where possible for compatibility's sake. Considering that and making sure we don't clobber existing ABI that they have etc may be a nice gesture. |
Here's an idea for a more extensible API: typedef enum {
CMARK_NODE_CLASS_BLOCK = 1 << 0,
CMARK_NODE_CLASS_INLINE = 1 << 1,
CMARK_NODE_CLASS_LEAF = 1 << 2,
} cmark_node_class;
// Returns a bit mask of classes
cmark_node_class cmark_node_get_class(cmark_node *node); Usage: if (cmark_node_get_class(node) & CMARK_NODE_CLASS_BLOCK) {
...
} Or maybe call it |
I'd be okay with the proposed alternative API. Or, we could consider a more breaking change and follow cmark-gfm in building this information into the node type enums themselves, so that a separate Or, we could just go with the simple change above (emended to add I'm okay with any of these ideas, and don't really have strong feelings. |
For the sake of compatibility, I'd vote to replicate what |
cmark_is_block -> cmark_node_is_block and similarly for cmark_is_leaf, cmark_is_inline
For now I just made the change @nwellnhof requested ( |
I suggest we consider upstreaming https://github.com/github/cmark-gfm/blob/587a12bb54d95ac37241377e6ddc93ea0e45439b/src/cmark-gfm.h#L34-L78 and https://github.com/github/cmark-gfm/blob/587a12bb54d95ac37241377e6ddc93ea0e45439b/src/node.h#L138-L154. By doing this, we will improve consistency between |
@nwellnhof had some worries about ABI compatibility, and about the possibility that some users use hard-coded values that would change for the block types. So I went for the conservative change here. I'm open to the more radical change but would be interested in @nwellnhof's view. |
cmark-gfm exposes too many internals in their public header. It would be a lot better to downstream In general, it's the responsibility of downstream forks to keep compatibility. If you have any issues, I'd suggest to reach out to them first. |
I have. I didn't say it wasn't their responsibility, just that it would be generous to do so and make it easier for users and contributors. |
[Non-breaking API change]