Skip to content

Document custom block and inline nodes in the C API - #664

Open
doomfrawen wants to merge 1 commit into
commonmark:masterfrom
doomfrawen:docs/custom-node-types
Open

doomfrawen wants to merge 1 commit into
commonmark:masterfrom
doomfrawen:docs/custom-node-types

Conversation

@doomfrawen

Copy link
Copy Markdown
Contributor

Closes #441

Explain who creates custom nodes, which children each type accepts, and how to wrap inline children in HTML using the enter and exit setters. The same example now appears in cmark.h and the generated cmark(3) manual.

Comment thread src/cmark.h
Comment on lines +32 to +42
*
* Only applications create `CMARK_NODE_CUSTOM_BLOCK` and
* `CMARK_NODE_CUSTOM_INLINE` nodes. A filter can create one
* with `cmark_node_new` and insert it into the syntax tree after parsing.
* A custom block can contain block or inline children. A custom inline
* can contain inline children.
*
* For example, to highlight the children of a custom inline in HTML,
* use `cmark_node_set_on_enter` for the opening `<mark>` tag and
* `cmark_node_set_on_exit` for the closing `</mark>` tag. The HTML
* renderer writes these strings literally before and after the children.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to move this til after the definition. In this position one expects a preamble to the whole type definition, not an addendum-like comment about one particular node type.

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.

API documentation is missing an explanation of CMARK_NODE_CUSTOM_BLOCK and CMARK_NODE_CUSTOM_INLINE

2 participants