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

make protect math exit early for money #122

Merged
merged 4 commits into from
Oct 16, 2024
Merged

Conversation

zkamvar
Copy link
Member

@zkamvar zkamvar commented Oct 11, 2024

This adds a catch that will make the $protect_math() method exit early without
an error if there is unbalanced math without any trailing dollar signs, which
will indicate text with dollar amounts (like grants).

Note that this is still vulnerable if dollars are mixed with math that is broken
across lines.

This will fix #121

Copy link
Member

@maelle maelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much

@@ -1,6 +1,6 @@
Package: tinkr
Title: Cast '(R)Markdown' Files to 'XML' and Back Again
Version: 0.2.0.9000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think you might enjoy {fledge} since you're so good at incrementing version numbers!

@@ -38,6 +38,8 @@
#96, fix: #111, @zkamvar)
* Documents with no trailing newline will no longer throw a warning (issue: #65;
fix: #114, @zkamvar)
* Documents with dollar signs but no math will no longer fail with the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey I really like your tracking both issue and fix!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@@ -1,3 +1,12 @@
test_that("(#121) single dollar lines dont throw errors", {
expected <- "I've only got $2 in the bank. Feels bad, man.\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add the same example to the README? saying that you can use dollars as currency without any problem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added it, but I've added a caveat that there will be a problem if there is a mix.

@yabellini
Copy link
Member

This is great! Thanks @zkamvar ! 🙏

@@ -28,3 +28,22 @@ you must be sure to either use punctuation after the trailing dollar sign OR for
math$head(15) # malformed
math$protect_math() #error
```
4. **use of `$` as currency will still work**, but there is a caveat that mixing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the two *?

I'd break this sentence in two. Saying it works, saying "nevertheless, if there's broken math ()..."

this inline math broken across lines will cause problems:
```{r, split, error = TRUE}
# this will be mal-formed
bad <- "It's 5:45 and I've got $5.45 in my pocket.\nThe __area of a circle__ is $A =\n \\pi r^2$, where\n$\\pi$ is irrational when it hasn't had its coffee."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice example 😸

@maelle
Copy link
Member

maelle commented Oct 14, 2024

Thank you!!

@zkamvar zkamvar merged commit 2798e86 into main Oct 16, 2024
12 checks passed
@zkamvar zkamvar deleted the znk/money-money-2020/121 branch October 16, 2024 04:23
This was referenced Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

how do we protect money dollar sign from math protection
3 participants