cmark

  1. cmark
    1. Description
    2. API
      1. High Level Procedures
      2. Low Level Procedures
      3. Constants
    3. Source Code / Issues
    4. License
    5. Releases

Description

This egg is a wrapper for the native commonmark library. It includes markdown to sxml capabilities and can function as a drop-in replacement for lowdown with higher performance.

The cmark->sxml tests use the entire Markdown Testsuite to verify correctness. As a consequence of this, cmark does not generate the exact sxml as lowdown. One could argue cmark's sxml is better than lowdown's.

This is an entirely new codebase from the Chicken 4 version of cmark. However, aliases have been provided to make this egg backwards compatible when upgrading from Chicken 4 to Chicken 5.

API

High Level Procedures

For most common use cases, you'll need cmark->sxml and cmark->html.

[procedure] (cmark->sxml s)

Convert markdown string to sxml. Useful if you want to use sxml as an intermediate format and programmatically manipulate the document structure.

[procedure] (cmark->html input #!key (safe? t))

Convert commonmark markdown string to html string.

[procedure] (commonmark->html input #!key (safe? t))

Alias for cmark->html.

Low Level Procedures

The rest of the api is for more advanced use cases like writing your own commonmark renderer.

[procedure] (cmark-parse-document c-string size options)

Reads in a string and converts it to a cmark document object or cmark-node.

[procedure] (cmark-render-xml cmark-node-pointer options)

Renders a cmark document to an xml string.

[procedure] (cmark-render-html cmark-node-pointer options)

Renders a cmark document to an html string.

[procedure] (cmark-render-man cmark-node-pointer int-num options)

Renders a cmark document to a manpage string.

[procedure] (cmark-render-commonmark cmark-node-pointer int-num options)

Renders a cmark document to commonmark markdown string.

[procedure] (cmark-render-latex cmark-node-pointer int-num options)

Renders a cmark document to latex string.

[procedure] (cmark-markdown-to-html markdown content-length options)

Renders commonmark string to html string. commonmark->html abstracts over this function.

[procedure] (cmark-node-free cmark-node-pointer)
[procedure] (cmark-node-next cmark-node-pointer)
[procedure] (cmark-node-previous cmark-node-pointer)
[procedure] (cmark-node-parent cmark-node-pointer)
[procedure] (cmark-node-first-child cmark-node-pointer)
[procedure] (cmark-node-last-child cmark-node-pointer)
[procedure] (cmark-node-get-user-data cmark-node-pointer)
[procedure] (cmark-node-get-type cmark-node-pointer)
[procedure] (cmark-node-get-type-string cmark-node-pointer)
[procedure] (cmark-node-get-literal cmark-node-pointer)
[procedure] (cmark-node-set-literal cmark-node-pointer c-string)
[procedure] (cmark-node-get-heading-level cmark-node-pointer)
[procedure] (cmark-node-set-heading-level cmark-node-pointer int-num)
[procedure] (cmark-node-get-list-type cmark-node-pointer)
[procedure] (cmark-node-set-list-type cmark-node-pointer int-num)
[procedure] (cmark-node-get-list-delim cmark-node-pointer)
[procedure] (cmark-node-set-list-delim cmark-node-pointer int-num)
[procedure] (cmark-node-get-list-start cmark-node-pointer)
[procedure] (cmark-node-set-list-start cmark-node-pointer int-num)
[procedure] (cmark-node-get-list-tight cmark-node-pointer)
[procedure] (cmark-node-set-list-tight cmark-node-pointer int-num)
[procedure] (cmark-node-get-fence-info cmark-node-pointer)
[procedure] (cmark-node-set-fence-info cmark-node-pointer c-string)
[procedure] (cmark-node-get-url cmark-node-pointer)
[procedure] (cmark-node-set-url cmark-node-pointer c-string)
[procedure] (cmark-node-get-title cmark-node-pointer)
[procedure] (cmark-node-set-title cmark-node-pointer c-string)
[procedure] (cmark-node-get-on-enter cmark-node-pointer)
[procedure] (cmark-node-set-on-enter cmark-node-pointer c-string)
[procedure] (cmark-node-get-on-exit cmark-node-pointer)
[procedure] (cmark-node-set-on-exit cmark-node-pointer c-string)
[procedure] (cmark-node-get-start-line cmark-node-pointer)
[procedure] (cmark-node-get-start-column cmark-node-pointer)
[procedure] (cmark-node-end-line cmark-node-pointer)
[procedure] (cmark-node-end-column cmark-node-pointer)
[procedure] (cmark-node-unlink cmark-node-pointer)
[procedure] (cmark-node-insert-before cmark-node-pointer-a cmark-node-pointer-b)
[procedure] (cmark-node-insert-after cmark-node-pointer-a cmark-node-pointer-b)
[procedure] (cmark-node-replace cmark-node-pointer-a cmark-node-pointer-b)
[procedure] (cmark-node-prepend-child cmark-node-pointer-a cmark-node-pointer-b)
[procedure] (cmark-node-append-child cmark-node-pointer-a cmark-node-pointer-b)
[procedure] (cmark-consolidate-text-nodes cmark-node-pointer)
[procedure] (cmark-iter-new cmark-node-pointer)
[procedure] (cmark-iter-free cmark-node-iter-pointer)
[procedure] (cmark-iter-next cmark-node-iter-pointer)
[procedure] (cmark-iter-get-node cmark-node-iter-pointer)
[procedure] (cmark-iter-get-event-type cmark-node-iter-pointer)
[procedure] (cmark-iter-get-root cmark-node-iter-pointer)
[procedure] (cmark-iter-reset cmark-node-iter-pointer)
[procedure] (cmark-parser-new int-num)
[procedure] (cmark-parser-free cmark-parser-pointer)
[procedure] (cmark-parser-feed cmark-parser-pointer c-string size)
[procedure] (cmark-parser-finish cmark-parser-pointer)
[procedure] (cmark-parse-file file)
[procedure] (cmark-version)
[procedure] (cmark-version-string)

Constants

All commonmark constants are exported as well. They are mostly useful internally, but are necessary if writing a new cmark export format. The variables keep the C style formatting from the commonmark library.

[constant] CMARK_OPT_SAFE
[constant] CMARK_OPT_DEFAULT
[constant] CMARK_EVENT_NONE
[constant] CMARK_EVENT_DONE
[constant] CMARK_EVENT_ENTER
[constant] CMARK_EVENT_EXIT
[constant] CMARK_NODE_NONE
[constant] CMARK_NODE_DOCUMENT
[constant] CMARK_NODE_BLOCK_QUOTE
[constant] CMARK_NODE_LIST
[constant] CMARK_NODE_ITEM
[constant] CMARK_NODE_CODE_BLOCK
[constant] CMARK_NODE_HTML_BLOCK
[constant] CMARK_NODE_CUSTOM_BLOCK
[constant] CMARK_NODE_PARAGRAPH
[constant] CMARK_NODE_HEADING
[constant] CMARK_NODE_THEMATIC_BREAK
[constant] CMARK_NODE_FIRST_BLOCK
[constant] CMARK_NODE_LAST_BLOCK
[constant] CMARK_NODE_TEXT
[constant] CMARK_NODE_SOFTBREAK
[constant] CMARK_NODE_LINEBREAK
[constant] CMARK_NODE_CODE
[constant] CMARK_NODE_HTML_INLINE
[constant] CMARK_NODE_CUSTOM_INLINE
[constant] CMARK_NODE_EMPH
[constant] CMARK_NODE_STRONG
[constant] CMARK_NODE_LINK
[constant] CMARK_NODE_IMAGE
[constant] CMARK_NODE_FIRST_INLINE
[constant] CMARK_NODE_LAST_INLINE
[constant] CMARK_NO_LIST
[constant] CMARK_BULLET_LIST
[constant] CMARK_ORDERED_LIST
[constant] CMARK_NO_DELIM
[constant] CMARK_PERIOD_DELIM
[constant] CMARK_PAREN_DELIM

Source Code / Issues

https://git.sr.ht/~fancycade/chicken-cmark

License

MIT

Releases

0.1.0 Initial release for Chicken 5