github/cmark-gfm

No type string for `CMARK_NODE_FOOTNOTE_REFERENCE`, `CMARK_NODE_FOOTNOTE_DEFINITION`

matthewhughes934 opened this issue · 2 comments

Nodes of this type return "<unknown>" when passed to cmark_node_get_type_string is it intentional that there's no entry for these types in that function?

Basic program to show the "<unknown>"s:

#include <stdio.h>
#include <string.h>
#include "cmark-gfm.h"

int main(void)
{
  const char *document = "Here's a footnote[^1]\n\n[^1]: a reference\n";
  cmark_node *root = cmark_parse_document(document, strlen(document), CMARK_OPT_DEFAULT | CMARK_OPT_FOOTNOTES);
  cmark_iter *iter = cmark_iter_new(root);

  for (cmark_event_type ev_type = cmark_iter_next(iter); ev_type != CMARK_EVENT_DONE; ev_type = cmark_iter_next(iter)) {
    if (ev_type == CMARK_EVENT_ENTER) {
      cmark_node *cur = cmark_iter_get_node(iter);
      printf("%s\n", cmark_node_get_type_string(cur));
    }
  }

  cmark_iter_free(iter);
  cmark_node_free(root);

  return 0;
}

Output:

document
paragraph
text
<unknown>
<unknown>
paragraph
text

I think this is also related to #316 since for a footnote the XML tag is just generated via cmark_node_get_type_for_string

cmark_strbuf_puts(xml, cmark_node_get_type_string(node));

I've attempted to address this in #362, but I'm still waiting on response from the GitHub maintainers.