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

prevent single tildes from becoming strikethrough #31

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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")),
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 4 additions & 0 deletions src/wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-extensions.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ test_that("list extensions", {
})

test_that("strikethrough", {
md <- "foo ~bar~ baz"
expect_equal(markdown_html(md, extensions = FALSE), "<p>foo ~bar~ baz</p>\n")
md <- "foo ~~bar~~ baz"
expect_equal(markdown_html(md, extensions = FALSE), "<p>foo ~~bar~~ baz</p>\n")
expect_equal(markdown_html(md, extensions = TRUE), "<p>foo <del>bar</del> baz</p>\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)
Expand Down
Loading