You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Text runs are serialized without \text{} when defaultMode is "text", making the value unusable outside the mathfield #3078
That value is only meaningful to another text-default field. Handed to anything else that reads LaTeX — convertLatexToMarkup(), renderMathInElement(), a server, a database — Hello is a run of five italic variables and its spaces are gone, because outside a text-default context unmarked words are maths.
It round-trips within a text-default mathfield, so it is self-consistent; the problem is that the emitted LaTeX is not portable, and there is no option to ask for the marked form.
The two mode serializers make opposite decisions from the same flag:
src/core/modes-text.ts — needsWrap is options.defaultMode !== 'text', so a text run is never wrapped in a text-default field.
src/core/modes-math.ts — a maths run is wrapped in $ … $ precisely when options.defaultMode === 'text'.
So in a text-default field the maths is marked and the words are not. That is fine while the whole document is text, and ambiguous as soon as it is mixed.
Proposed fix
A text run that shares the document with maths is marked whatever the field's default mode; words on their own are left alone. The decision is made where a run is already being split by mode, so both the styled and skipStyles paths agree.
This is the blocker for the use case in #2420. An application that stores a mathfield's value and renders it anywhere else — a document, a print view, another mathfield in maths mode — has to re-mark the words itself to know which parts were prose. We do that with a normalization pass over every value on the way in and out; the marked form removes the need.
Activity