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

feat: do not break math #67

Merged
merged 10 commits into from
Apr 5, 2024
Merged

feat: do not break math #67

merged 10 commits into from
Apr 5, 2024

Conversation

maelle
Copy link
Contributor

@maelle maelle commented Apr 4, 2024

Fix #60
Fix #61
Fix #64
Fix #65

@xtimbeau could you please have a look?

@maelle
Copy link
Contributor Author

maelle commented Apr 4, 2024

I need to try the case with a one-character equation though.

@@ -191,7 +194,7 @@ translate_part <- function(xml,
non_splitting_tags = "text,softbreak",
formality = formality,
glossary_id = glossary_id,
ignore_tags = "code,code_block,curly,notranslate"
ignore_tags = "code,code_block,curly,math,notranslate"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

because of this I had to re-record all fixtures 🙃

Code
math_lines[4]
Output
[1] "E = m \\times c^2"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this actually looks good in the output file, but that's how the backslash has to be recorded here.

@xtimbeau
Copy link

xtimbeau commented Apr 5, 2024

Hi @maelle, protect_math is working, but there are still 3 problems (that I know).

  1. One char equations are throwing an error #
  2. multiple _in latex are (wrongly) transformed to tag
  3. there is still the problem of footnote equation equations and footnote don't play nicely #65

In #61 I proposed a way to deal with 1 and 2 (not very satisfying, I agree) by adding chararecters (xXx sequence) to one char equation (which deals with the bug) and by transforming "_" to "°°" before translation. Both replacements are reversed after the translation, so everything is invisible to the user. If protect_math was able to deal with those cases, than those 2 workarounds would be useless.

@maelle
Copy link
Contributor Author

maelle commented Apr 5, 2024

@xtimbeau thanks!

One char equations are throwing an error #

Have you installed tinkr from my branch? Running pak::pak() should do that automatically.

there is still the problem of footnote equation

See my latest commit, I was working on that.

multiple _in latex are (wrongly) transformed to tag

Any example I could use?


How nice is this equation? Note that $\alpha=1$ and $b$ is not defined.

$i_t = j_t$
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xtimbeau I had added this.

Copy link

Choose a reason for hiding this comment

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

Ok, tinkr@one-char-math is working for one char equations (nice!)

And it is also working with multiple underscores (you're a magician)

---
title: multiple underscore
description: equations in babeldown
---

$e_t = e_{t-1} + \varepsilon_t$ une équation à `_` !

En bloc :

$$
e_t = e_{t-1} + \varepsilon_t
$$

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great! I'll merge this if the checks pass. Then you can report new bugs in the coming weeks 😸

@maelle maelle mentioned this pull request Apr 5, 2024
@maelle maelle merged commit 4ad4c74 into main Apr 5, 2024
5 checks passed
@maelle maelle deleted the equations branch April 5, 2024 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants