Fix LaTeXWriter not stripping $$ delimiters from text/latex MIME output#2929
Fix LaTeXWriter not stripping $$ delimiters from text/latex MIME output#2929singhharsh1708 wants to merge 3 commits intoJuliaDocs:masterfrom
Conversation
|
I maintain that this is a bug in ModelingToolkit: That's not valid LaTeX. |
|
You're right that $$\begin{equation}...\end{equation}$$ is invalid LaTeX — the bug belongs in the package generating it. |
|
I don't think there needs to be any change in Documenter. We shouldn't try to correct other people's incorrect LaTeX. |
|
It's probably because Ideally there would be some way to tell it not to - which SciML/MTK could use. But at a brief glance I could not find one. |
|
Understood, closing this. The fix belongs upstream — either in Latexify.jl to provide a way to suppress the \begin{equation} wrapper, or in ModelingToolkit's MTKLatexifyExt.jl to use that option once available. |
When a type's show(io, ::MIME"text/latex", ...) wraps output in $$
or \[...\] around a display math environment (e.g. ModelingToolkit),
LaTeXWriter was writing the content verbatim. This caused a 'Bad math
environment delimiter' LaTeX error because both $$ and \begin{equation}
try to open math mode.
Add _strip_latex_math_delimiters which strips outer $$/\[...\] delimiters
only when the inner content already contains a \begin{...} environment.
Plain math content like $$ \left[...\right] $$ is left unchanged.
Fixes #2923