Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No type string for CMARK_NODE_FOOTNOTE_REFERENCE, CMARK_NODE_FOOTNOTE_DEFINITION #341

Open
matthewhughes934 opened this issue Jul 15, 2023 · 2 comments

Comments

@matthewhughes934
Copy link

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
@matthewhughes934
Copy link
Author

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));

@zkamvar
Copy link

zkamvar commented Apr 22, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants