-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix inline math with code #57
Conversation
This will cause things like 10$? to break, but I think these kinds of things are rare enough to allow for things like $\beta$, to be valid
Note, while this PR will fix #56, there is still the problem of math and links that begin a line: library(tinkr)
ex <- "- so $\\beta^2 = `r runif(1)`$ works but,\n- $\\beta$ has the first dollar escaped"
f <- textConnection(ex)
y <- yarn$new(f)
close(f)
y$protect_math()$show()
#> - so $\beta^2 = `r runif(1)`$ works but,
#> - \$\beta$ has the first dollar escaped Created on 2021-10-15 by the reprex package (v2.0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@@ -20,6 +20,8 @@ | |||
sink to the bottom of the document. | |||
* 2021-09-14: numeric options fig.width and fig.height will no longer be quoted; | |||
`transform_params()` is simplified and no longer requires glue. | |||
* 2021-10-15: math with embedded code and punctuation following are now allowed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the edge cases 😁 👏
R/asis-nodes.R
Outdated
# a space or another dollar. | ||
start <- glue::glue("(?=^|{punks})[$]?[$][^{ace}$]") | ||
# a space, a dollar sign, or any possible adjacent punctuation. | ||
no_punks <- glue::glue("{minus_maybe}[^]}}>){ace},;.?$-])") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👩🎤
This updates the regex so that
$,
is no longer considered to be a starting element and adds an "ambiguous" flag that can be checked for the presence of a code block immediately preceding.Created on 2021-10-15 by the reprex package (v2.0.1)
this will fix #56