cmark

Unnamed repository; edit this file 'description' to name the repository.

commit 57a601a20071d854e2df19f2fc7ee05422a8e59a
parent 6c0da96b490f0889282d20ce5c30ec18e351f1c1
Author: John MacFarlane <jgm@berkeley.edu>
Date:   Sat, 21 Mar 2015 20:46:05 -0700

CommonMark writer: support title on link, image.

Diffstat:
Msrc/commonmark.c | 15+++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
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;