Open apps4everyone opened 2 years ago
@johnxnguyen we've run into a bug which is present on 0.29, but not present on 0.30:
If you try to render a single tick (`) on 0.30.2 with the following C code:
char *content = "`";
int opts = 0;
cmark_node *doc = cmark_parse_document(content, strlen(content), opts);
printf("%d, %d\n", doc->start_column, doc->end_column);
printf("%d, %d\n", doc->first_child->start_column, doc->first_child->end_column);
printf("%d, %d\n", doc->first_child->first_child->start_column, doc->first_child->first_child->end_column);
you get:
1, 1
1, 1
1, 1
as expected, but if you do so with 0.29 (Down's current version which is 3 years old) you get:
1, 1
1, 1
2, 2
which exceeds the document bounds and depending on what you're doing with the AST you'll experience crashes
here is the tree visualized in the xcode debugger:
if you need it here is what the debug visitor sees:
Document
↳ Paragraph
↳ Text - `
(which is fine)
Here is a small C program you can use for testing:
if you go into the cmark folder and checkout the most recent commit and regen the libs you'll find that the problem goes away and we're returned valid ranges.
Thanks for lending a hand with the C code @steverusso
I updated on my fork, and everything seems to be working fine, will report back as I explore more: https://github.com/Parth/Down
Update to cmark 0.30.2