From b9bba2093b24cf08b9ac7944a092dd4fd91dd340 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Tue, 1 Feb 2022 17:33:56 -0800 Subject: [PATCH] add test for #61 (this will fail) --- tests/testthat/test-asis-nodes.R | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/testthat/test-asis-nodes.R b/tests/testthat/test-asis-nodes.R index cf310b0..d6cca1b 100644 --- a/tests/testthat/test-asis-nodes.R +++ b/tests/testthat/test-asis-nodes.R @@ -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"