diff options
Diffstat (limited to 'man')
-rw-r--r-- | man/cmark.3.md | 190 | ||||
-rw-r--r-- | man/make_man_page.py | 15 | ||||
-rw-r--r-- | man/man3/cmark.3 | 194 |
3 files changed, 122 insertions, 277 deletions
diff --git a/man/cmark.3.md b/man/cmark.3.md deleted file mode 100644 index 558974d..0000000 --- a/man/cmark.3.md +++ /dev/null @@ -1,190 +0,0 @@ ---- -title: cmark -section: 3 -footer: libcmark manual -date: November 29, 2014 -... - -# NAME - -cmark - parse, manipulate, and render CommonMark formatted text - - #include <cmark.h> - -# SIMPLE INTERFACE - - char* - cmark_markdown_to_html(const char *text, int len); - -# PARSING - - void - cmark_parser_push(cmark_parser *parser, const char *buffer, size_t len); - - cmark_node* - cmark_parse_document(const char *buffer, size_t len); - - cmark_node* - cmark_parse_file(FILE *f); - -# RENDERING - - char* - cmark_render_ast(cmark_node *root); - - char* - cmark_render_html(cmark_node *root); - -# CREATING AND DESTROYING NODES - - cmark_node* - cmark_node_new(cmark_node_type type); - - void - cmark_node_free(cmark_node *node); - -# TREE TRAVERSAL - - cmark_node* - cmark_node_next(cmark_node *node); - - cmark_node* - cmark_node_previous(cmark_node *node); - - cmark_node* - cmark_node_parent(cmark_node *node); - - cmark_node* - cmark_node_first_child(cmark_node *node); - - cmark_node* - cmark_node_last_child(cmark_node *node); - -# TREE MANIPULATION - - void - cmark_node_unlink(cmark_node *node); - - int - cmark_node_insert_before(cmark_node *node, cmark_node *sibling); - - int - cmark_node_insert_after(cmark_node *node, cmark_node *sibling); - - int - cmark_node_prepend_child(cmark_node *node, cmark_node *child); - - int - cmark_node_append_child(cmark_node *node, cmark_node *child); - -# ACCESSORS - - cmark_node_type - cmark_node_get_type(cmark_node *node); - - const char* - cmark_node_get_string_content(cmark_node *node); - - int - cmark_node_set_string_content(cmark_node *node, const char *content); - - int - cmark_node_get_header_level(cmark_node *node); - - int - cmark_node_set_header_level(cmark_node *node, int level); - - cmark_list_type - cmark_node_get_list_type(cmark_node *node); - - int - cmark_node_set_list_type(cmark_node *node, cmark_list_type type); - - int - cmark_node_get_list_start(cmark_node *node); - - int - cmark_node_set_list_start(cmark_node *node, int start); - - int - cmark_node_get_list_tight(cmark_node *node); - - int - cmark_node_set_list_tight(cmark_node *node, int tight); - - const char* - cmark_node_get_fence_info(cmark_node *node); - - int - cmark_node_set_fence_info(cmark_node *node, const char *info); - - const char* - cmark_node_get_url(cmark_node *node); - - int - cmark_node_set_url(cmark_node *node, const char *url); - - const char* - cmark_node_get_title(cmark_node *node); - - int - cmark_node_set_title(cmark_node *node, const char *title); - - int - cmark_node_get_start_line(cmark_node *node); - - int - cmark_node_get_start_column(cmark_node *node); - - int - cmark_node_get_end_line(cmark_node *node); - -# DEFINITIONS - - CMARK_VERSION - - 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; - - typedef enum { - CMARK_NO_LIST, - CMARK_BULLET_LIST, - CMARK_ORDERED_LIST - } cmark_list_type; - - typedef enum { - CMARK_PERIOD_DELIM, - CMARK_PAREN_DELIM - } cmark_delim_type; - -# AUTHORS - -John MacFarlane diff --git a/man/make_man_page.py b/man/make_man_page.py index ed52381..19e1271 100644 --- a/man/make_man_page.py +++ b/man/make_man_page.py @@ -14,14 +14,21 @@ import sys import re -special_comment_re = re.compile('^\/\/\/ ?'); -blank_re = re.compile('^\s*$'); +if len(sys.argv) > 1: + sourcefile = sys.argv[1] +else: + print("Usage: make_man_page.py sourcefile") + exit(1) + +special_comment_re = re.compile('^\/\/\/ ?') +blank_re = re.compile('^\s*$') +macro_re = re.compile('CMARK_EXPORT *') mdlines = [] chunk = [] sig = [] -with open('../src/cmark.h', 'r') as cmarkh: +with open(sourcefile, 'r') as cmarkh: state = 'default' for line in cmarkh: # state transition @@ -39,7 +46,7 @@ with open('../src/cmark.h', 'r') as cmarkh: if state == 'markdown': chunk.append(re.sub(special_comment_re, '', line)) elif state == 'signature': - sig.append(' ' + line) + sig.append(' ' + re.sub(macro_re, '', line)) elif oldstate == 'signature' and state != 'signature': if len(mdlines) > 0 and mdlines[-1] != '\n': mdlines.append('\n') diff --git a/man/man3/cmark.3 b/man/man3/cmark.3 index 431e961..f611786 100644 --- a/man/man3/cmark.3 +++ b/man/man3/cmark.3 @@ -1,53 +1,65 @@ -.TH "cmark" "3" "November 29, 2014" "libcmark manual" "" +.TH "" "" "" "" "" .SH NAME .PP -cmark \- parse, manipulate, and render CommonMark formatted text +cmark \- CommonMark parsing, manipulating, and rendering +.SH SIMPLE INTERFACE .IP .nf \f[C] -#include\ <cmark.h> +#define\ CMARK_VERSION\ "0.1" \f[] .fi -.SH SIMPLE INTERFACE +.PP +Current version of library. .IP .nf \f[C] -char* -cmark_markdown_to_html(const\ char\ *text,\ int\ len); +char\ *cmark_markdown_to_html(const\ char\ *text,\ int\ len); \f[] .fi -.SH PARSING +.PP +Convert \f[C]text\f[] (assumed to be a UTF\-8 encoded string with length +\f[C]len\f[]) from CommonMark Markdown to HTML, returning a +null\-terminated, UTF\-8\-encoded string. +.SH NODE STRUCTURE .IP .nf \f[C] -void -cmark_parser_push(cmark_parser\ *parser,\ const\ char\ *buffer,\ size_t\ len); +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* -cmark_parse_document(const\ char\ *buffer,\ size_t\ len); -cmark_node* -cmark_parse_file(FILE\ *f); -\f[] -.fi -.SH RENDERING -.IP -.nf -\f[C] -char* -cmark_render_ast(cmark_node\ *root); +typedef\ enum\ { +\ \ \ \ CMARK_NO_LIST, +\ \ \ \ CMARK_BULLET_LIST, +\ \ \ \ CMARK_ORDERED_LIST +}\ \ cmark_list_type; + -char* -cmark_render_html(cmark_node\ *root); +typedef\ enum\ { +\ \ \ \ CMARK_PERIOD_DELIM, +\ \ \ \ CMARK_PAREN_DELIM +}\ cmark_delim_type; \f[] .fi -.SH CREATING AND DESTROYING NODES +.SH CREATING AND DESTORYING NODES .IP .nf \f[C] cmark_node* cmark_node_new(cmark_node_type\ type); + void cmark_node_free(cmark_node\ *node); \f[] @@ -59,39 +71,23 @@ cmark_node_free(cmark_node\ *node); cmark_node* cmark_node_next(cmark_node\ *node); + cmark_node* cmark_node_previous(cmark_node\ *node); + cmark_node* cmark_node_parent(cmark_node\ *node); + cmark_node* cmark_node_first_child(cmark_node\ *node); + cmark_node* cmark_node_last_child(cmark_node\ *node); \f[] .fi -.SH TREE MANIPULATION -.IP -.nf -\f[C] -void -cmark_node_unlink(cmark_node\ *node); - -int -cmark_node_insert_before(cmark_node\ *node,\ cmark_node\ *sibling); - -int -cmark_node_insert_after(cmark_node\ *node,\ cmark_node\ *sibling); - -int -cmark_node_prepend_child(cmark_node\ *node,\ cmark_node\ *child); - -int -cmark_node_append_child(cmark_node\ *node,\ cmark_node\ *child); -\f[] -.fi .SH ACCESSORS .IP .nf @@ -99,113 +95,145 @@ cmark_node_append_child(cmark_node\ *node,\ cmark_node\ *child); cmark_node_type cmark_node_get_type(cmark_node\ *node); + const\ char* cmark_node_get_string_content(cmark_node\ *node); + int cmark_node_set_string_content(cmark_node\ *node,\ const\ char\ *content); + int cmark_node_get_header_level(cmark_node\ *node); + int cmark_node_set_header_level(cmark_node\ *node,\ int\ level); + cmark_list_type cmark_node_get_list_type(cmark_node\ *node); + int cmark_node_set_list_type(cmark_node\ *node,\ cmark_list_type\ type); + int cmark_node_get_list_start(cmark_node\ *node); + int cmark_node_set_list_start(cmark_node\ *node,\ int\ start); + int cmark_node_get_list_tight(cmark_node\ *node); + int cmark_node_set_list_tight(cmark_node\ *node,\ int\ tight); + const\ char* cmark_node_get_fence_info(cmark_node\ *node); + int cmark_node_set_fence_info(cmark_node\ *node,\ const\ char\ *info); + const\ char* cmark_node_get_url(cmark_node\ *node); + int cmark_node_set_url(cmark_node\ *node,\ const\ char\ *url); + const\ char* cmark_node_get_title(cmark_node\ *node); + int cmark_node_set_title(cmark_node\ *node,\ const\ char\ *title); + int cmark_node_get_start_line(cmark_node\ *node); + int cmark_node_get_start_column(cmark_node\ *node); + int cmark_node_get_end_line(cmark_node\ *node); \f[] .fi -.SH DEFINITIONS +.SH TREE MANIPULATION .IP .nf \f[C] -CMARK_VERSION +void +cmark_node_unlink(cmark_node\ *node); -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, +int +cmark_node_insert_before(cmark_node\ *node,\ cmark_node\ *sibling); -\ \ \ \ //\ 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; +int +cmark_node_insert_after(cmark_node\ *node,\ cmark_node\ *sibling); -typedef\ enum\ { -\ \ \ \ CMARK_NO_LIST, -\ \ \ \ CMARK_BULLET_LIST, -\ \ \ \ CMARK_ORDERED_LIST -}\ \ cmark_list_type; -typedef\ enum\ { -\ \ \ \ CMARK_PERIOD_DELIM, -\ \ \ \ CMARK_PAREN_DELIM -}\ cmark_delim_type; +int +cmark_node_prepend_child(cmark_node\ *node,\ cmark_node\ *child); + + +int +cmark_node_append_child(cmark_node\ *node,\ cmark_node\ *child); +\f[] +.fi +.SH PARSING +.IP +.nf +\f[C] +cmark_parser\ *cmark_parser_new(); + + + +void\ cmark_parser_free(cmark_parser\ *parser); + + + +cmark_node\ *cmark_parser_finish(cmark_parser\ *parser); + + + +void\ cmark_parser_push(cmark_parser\ *parser,\ const\ char\ *buffer,\ size_t\ len); + + + +cmark_node\ *cmark_parse_document(const\ char\ *buffer,\ size_t\ len); + + + +cmark_node\ *cmark_parse_file(FILE\ *f); +\f[] +.fi +.SH RENDERING +.IP +.nf +\f[C] +char\ *cmark_render_ast(cmark_node\ *root); + + + +char\ *cmark_render_html(cmark_node\ *root); \f[] .fi .SH AUTHORS .PP -John MacFarlane +John MacFarlane, Vicent Marti, Kārlis Gaņģis, Nick Wellnhofer. |