Syntax extension API: allow to create extension nodes #89
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently it is not possible to create nodes defined by syntax extensions using the C API if they use the
opaque
field (e.g. the"table"
extension) because there is no way to correctly allocate this field without exposing the details of the syntax extension in question. Concretely this means that it is not possible to programmatically create documents containing syntax extension nodes.This PR adds a field
opaque_alloc_func
to thecmark_syntax_extension
struct of typewhich is supposed to fill the
opaque
field of acmark_node
in those syntax extensions that need it.Since this field must be allocated when creating the
cmark_node
, the functioncmark_node_new
has been extended to take acmark_syntax_extension *
argument:(a new function could be introduced for this purpose to avoid changing the signature of
cmark_node_new
.)What do you think? Do you find this approach reasonable? Opinions welcome!
Thanks!