mirror of
https://github.com/urbit/shrub.git
synced 2024-12-17 15:23:58 +03:00
276 lines
4.8 KiB
Groff
276 lines
4.8 KiB
Groff
.TH cmark 3 "December 05, 2014" "LOCAL" "Library Functions Manual"
|
|
.SH NAME
|
|
|
|
.B cmark
|
|
\- CommonMark parsing, manipulating, and rendering
|
|
|
|
.SH SIMPLE INTERFACE
|
|
|
|
.nf
|
|
\f[C]
|
|
.RS 0n
|
|
#define CMARK_VERSION "0.1"
|
|
.RE
|
|
\f[]
|
|
.fi
|
|
|
|
.PP
|
|
Current version of library.
|
|
|
|
\fIchar *\fR \fBcmark_markdown_to_html\fR(\fIconst char *text\fR, \fIint len\fR)
|
|
|
|
.PP
|
|
Convert \fItext\fR (assumed to be a UTF-8 encoded string with length
|
|
\fIlen\fR from CommonMark Markdown to HTML, returning a null-terminated,
|
|
UTF-8-encoded string.
|
|
|
|
.SH NODE STRUCTURE
|
|
|
|
.nf
|
|
\f[C]
|
|
.RS 0n
|
|
typedef enum {
|
|
/* Block */
|
|
CMARK_NODE_DOCUMENT,
|
|
CMARK_NODE_BLOCK_QUOTE,
|
|
CMARK_NODE_LIST,
|
|
CMARK_NODE_LIST_ITEM,
|
|
CMARK_NODE_CODE_BLOCK,
|
|
CMARK_NODE_HTML,
|
|
CMARK_NODE_PARAGRAPH,
|
|
CMARK_NODE_HEADER,
|
|
CMARK_NODE_HRULE,
|
|
CMARK_NODE_REFERENCE_DEF,
|
|
|
|
CMARK_NODE_FIRST_BLOCK = CMARK_NODE_DOCUMENT,
|
|
CMARK_NODE_LAST_BLOCK = CMARK_NODE_REFERENCE_DEF,
|
|
|
|
/* Inline */
|
|
CMARK_NODE_TEXT,
|
|
CMARK_NODE_SOFTBREAK,
|
|
CMARK_NODE_LINEBREAK,
|
|
CMARK_NODE_INLINE_CODE,
|
|
CMARK_NODE_INLINE_HTML,
|
|
CMARK_NODE_EMPH,
|
|
CMARK_NODE_STRONG,
|
|
CMARK_NODE_LINK,
|
|
CMARK_NODE_IMAGE,
|
|
|
|
CMARK_NODE_FIRST_INLINE = CMARK_NODE_TEXT,
|
|
CMARK_NODE_LAST_INLINE = CMARK_NODE_IMAGE,
|
|
} cmark_node_type;
|
|
.RE
|
|
\f[]
|
|
.fi
|
|
|
|
.PP
|
|
|
|
.nf
|
|
\f[C]
|
|
.RS 0n
|
|
typedef enum {
|
|
CMARK_NO_LIST,
|
|
CMARK_BULLET_LIST,
|
|
CMARK_ORDERED_LIST
|
|
} cmark_list_type;
|
|
.RE
|
|
\f[]
|
|
.fi
|
|
|
|
.PP
|
|
|
|
.nf
|
|
\f[C]
|
|
.RS 0n
|
|
typedef enum {
|
|
CMARK_PERIOD_DELIM,
|
|
CMARK_PAREN_DELIM
|
|
} cmark_delim_type;
|
|
.RE
|
|
\f[]
|
|
.fi
|
|
|
|
.PP
|
|
|
|
|
|
.SH CREATING AND DESTROYING NODES
|
|
|
|
\fIcmark_node*\fR \fBcmark_node_new\fR(\fIcmark_node_type type\fR)
|
|
|
|
.PP
|
|
|
|
\fIvoid\fR \fBcmark_node_free\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIcmark_node*\fR \fBcmark_node_next\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
.SH TREE TRAVERSAL
|
|
|
|
\fIcmark_node*\fR \fBcmark_node_previous\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIcmark_node*\fR \fBcmark_node_parent\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIcmark_node*\fR \fBcmark_node_first_child\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIcmark_node*\fR \fBcmark_node_last_child\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
|
|
.SH ACCESSORS
|
|
|
|
\fIcmark_node_type\fR \fBcmark_node_get_type\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIconst char*\fR \fBcmark_node_get_string_content\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_set_string_content\fR(\fIcmark_node *node\fR, \fIconst char *content\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_get_header_level\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_set_header_level\fR(\fIcmark_node *node\fR, \fIint level\fR)
|
|
|
|
.PP
|
|
|
|
\fIcmark_list_type\fR \fBcmark_node_get_list_type\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_set_list_type\fR(\fIcmark_node *node\fR, \fIcmark_list_type type\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_get_list_start\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_set_list_start\fR(\fIcmark_node *node\fR, \fIint start\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_get_list_tight\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_set_list_tight\fR(\fIcmark_node *node\fR, \fIint tight\fR)
|
|
|
|
.PP
|
|
|
|
\fIconst char*\fR \fBcmark_node_get_fence_info\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_set_fence_info\fR(\fIcmark_node *node\fR, \fIconst char *info\fR)
|
|
|
|
.PP
|
|
|
|
\fIconst char*\fR \fBcmark_node_get_url\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_set_url\fR(\fIcmark_node *node\fR, \fIconst char *url\fR)
|
|
|
|
.PP
|
|
|
|
\fIconst char*\fR \fBcmark_node_get_title\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_set_title\fR(\fIcmark_node *node\fR, \fIconst char *title\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_get_start_line\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_get_start_column\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_get_end_line\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
|
|
.SH TREE MANIPULATION
|
|
|
|
\fIvoid\fR \fBcmark_node_unlink\fR(\fIcmark_node *node\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_insert_before\fR(\fIcmark_node *node\fR, \fIcmark_node *sibling\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_insert_after\fR(\fIcmark_node *node\fR, \fIcmark_node *sibling\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_prepend_child\fR(\fIcmark_node *node\fR, \fIcmark_node *child\fR)
|
|
|
|
.PP
|
|
|
|
\fIint\fR \fBcmark_node_append_child\fR(\fIcmark_node *node\fR, \fIcmark_node *child\fR)
|
|
|
|
.PP
|
|
|
|
|
|
.SH PARSING
|
|
|
|
\fIcmark_parser *\fR \fBcmark_parser_new\fR(\fI\fR)
|
|
|
|
.PP
|
|
|
|
\fIvoid\fR \fBcmark_parser_free\fR(\fIcmark_parser *parser\fR)
|
|
|
|
.PP
|
|
|
|
\fIcmark_node *\fR \fBcmark_parser_finish\fR(\fIcmark_parser *parser\fR)
|
|
|
|
.PP
|
|
|
|
\fIvoid\fR \fBcmark_parser_feed\fR(\fIcmark_parser *parser\fR, \fIconst char *buffer\fR, \fIsize_t len\fR)
|
|
|
|
.PP
|
|
|
|
\fIcmark_node *\fR \fBcmark_parse_document\fR(\fIconst char *buffer\fR, \fIsize_t len\fR)
|
|
|
|
.PP
|
|
|
|
\fIcmark_node *\fR \fBcmark_parse_file\fR(\fIFILE *f\fR)
|
|
|
|
.PP
|
|
|
|
|
|
.SH RENDERING
|
|
|
|
\fIchar *\fR \fBcmark_render_ast\fR(\fIcmark_node *root\fR)
|
|
|
|
.PP
|
|
|
|
\fIchar *\fR \fBcmark_render_html\fR(\fIcmark_node *root\fR)
|
|
|
|
.PP
|
|
|
|
.SH AUTHORS
|
|
|
|
John MacFarlane, Vicent Marti, Kārlis Gaņģis, Nick Wellnhofer.
|
|
|