cmark
My personal build of CMark ✏️
- Commit
- 19a3a5ea4f73e8757b6d208f3be003bc2828e752
- Parent
- d19558961c1b579ddb2f5c62f1b6a65be3324333
- Author
- John MacFarlane <jgm@berkeley.edu>
- Date
Added end_column to cmark_node struct.
API exports cmark_node_get_column.
XML writer indicates start and end line and column for block-level
nodes.
Diffstat
6 files changed, 22 insertions, 2 deletions
diff --git a/src/blocks.c b/src/blocks.c
@@ -64,6 +64,7 @@ cmark_parser *cmark_parser_new()
parser->current = document;
parser->line_number = 0;
parser->curline = line;
+ parser->last_line_length = 0;
parser->linebuf = buf;
return parser;
@@ -198,6 +199,8 @@ finalize(cmark_parser *parser, cmark_node* b)
b->end_line = parser->line_number;
}
+ b->end_column = parser->last_line_length - 1; // -1 because of newline
+
switch (b->type) {
case NODE_PARAGRAPH:
while (cmark_strbuf_at(&b->string_content, 0) == '[' &&
@@ -853,6 +856,7 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
parser->current = container;
}
+ parser->last_line_length = parser->curline->size;
cmark_strbuf_clear(parser->curline);
}
diff --git a/src/xml.c b/src/xml.c
@@ -49,10 +49,11 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
cmark_node_get_type_string(node));
if (node->start_line != 0) {
- cmark_strbuf_printf(xml, " sourcepos=\"%d:%d-%d\"",
+ cmark_strbuf_printf(xml, " sourcepos=\"%d:%d-%d:%d\"",
node->start_line,
node->start_column,
- node->end_line);
+ node->end_line,
+ node->end_column);
}
literal = false;