diff --git a/DESCRIPTION b/DESCRIPTION index 618811c..78e886b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: commonmark Type: Package Title: High Performance CommonMark and Github Markdown Rendering in R -Version: 1.9.1 +Version: 1.9.2 Authors@R: c( person("Jeroen", "Ooms", ,"jeroen@berkeley.edu", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-4035-0289")), diff --git a/NEWS b/NEWS index 775c89a..6b9176b 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +1.9.2 + - Prevent single-tildes from being parsed as strikethrough (#25) + 1.9.1 - Update libcmark-gfm to 0.29.0.gfm.13 diff --git a/src/wrapper.c b/src/wrapper.c index f409f12..c2a4864 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -71,6 +71,10 @@ SEXP R_render_markdown(SEXP text, SEXP format, SEXP sourcepos, SEXP hardbreaks, /* Prevent filtering embedded resources: https://github.com/github/cmark-gfm#security */ options += CMARK_OPT_UNSAFE; + /* Only process double tildes as strikethrough, otherwise, leave them asis + * https://github.com/r-lib/commonmark/issues/25 + * */ + options += CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE; /* parse input */ SEXP input = STRING_ELT(text, 0); diff --git a/tests/testthat/test-extensions.R b/tests/testthat/test-extensions.R index fa922fe..410a32a 100644 --- a/tests/testthat/test-extensions.R +++ b/tests/testthat/test-extensions.R @@ -5,14 +5,14 @@ test_that("list extensions", { }) test_that("strikethrough", { - md <- "foo ~bar~ baz" - expect_equal(markdown_html(md, extensions = FALSE), "

foo ~bar~ baz

\n") + md <- "foo ~~bar~~ baz" + expect_equal(markdown_html(md, extensions = FALSE), "

foo ~~bar~~ baz

\n") expect_equal(markdown_html(md, extensions = TRUE), "

foo bar baz

\n") - expect_equal(markdown_latex(md, extensions = FALSE), "foo \\textasciitilde{}bar\\textasciitilde{} baz\n") + expect_equal(markdown_latex(md, extensions = FALSE), "foo \\textasciitilde{}\\textasciitilde{}bar\\textasciitilde{}\\textasciitilde{} baz\n") expect_equal(markdown_latex(md, extensions = TRUE), "foo \\sout{bar} baz\n") - expect_equal(markdown_man(md, extensions = FALSE), ".PP\nfoo ~bar~ baz\n") + expect_equal(markdown_man(md, extensions = FALSE), ".PP\nfoo ~~bar~~ baz\n") expect_equal(markdown_man(md, extensions = TRUE), ".PP\nfoo \n.ST \"bar\"\n baz\n") library(xml2)