From 5f88071c82769d557062ea574a42eab700a28c4b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 29 Dec 2014 12:54:27 -0800 Subject: Make `--sourcepos` affect xml writer too. --- src/xml.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/xml.c b/src/xml.c index 8f48a12..c0f9d4e 100644 --- a/src/xml.c +++ b/src/xml.c @@ -35,7 +35,8 @@ static inline void indent(struct render_state *state) } static int -S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate) +S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate, + long options) { struct render_state *state = vstate; cmark_strbuf *xml = state->xml; @@ -48,7 +49,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate) cmark_strbuf_printf(xml, "<%s", cmark_node_get_type_string(node)); - if (node->start_line != 0) { + if (options & CMARK_OPT_SOURCEPOS && node->start_line != 0) { cmark_strbuf_printf(xml, " sourcepos=\"%d:%d-%d:%d\"", node->start_line, node->start_column, @@ -135,7 +136,7 @@ char *cmark_render_xml(cmark_node *root, long options) "\n"); while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) { cur = cmark_iter_get_node(iter); - S_render_node(cur, ev_type, &state); + S_render_node(cur, ev_type, &state, options); } result = (char *)cmark_strbuf_detach(&xml); -- cgit v1.2.3