Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
# Conflicts:
#	NEWS
  • Loading branch information
yihui committed Oct 13, 2024
2 parents d6ac5b0 + 91237d4 commit d8b4c03
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Suggests:
curl,
testthat,
xml2
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
Language: en-US
Encoding: UTF-8
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
1.9.4
- Apply upstream PR https://github.com/github/cmark-gfm/pull/362
- Require double-tilde `~~` for the strikethrough extension, for consistency with Pandoc's Markdown
- Implement LaTeX footnotes (#32)

1.9.1
Expand Down
2 changes: 1 addition & 1 deletion R/extensions.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' Currently the following extensions are supported:
#'
#' - **table** support rendering of tables: [gfm-spec section 4.10](https://github.github.com/gfm/#tables-extension-)
#' - **strikethrough** via `~sometext~` syntax: [gfm-spec section 6.5](https://github.github.com/gfm/#strikethrough-extension-)
#' - **strikethrough** via `~~sometext~~` syntax: [gfm-spec section 6.5](https://github.github.com/gfm/#strikethrough-extension-)
#' - **autolink** automatically turn URLs into hyperlinks: [gfm-spec section 6.9](https://github.github.com/gfm/#autolinks-extension-)
#' - **tagfilter** blacklist html tags: `title` `textarea` `style` `xmp` `iframe`
#' `noembed` `noframes` `script` `plaintext`: [gfm-spec section 6.11](https://github.github.com/gfm/#disallowed-raw-html-extension-)
Expand Down
2 changes: 1 addition & 1 deletion man/extensions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ SEXP R_render_markdown(SEXP text, SEXP format, SEXP sourcepos, SEXP hardbreaks,

/* combine options */
int options = CMARK_OPT_DEFAULT;
options += CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE;
options += Rf_asLogical(sourcepos) * CMARK_OPT_SOURCEPOS;
options += Rf_asLogical(hardbreaks) * CMARK_OPT_HARDBREAKS;
options += Rf_asLogical(smart) * CMARK_OPT_SMART;
Expand Down
18 changes: 9 additions & 9 deletions tests/testthat/test-extensions.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ test_that("list extensions", {
})

test_that("strikethrough", {
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")
md <- "~Hello~ ~~world~~!"
expect_equal(markdown_html(md), "<p>~Hello~ ~~world~~!</p>\n")
expect_equal(markdown_html(md, extensions = "strikethrough"), "<p>~Hello~ <del>world</del>!</p>\n")

expect_equal(markdown_latex(md, extensions = FALSE), "foo \\textasciitilde{}bar\\textasciitilde{} baz\n")
expect_equal(markdown_latex(md, extensions = TRUE), "foo \\sout{bar} baz\n")
expect_equal(markdown_latex(md), "\\textasciitilde{}Hello\\textasciitilde{} \\textasciitilde{}\\textasciitilde{}world\\textasciitilde{}\\textasciitilde{}!\n")
expect_equal(markdown_latex(md, extensions = "strikethrough"), "\\textasciitilde{}Hello\\textasciitilde{} \\sout{world}!\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")
expect_equal(markdown_man(md), ".PP\n~Hello~ ~~world~~!\n")
expect_equal(markdown_man(md, extensions = "strikethrough"), ".PP\n~Hello~ \n.ST \"world\"\n!\n")

library(xml2)
doc1 <- xml_ns_strip(read_xml(markdown_xml(md, extensions = FALSE)))
doc2 <- xml_ns_strip(read_xml(markdown_xml(md, extensions = TRUE)))
doc1 <- xml_ns_strip(read_xml(markdown_xml(md)))
doc2 <- xml_ns_strip(read_xml(markdown_xml(md, extensions = "strikethrough")))
expect_length(xml_find_all(doc1, "//strikethrough"), 0)
expect_length(xml_find_all(doc2, "//strikethrough"), 1)

Expand Down

0 comments on commit d8b4c03

Please sign in to comment.