diff options
-rw-r--r-- | man/make_man_page.py | 15 | ||||
-rw-r--r-- | man/man3/cmark.3 | 60 | ||||
-rw-r--r-- | src/cmark.h | 7 |
3 files changed, 68 insertions, 14 deletions
diff --git a/man/make_man_page.py b/man/make_man_page.py index 4516891..01a1c6f 100644 --- a/man/make_man_page.py +++ b/man/make_man_page.py @@ -2,7 +2,8 @@ # Creates a man page from a C file. -# Comments beginning with `/**` are treated as Groff man. +# Comments beginning with `/**` are treated as Groff man, except that +# 'this' is converted to \fIthis\fR, and ''this'' to \fBthis\fR. # Non-blank lines immediately following a man page comment are treated # as function signatures or examples and parsed into .Ft, .Fo, .Fa, .Fc. The @@ -22,6 +23,11 @@ blank_re = re.compile('^\s*$') macro_re = re.compile('CMARK_EXPORT *') typedef_start_re = re.compile('typedef.*{$') typedef_end_re = re.compile('}') +single_quote_re = re.compile("(?<!\w)'([^']+)'(?!\w)") +double_quote_re = re.compile("(?<!\w)''([^']+)''(?!\w)") + +def handle_quotes(s): + return re.sub(double_quote_re, '\\\\fB\g<1>\\\\fR', re.sub(single_quote_re, '\\\\fI\g<1>\\\\fR', s)) typedef = False mdlines = [] @@ -55,7 +61,7 @@ with open(sourcefile, 'r') as cmarkh: # handle line if state == 'man': - chunk.append(re.sub(comment_delim_re, '', line)) + chunk.append(handle_quotes(re.sub(comment_delim_re, '', line))) elif state == 'signature': ln = re.sub(macro_re, '', line) if typedef or not re.match(blank_re, ln): @@ -76,11 +82,12 @@ with open(sourcefile, 'r') as cmarkh: mdlines.append('\\fI' + argument.strip() + '\\fR') mdlines.append(')\n') else: - mdlines.append('.nf\n.RS 0n\n') + mdlines.append('.nf\n\\f[C]\n.RS 0n\n') mdlines += sig - mdlines.append('.RE\n.fi\n') + mdlines.append('.RE\n\\f[]\n.fi\n') if len(mdlines) > 0 and mdlines[-1] != '\n': mdlines.append('\n') + mdlines.append('.PP\n') mdlines += chunk chunk = [] sig = [] diff --git a/man/man3/cmark.3 b/man/man3/cmark.3 index fcd1c28..4c0581f 100644 --- a/man/man3/cmark.3 +++ b/man/man3/cmark.3 @@ -7,25 +7,27 @@ .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) -Convert -.Fa text -(assumed to be a UTF-8 encoded string with length -.Fa len ) -from CommonMark Markdown to HTML, returning a null-terminated, +.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 */ @@ -58,10 +60,13 @@ typedef enum { CMARK_NODE_LAST_INLINE = CMARK_NODE_IMAGE, } cmark_node_type; .RE +\f[] .fi +.PP .nf +\f[C] .RS 0n typedef enum { CMARK_NO_LIST, @@ -69,155 +74,200 @@ typedef enum { 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 diff --git a/src/cmark.h b/src/cmark.h index 89d6f16..cae4426 100644 --- a/src/cmark.h +++ b/src/cmark.h @@ -21,11 +21,8 @@ extern "C" { */ #define CMARK_VERSION "0.1" -/** Convert - * .Fa text - * (assumed to be a UTF-8 encoded string with length - * .Fa len ) - * from CommonMark Markdown to HTML, returning a null-terminated, +/** Convert 'text' (assumed to be a UTF-8 encoded string with length + * 'len' from CommonMark Markdown to HTML, returning a null-terminated, * UTF-8-encoded string. */ CMARK_EXPORT |