Skip to content

Commit 9dc038a

Browse files
authored
Merge pull request #125 from ropensci/znk/french-connection/124
allow for French-style dollar signs
2 parents 2798e86 + 640e988 commit 9dc038a

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
* Documents with no trailing newline will no longer throw a warning (issue: #65;
4040
fix: #114, @zkamvar)
4141
* Documents with dollar signs but no math will no longer fail with the
42-
`$protect_math()` method (issue: #121, @maelle; fix: #122, @zkamvar).
42+
`$protect_math()` method
43+
(issue: #121, #124 @maelle; fix: #122, #125 @zkamvar)
4344

4445
## MISC
4546

R/asis-nodes.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ protect_inline_math <- function(body, ns) {
144144
# an error.
145145
le <- length(bmath[endless])
146146
lh <- length(bmath[headless])
147-
# 2024-10-10: if the number of headless tags is zero, then we are dealing
148-
# with currency. See issue #121
149-
if (lh == 0) {
147+
# 2024-10-10: if the number of headless OR endless tags is zero, then we
148+
# are dealing with currency. See issue #121 and #124
149+
if (lh == 0 || le == 0) {
150150
return(copy_xml(body))
151151
}
152152
if (le != lh) {

tests/testthat/test-asis-nodes.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ test_that("(#121) single dollar lines dont throw errors", {
77
expect_equal(actual, expected)
88
})
99

10+
test_that("(#124) french dollar lines dont throw errors", {
11+
expected <- "I've only got 2$ in the bank. Feels bad, man. Feels bad to not have 2 $\n"
12+
math <- commonmark::markdown_xml(expected)
13+
txt <- xml2::read_xml(math)
14+
expect_no_error(protxt <- protect_inline_math(txt, md_ns()))
15+
actual <- to_md(list(yaml = NULL, body = protxt))
16+
expect_equal(actual, expected)
17+
})
18+
1019
test_that("mal-formed inline math throws an informative error", {
1120
patherr <- system.file("extdata", "basic-math.md", package = "tinkr")
1221
me <- yarn$new(patherr, sourcepos = TRUE)

0 commit comments

Comments
 (0)