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

commonmark::markdown_text(footnotes = TRUE) does not strip footnotes #24

Open
salim-b opened this issue Mar 29, 2023 · 1 comment
Open

Comments

@salim-b
Copy link

salim-b commented Mar 29, 2023

The recently introduced footnote support via param footnotes does not work as one would expect for commonmark::markdown_text(). For all other Markdown features (like emphasizing, links etc.), they are stripped by commonmark::markdown_text() since regular text has no notion of markup.

But the footnotes remain:

md <- "Text *emphasized* and **bold**, with [inline link](https://to.some.where/), [reference link][ref] and footnote[^fn].\n\n[ref]: https://fsf.org\n\n[^fn]: A note.\n"
cat(md)
#> Text *emphasized* and **bold**, with [inline link](https://to.some.where/), [reference link][ref] and footnote[^fn].
#> 
#> [ref]: https://fsf.org
#> 
#> [^fn]: A note.

# without footnote parsing
md |> commonmark::markdown_text(footnotes = F) |> cat()
#> Text emphasized and bold, with inline link, reference link and footnote[^fn].
#> 
#> [^fn]: A note.

# with footnote parsing
md |> commonmark::markdown_text(footnotes = T) |> cat()
#> Text emphasized and bold, with inline link, reference link and footnote[^1].
#> 
#> [^1]: A note.

Created on 2023-03-29 with reprex v2.0.2

Is this really the intended behaviour?

@jeroen
Copy link
Member

jeroen commented Mar 29, 2023

I am not sure actually. Footnotes are not described in the gfm spec. I can imagine they are considered content, not markup, and hence get retained in plain text.

Either way, you have to ask this upstream in https://github.com/github/cmark-gfm . We don't control this form the R bindings.

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