summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-03-21 20:46:05 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-03-21 20:46:05 -0700
commit57a601a20071d854e2df19f2fc7ee05422a8e59a (patch)
tree8781afd14572e2bf1586b23d3784647af929cbf8
parent6c0da96b490f0889282d20ce5c30ec18e351f1c1 (diff)
CommonMark writer: support title on link, image.
-rw-r--r--src/commonmark.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/commonmark.c b/src/commonmark.c
index c51be5c..bb24515 100644
--- 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;