Skip to content

No type string for CMARK_NODE_FOOTNOTE_REFERENCE, CMARK_NODE_FOOTNOTE_DEFINITION #341

@matthewhughes934

Description

@matthewhughes934

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions