knitr icon indicating copy to clipboard operation
knitr copied to clipboard

Switch to commonmark markdown

Open jeroen opened this issue 8 years ago • 13 comments

The new version of commonmark uses the Github fork of the libcmark library, providing fast and standardized markdown rendering, including support for Github Flavored Markdown extensions (tables, autolinks, strikethough).

commonmark::markdown_html(md_text, extensions = c("table", "autolink"))
commonmark::markdown_latex(md_text, extensions = c("table", "autolink"))

Maybe it could be a better alternative to markdown::markdownToHTML.

jeroen avatar Dec 02 '16 18:12 jeroen

Thanks for the suggestion! I'll take a look. I think the markdown package will be retired eventually.

yihui avatar Dec 02 '16 18:12 yihui

Hi Yihui!

Could you please revisit this?

The markdown package relies on a version of sundown that is very old and no longer maintained. At Google, we're treating this as a security issue.

We're in a bit of a tough spot:

  • sundown itself can be replaced by the currently-maintained hoedown, but it is a pretty big rewrite if we're going to do that: https://github.com/hoedown/hoedown
  • Or we need to figure out how to remove the markdown package itself from knitr to use commonmark

Since both involve non-trivial amounts of work, it would be nice to know what approach you would prefer.

Best wishes, Michael

michaelquinn32 avatar May 12 '20 01:05 michaelquinn32

@michaelquinn32 Yes, I'll remove the dependency on markdown. It may take at least a couple of weeks. The trickiest thing will be package vignettes on CRAN. Due to the huge number of reverse dependencies of knitr, I'll have to be extremely cautious to make this transition. Thanks!

yihui avatar May 12 '20 21:05 yihui

That's amazing to hear! Thank you.

Let me know if there's anything I can do to help you out.

michaelquinn32 avatar May 13 '20 03:05 michaelquinn32

Hi @michaelquinn32, I heard that you were planning to work on this issue by yourself, and I just want to let you know that we also plan to work on it on our end. I don't have an ETA yet, but my estimate is that it should be done in about two months. If this issue is urgent to you, please feel to let me know and we can certainly prioritize it. Thanks!

yihui avatar Sep 14 '20 13:09 yihui

Thanks for the update!

There's no need to adjust your prioritization. I'll let you know how things go on my end, and I'm really looking forward to seeing this fixed!

michaelquinn32 avatar Sep 14 '20 18:09 michaelquinn32

Following. I'm very interested in this change as markdown is GPL-2.

rickyars avatar Sep 21 '20 17:09 rickyars

@rickyars Do you mean that you can't use packages licensed under GPL-2? I'm not entirely sure if I'll be able to change the license of the markdown package.

yihui avatar Sep 21 '20 19:09 yihui

Yes. We can't mix code that uses GPL-2 and GPL-3 if we plan to redistribute our work open source. Right now I have some Shiny apps that use knitr and the one piece I can't get around is its dependence on markdown. If you are removing markdown then the issue goes away. Maybe I misunderstood what was you meant when you said "I'll remove the dependency on markdown." Alternatively, have you considered switching to the rmarkdown package?

rickyars avatar Sep 21 '20 19:09 rickyars

What I meant are:

  1. markdown won't be a hard dependency of knitr in the future (will only be in Suggests instead of Depends).

  2. markdown won't use the sundown C library.

It sounds like 1 will solve your problem?

yihui avatar Sep 21 '20 19:09 yihui

Yes, thank you!

rickyars avatar Sep 21 '20 20:09 rickyars

Just for reference regarding ☝️

markdown won't be a hard dependency of knitr in the future (will only be in Suggests instead of Depends).

This is followed in https://github.com/yihui/knitr/issues/1864

cderv avatar Mar 22 '21 14:03 cderv

Cool. The commonmark package is now part of the r-lib organization: https://github.com/r-lib/commonmark

jeroen avatar Mar 22 '21 15:03 jeroen

Although this is no longer tightly relevant to knitr, I've retired the C library sundown in markdown, and switched to commonmark as suggested. Thanks!

yihui avatar Oct 27 '22 19:10 yihui

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

github-actions[bot] avatar Apr 26 '23 05:04 github-actions[bot]