diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-02-15 11:15:04 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-02-15 11:15:04 -0800 |
commit | 455a6a937df0e6eb4612c0f818a36e6a0629ee4b (patch) | |
tree | 9140ab4be5d76f2351a89156d7e2e3481004a89a | |
parent | b27dcba03a6907cfc71aa0af5bfe737793c542ca (diff) |
Implemented --smart for man output.
-rw-r--r-- | man/man1/cmark.1 | 4 | ||||
-rw-r--r-- | src/man.c | 15 |
2 files changed, 13 insertions, 6 deletions
diff --git a/man/man1/cmark.1 b/man/man1/cmark.1 index 305761f..c2a023a 100644 --- a/man/man1/cmark.1 +++ b/man/man1/cmark.1 @@ -36,8 +36,8 @@ Consolidate adjacent text nodes. Use smart punctuation. Straight double and single quotes will be rendered as curly quotes, depending on their position. `--` will be rendered as an en-dash. `---` will be rendered as -an em-dash. `...` will be rendered as ellipses. Currently -only supported for HTML output. +an em-dash. `...` will be rendered as ellipses. (This option +has no effect on XML output.) .TP 12n \-\-help Print usage information. @@ -7,6 +7,7 @@ #include "cmark.h" #include "node.h" #include "buffer.h" +#include "smart.h" // Functions to convert cmark_nodes to groff man strings. @@ -46,7 +47,7 @@ struct render_state { static int S_render_node(cmark_node *node, cmark_event_type ev_type, - struct render_state *state) + struct render_state *state, long options) { cmark_node *tmp; cmark_strbuf *man = state->man; @@ -165,8 +166,14 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, break; case CMARK_NODE_TEXT: - escape_man(man, node->as.literal.data, - node->as.literal.len); + if (options & CMARK_OPT_SMARTPUNCT) { + escape_with_smart(man, node, escape_man, + "\\[lq]", "\\[rq]", "\\[oq]", "\\[cq]", + "\\[em]", "\\[en]", "..."); + } else { + escape_man(man, node->as.literal.data, + node->as.literal.len); + } break; case CMARK_NODE_LINEBREAK: @@ -241,7 +248,7 @@ char *cmark_render_man(cmark_node *root, long options) while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) { cur = cmark_iter_get_node(iter); - S_render_node(cur, ev_type, &state); + S_render_node(cur, ev_type, &state, options); } result = (char *)cmark_strbuf_detach(&man); |