]> git.lyx.org Git - lyx.git/commit
Fix crash when generating MathML with InsetMathBox
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 20 Jul 2024 10:15:32 +0000 (12:15 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 22 Jul 2024 20:08:58 +0000 (22:08 +0200)
commitb29b3eb1fcbc30aad3c5e2800a9db61b823f65ae
tree26e79af9c03032eecf1bfe9fdcb62577f6edef31
parent17bc6d05b327034c2034087978c2ebf9f8d9e469
Fix crash when generating MathML with InsetMathBox

Instead of generating code and parsing it to add <mtext>...</mtext> at
the right spots, this commit honors the text mode setting that was
already present in the codebase to generate it automatically.

This is the work of two helper methods in MathMLStream:

* beforeText() notices when the stream is in text mode and that a
  <mtext> has not yet been generated. In this case it inserts it, so
  that raw text can be emitted afterwards.

* beforeTag() checks whether a <mtext> needs to be closed at this
  point, and does it if needed.

To make this work, the code now tracks the nesting level in the
stream, and compares it the what the level was when text mode has been
enabled using the SetMode helper function.

In order to avoid later bugs, member os() that allows to access the
underlying stream of MathMLStream is removed. This required many <<
operators to become friends of MathMLStream.

In InsetMathBox, rename splitAndWrapInMText() to mathmlizeHelper(),
which is not just a method that sets text mode inside a <mrow>
element.

In InsetMathFont and InsetMathHull, the explicit generation of nesting
in <mtext>...</mtext> can be removed now.

Fixes bug #13069.

(cherry picked from commit 216a6fb348dedac3230f651287a0ccfb48b88818)
src/mathed/InsetMath.cpp
src/mathed/InsetMathBox.cpp
src/mathed/InsetMathFont.cpp
src/mathed/InsetMathHull.cpp
src/mathed/MathStream.cpp
src/mathed/MathStream.h
status.24x