Mykhailo Mishchenko <[email protected]> writes:
> I've split this regexp in two: one is searching for the beginning of MathML,
> and another — for its end. A patch is attached.
Hi Mykhailo,
Thanks for the patch!
I ran into this exact issue when exporting a document with a complex
MathJax formula, and applying your fix solved the stack overflow for me.
I'm quite new to this, but while testing it I noticed a small difference
with the original code:
> - (match-string 0)))))
> + (let ((from (match-end 0)))
> + (when (re-search-forward "</math>" nil t)
> + (buffer-substring from (match-beginning 0))))))))
It worked fine in my specific test, but I think we need to keep the
full `<math>...</math>` wrapper because OpenDocument / LibreOffice needs
those tags to know where the MathML object actually starts and ends.
Without them, it might fail to render as a proper formula in other cases.
To keep the tags (just like the original code did), we could use
`(match-beginning 0)` like this:
(when (re-search-forward
(format "<math[^>]*?%s[^>]*?>"
(regexp-quote "xmlns=\"http://www.w3.org/1998/Math/MathML\""))
nil t)
(let ((from (match-beginning 0)))
(when (re-search-forward "</math>" nil t)
(buffer-substring from (match-end 0)))))
Thanks again for fixing this!
Best regards,
Carlos