diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-12-16 12:01:19 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-12-16 12:01:19 -0800 |
commit | 6e25c889cf33a6217a9b4cf37ea1a6361883901b (patch) | |
tree | 949a5482cf2df495107edf03d822fc5a05e1ae31 /src | |
parent | 06fcdb7592a6106daa52dfe4830373ed735e4053 (diff) |
Added 'literal' field to 'code' struct.
In the last few commits we were using as.code.fenced and as.literal at
the same time for NODE_CODE_BLOCK, which obviously led to problems.
Diffstat (limited to 'src')
-rw-r--r-- | src/blocks.c | 2 | ||||
-rw-r--r-- | src/html.c | 3 | ||||
-rw-r--r-- | src/man.c | 4 | ||||
-rw-r--r-- | src/node.c | 11 | ||||
-rw-r--r-- | src/node.h | 1 | ||||
-rw-r--r-- | src/print.c | 4 |
6 files changed, 16 insertions, 9 deletions
diff --git a/src/blocks.c b/src/blocks.c index fe43055..4dcd3f4 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -232,7 +232,7 @@ finalize(cmark_parser *parser, cmark_node* b, int line_number) cmark_strbuf_drop(&b->string_content, firstlinelen + 1); } - b->as.literal = cmark_chunk_buf_detach(&b->string_content); + b->as.code.literal = cmark_chunk_buf_detach(&b->string_content); break; case NODE_HTML: @@ -152,7 +152,8 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate) cmark_strbuf_puts(html, "\">"); } - escape_html(html, node->as.literal.data, node->as.literal.len); + escape_html(html, node->as.code.literal.data, + node->as.code.literal.len); cmark_strbuf_puts(html, "</code></pre>\n"); break; @@ -130,8 +130,8 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate) case CMARK_NODE_CODE_BLOCK: cr(man); cmark_strbuf_puts(man, ".IP\n.nf\n\\f[C]\n"); - escape_man(man, node->as.literal.data, - node->as.literal.len); + escape_man(man, node->as.code.literal.data, + node->as.code.literal.len); cr(man); cmark_strbuf_puts(man, "\\f[]\n.fi"); cr(man); @@ -42,7 +42,7 @@ void S_free_nodes(cmark_node *e) switch (e->type){ case NODE_CODE_BLOCK: cmark_chunk_free(&e->as.code.info); - cmark_chunk_free(&e->as.literal); + cmark_chunk_free(&e->as.code.literal); break; case NODE_TEXT: case NODE_INLINE_HTML: @@ -183,13 +183,15 @@ cmark_node_get_literal(cmark_node *node) { } switch (node->type) { - case NODE_CODE_BLOCK: case NODE_HTML: case NODE_TEXT: case NODE_INLINE_HTML: case NODE_CODE: return cmark_chunk_to_cstr(&node->as.literal); + case NODE_CODE_BLOCK: + return cmark_chunk_to_cstr(&node->as.code.literal); + default: break; } @@ -204,7 +206,6 @@ cmark_node_set_literal(cmark_node *node, const char *content) { } switch (node->type) { - case NODE_CODE_BLOCK: case NODE_HTML: case NODE_TEXT: case NODE_INLINE_HTML: @@ -212,6 +213,10 @@ cmark_node_set_literal(cmark_node *node, const char *content) { cmark_chunk_set_cstr(&node->as.literal, content); return 1; + case NODE_CODE_BLOCK: + cmark_chunk_set_cstr(&node->as.code.literal, content); + return 1; + default: break; } @@ -27,6 +27,7 @@ typedef struct { int fence_offset; unsigned char fence_char; cmark_chunk info; + cmark_chunk literal; } cmark_code; typedef struct { diff --git a/src/print.c b/src/print.c index a4654f2..c38271f 100644 --- a/src/print.c +++ b/src/print.c @@ -81,8 +81,8 @@ static void render_nodes(cmark_strbuf* buffer, cmark_node* node, int indent) print_str(buffer, node->as.code.info.data, node->as.code.info.len); cmark_strbuf_putc(buffer, ' '); - print_str(buffer, node->as.literal.data, - node->as.literal.len); + print_str(buffer, node->as.code.literal.data, + node->as.code.literal.len); cmark_strbuf_putc(buffer, '\n'); break; case NODE_HTML: |