- Commit
- 1fad45bf96b3daf2fcba747d44caa4556c68917a
- Parent
- df29746dabf154ce09f3bfbdeeafb62bff72366a
- Author
- John MacFarlane <jgm@berkeley.edu>
- Date
commonmark - don't use indented code if first thing in list item.
My personal build of CMark ✏️
commonmark - don't use indented code if first thing in list item.
1 file changed, 6 insertions, 3 deletions
Status | File Name | N° Changes | Insertions | Deletions |
Modified | src/commonmark.c | 9 | 6 | 3 |
diff --git a/src/commonmark.c b/src/commonmark.c @@ -342,13 +342,16 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, blankline(state); info = cmark_node_get_fence_info(node); code = &node->as.code.literal; + // use indented form if no info, and code doesn't + // begin or end with a blank line, and code isn't + // first thing in a list item if ((info == NULL || strlen(info) == 0) && (code->len > 2 && !isspace(code->data[0]) && !(isspace(code->data[code->len - 1]) && - isspace(code->data[code->len - 2])))) { - // use indented form if no info and code doesn't - // begin or end with a blank line + isspace(code->data[code->len - 2]))) && + !(node->prev == NULL && node->parent && + node->parent->type == CMARK_NODE_ITEM)) { lit(state, " ", false); cmark_strbuf_puts(state->prefix, " "); out(state, node->as.code.literal, false, LITERAL);