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

Detect Quarto and protect MathJax . #844

Closed
wants to merge 1 commit into from
Closed

Detect Quarto and protect MathJax . #844

wants to merge 1 commit into from

Conversation

dmurdoch
Copy link
Collaborator

@dmurdoch dmurdoch commented May 6, 2024

This is so just a draft PR at the moment. Some issues:

  • If it detects Quarto, it wraps the contents of any cell containing two dollar signs with a wrapper as suggested by @cderv. That will catch false positives, e.g. multiple dollar amounts. Is this a problem?
  • It issues a warning if it has done the wrapping but the user had escape = TRUE. Should it just ignore that case?

When done, this fixes #746 .

@dmurdoch
Copy link
Collaborator Author

dmurdoch commented May 6, 2024

Thinking about this a bit more: this is really a Quarto bug, and should be fixed there. If we add a workaround like this, it will probably cause trouble when Quarto deals with the issue (which doesn't only affect kableExtra).

@dmurdoch dmurdoch closed this May 6, 2024
@dmurdoch dmurdoch deleted the quarto branch May 6, 2024 20:48
@cderv
Copy link

cderv commented May 7, 2024

this is really a Quarto bug

This can be discussed more in the Quarto issue, but this is not considered a bug on Quarto side.

Quarto won't parsed Markdown syntax inside a HTML table. So if kableExtra emits some HTML code containing markdown syntax, this markdown syntax won't be processed by Quarto not Pandoc. This includes Maths, Citations, or any markdown syntax.

Same with LaTeX table - Markdown is not parsed inside a LaTeX code. And this one is true for bare pandoc always.

Quarto provides a feature to allow some such content to be marke inside HTML table or LaTeX table, so that they are catched, processed by Quarto and Pandoc and inserted back in place. My suggestion is for kableExtra to leverage this feature in Quarto context.

Tools like gt provides some features to deal with this in general,not only in Quarto context.
I know they do offer special formatting function for markdown cells (processed by commonmark to transform to HTML before emitting output as HTML), or HTML cells to mark them as raw html to avoid escaping.
They do have now support for math by rendering them to HTML in R using katex R package so that HTML is produced (and not markdown).
And I think they do support citations in cells also by allowing to mark them as to be processed by Quarto, leveraging the attributes feature for HTML or LaTeX I mentioned in the issue.

I'll plan to document this more so that package author can make their choice regaring all this.

Hope it helps understand.

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.

Mathjax is not working properly with kableExtra html format in Quarto
2 participants