Skip to content

Instantly share code, notes, and snippets.

@andremedeiros
Created February 18, 2019 05:35
Show Gist options
  • Save andremedeiros/77ccbd81c536811b52b42ac4647f3356 to your computer and use it in GitHub Desktop.
Save andremedeiros/77ccbd81c536811b52b42ac4647f3356 to your computer and use it in GitHub Desktop.
// gcc -lcmark -o test test.c
#include <cmark.h>
int main(int argc, char *argv[]) {
int options = CMARK_OPT_DEFAULT;
cmark_parser *parser = cmark_parser_new(options);
cmark_parser_feed(parser, "Hello **world**.\n", 17);
cmark_node *document = cmark_parser_finish(parser);
cmark_node *paragraph = cmark_node_first_child(document);
cmark_node *text = cmark_node_first_child(paragraph);
cmark_node *strong = cmark_node_next(text);
int offset = cmark_node_get_start_column(strong);
int length = cmark_node_get_end_column(strong) - offset;
printf("%d - %d\n", offset, length);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment