diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-07-12 16:55:22 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-07-12 16:55:22 -0700 |
commit | 9e154368dd8cb9a1a00340c2210722f22160c402 (patch) | |
tree | 1ccad9f306f4df5d69df29e2d71bc13948245bcc | |
parent | 364c683fed6269c9b21ed870a8666e2de7121335 (diff) |
Added cmark_render_code_point.
-rw-r--r-- | src/man.c | 33 | ||||
-rw-r--r-- | src/render.c | 7 | ||||
-rw-r--r-- | src/render.h | 3 |
3 files changed, 24 insertions, 19 deletions
@@ -14,7 +14,6 @@ #define LIT(s) renderer->out(renderer, s, false, LITERAL) #define CR() renderer->cr(renderer) #define BLANKLINE() renderer->blankline(renderer) -#define ASCII(s) cmark_render_ascii(renderer, s) // Functions to convert cmark_nodes to groff man strings. static @@ -26,55 +25,51 @@ void S_outc(cmark_renderer *renderer, (void)(nextc); if (escape == LITERAL) { - utf8proc_encode_char(c, renderer->buffer); - renderer->column += 1; + cmark_render_code_point(renderer, c); return; } switch(c) { case 46: if (renderer->begin_line) { - ASCII("\\&."); + cmark_render_ascii(renderer, "\\&."); } else { - utf8proc_encode_char(c, renderer->buffer); - renderer->column += 1; + cmark_render_code_point(renderer, c); } break; case 39: if (renderer->begin_line) { - ASCII("\\&'"); + cmark_render_ascii(renderer, "\\&'"); } else { - utf8proc_encode_char(c, renderer->buffer); - renderer->column += 1; + cmark_render_code_point(renderer, c); } break; case 45: - ASCII("\\-"); + cmark_render_ascii(renderer, "\\-"); break; case 92: - ASCII("\\e"); + cmark_render_ascii(renderer, "\\e"); break; case 8216: // left single quote - ASCII("\\[oq]"); + cmark_render_ascii(renderer, "\\[oq]"); break; case 8217: // right single quote - ASCII("\\[cq]"); + cmark_render_ascii(renderer, "\\[cq]"); break; case 8220: // left double quote - ASCII("\\[lq]"); + cmark_render_ascii(renderer, "\\[lq]"); break; case 8221: // right double quote - ASCII("\\[rq]"); + cmark_render_ascii(renderer, "\\[rq]"); break; case 8212: // em dash - ASCII("\\[em]"); + cmark_render_ascii(renderer, "\\[em]"); break; case 8211: // en dash - ASCII("\\[en]"); + cmark_render_ascii(renderer, "\\[en]"); break; default: - utf8proc_encode_char(c, renderer->buffer); - renderer->column += 1; + cmark_render_code_point(renderer, c); } renderer->begin_line = (c == 10); } diff --git a/src/render.c b/src/render.c index e1545ea..7331a27 100644 --- a/src/render.c +++ b/src/render.c @@ -125,6 +125,13 @@ cmark_render_ascii(cmark_renderer* renderer, const char* s) renderer->column += renderer->buffer->size - origsize; } +void +cmark_render_code_point(cmark_renderer *renderer, uint8_t c) +{ + utf8proc_encode_char(c, renderer->buffer); + renderer->column += 1; +} + char* cmark_render(cmark_node *root, int options, diff --git a/src/render.h b/src/render.h index 17728b6..9409093 100644 --- a/src/render.h +++ b/src/render.h @@ -43,6 +43,9 @@ typedef struct cmark_renderer cmark_renderer; void cmark_render_ascii(cmark_renderer *renderer, const char* s); +void +cmark_render_code_point(cmark_renderer *renderer, uint8_t c); + char* cmark_render(cmark_node *root, int options, |