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

protect math protection #62

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Package: tinkr
Title: Casts (R)Markdown Files to XML and Back Again
Version: 0.0.0.9000
Title: Cast (R)Markdown Files to XML and Back Again
Version: 0.0.0.9001
Authors@R:
c(person(given = "Maëlle",
family = "Salmon",
role = c("aut", "cre"),
role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-2815-0399")),
person(given = "Zhian N.",
family = "Kamvar",
role = "aut",
role = c("aut", "cre"),
email = "[email protected]",
comment = c(ORCID = "0000-0003-1458-7108")),
person(given = "Jeroen",
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
(@zkamvar #56)
* 2021-10-18: links and asis nodes that are at the beginning of paragraphs are
no longer escaped (@zkamvar, #58)
* 2022-02-07: @zkamvar is now the maintainer

# tinkr 0.0.0.9000

Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/test-asis-nodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ test_that("multi-line inline math can have punctutation after", {
}
})


test_that("math with LaTeX protection will still work", {

expected <- c("Example 1: $a = \\begin{pmatrix} b \\\\ c \\end{pmatrix}$",
"Example 2: $f(x, \\, y)$",
"Example 3: $f(x, \\; y)$")
expected <- paste(expected, collapse = "\n\n")
math <- commonmark::markdown_xml(expected)
txt <- xml2::read_xml(math)
protxt <- protect_inline_math(txt, md_ns())
actual <- to_md(list(yaml = NULL, body = protxt))
expect_equal(actual, expected)

})


test_that("math with inline code still works", {

expected <- "some inline math, for example $R^2 = `r runif(1)`$, is failing with code\n"
Expand Down