- Commit
- 57a601a20071d854e2df19f2fc7ee05422a8e59a
- Parent
- 6c0da96b490f0889282d20ce5c30ec18e351f1c1
- Author
- John MacFarlane <jgm@berkeley.edu>
- Date
CommonMark writer: support title on link, image.
My personal build of CMark ✏️
CommonMark writer: support title on link, image.
1 file changed, 13 insertions, 2 deletions
Status | File Name | N° Changes | Insertions | Deletions |
Modified | src/commonmark.c | 15 | 13 | 2 |
diff --git a/src/commonmark.c b/src/commonmark.c @@ -162,6 +162,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, int list_number; bool entering = (ev_type == CMARK_EVENT_ENTER); const char *info; + const char *title; switch (node->type) { case CMARK_NODE_DOCUMENT: @@ -306,7 +307,12 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, } else { lit(state, "](", false); out(state, cmark_chunk_literal(cmark_node_get_url(node)), false, true); - // TODO title + title = cmark_node_get_title(node); + if (title && strlen(title) > 0) { + lit(state, " \"", true); + out(state, cmark_chunk_literal(title), false, true); + lit(state, "\"", false); + } lit(state, ")", false); } break; @@ -317,7 +323,12 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, } else { lit(state, "](", false); out(state, cmark_chunk_literal(cmark_node_get_url(node)), false, true); - // TODO title + title = cmark_node_get_title(node); + if (title && strlen(title) > 0) { + lit(state, " \"", true); + out(state, cmark_chunk_literal(title), false, true); + lit(state, "\"", false); + } lit(state, ")", false); } break;