compute-engine
compute-engine copied to clipboard
fix: various metadata preservation issues (boxing, LaTeX-parsing)
Noticed that verbatimLatex not being saved on BoxedExpression instances created from ce.parse for some time. Looks as if this traceable to commits:
cd557e5 - 'arch: changed JSON canonical format, APIs for serialization to LaTeX and MathJSON' (2024-06-25)
^Wherein there is retraction of passing of 'metadata' to ce.box from within ce.parse
And:
e1f9e19 - 'arch' (2024-09-25)
^In which 'metadata' is retracted both as an argument to 'box' (the function) and its inner forwarding to BoxedExpression constructor calls when handling 'MathJSON object literals'.
As a guess, it appears to me that removing metadata as a parameter from box was apt due to these properties being foreseen as present on MathJSON object literals: if present at all. Looks however that in these changes that the step of checking for this meta elsewhere (i.e. object literals) and forwarding onwards (like before) is absent.
This 'fix' is only an educated guess & seems to address the issue,
But this change/request also appears to break a single test-case within test/compute-engine/latex-syntax/numbers.test.ts - which I have not investigated - and thus is not suitable for merging.
(Note at the time of this request, the HEAD of main (#115272d, there is already extant a single test failure (test/compute-engine/functions.test.ts -> Apply -> Function and Hold), which is not related to this change).
Single commit also includes an unused utility isExpressionObject, which was initially used, but could now be discarded.
(Could also do with a couple of test cases for this feature)