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

Correctly deactivate math support in Rmd for @includeRmd with math #1306

Merged
merged 1 commit into from
Mar 24, 2022

Conversation

cderv
Copy link
Contributor

@cderv cderv commented Mar 24, 2022

This follows up on #1304 to fix rstudio/rmarkdown#2331

This will now correctly modify option to rmarkdown::github_document() conditionnaly. I messed up my test last time but now this work as expected.

Tested by:

This produce what is explained in the comment in previous PR: #1304 (comment)

This in markdown

$$
\eta_{i} = (\beta_0 + b_{0i}) + \beta_1x_{i1}
$$ 

will produce this in Rd file

\emph{η}\if{html}{\out{<sub>}}\emph{i}\if{html}{\out{</sub>}} = (\emph{β}\if{html}{\out{<sub>}}0\if{html}{\out{</sub>}}+\emph{b}\if{html}{\out{<sub>}}0\emph{i}\if{html}{\out{</sub>}}) + \emph{β}\if{html}{\out{<sub>}}1\if{html}{\out{</sub>}}\emph{x}\if{html}{\out{<sub>}}\emph{i}1\if{html}{\out{</sub>}}

as Pandoc will convert this math using Plain text. Complex LaTeX math won't work in github document output as pandoc will produce this

$ echo "$\frac{1}{2}$" | pandoc -t gfm
[WARNING] Could not convert TeX math \frac{1}{2}, rendering as TeX
$\\frac{1}{2}$

@EmilHvitfeldt can you confirm this time this PR work on your projects ? Thank you !

@hadley I am trying to add test so that change on math in included Rmd can be detected

@EmilHvitfeldt
Copy link
Member

This works for me test in reprex and parsnip 🎉

Comment on lines -48 to +51
output_format = rmarkdown::github_document(html_preview = FALSE),
output_options = list(
if (packageVersion("rmarkdown") >= "2.12") math_method = NULL
output_format = "github_document",
output_options = c(
list(html_preview = FALSE),
if (packageVersion("rmarkdown") >= "2.12") list(math_method = NULL)
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 could also be done probably by creating the format with option using a do.call(rmarkdown::github_document, ...)
I can change if that better fits the usual practice or if it seems clearer.

@hadley hadley merged commit 76ebaab into r-lib:main Mar 24, 2022
@cderv cderv deleted the fix/1304-followup branch March 24, 2022 19:13
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.

Pandoc error when rendering Rmd included in roxygen documentation during devtools::document()
3 participants