Add EqEdit triangle symbol support - #93
Conversation
airmang
left a comment
There was a problem hiding this comment.
Thanks for this PR — the diagnosis is exactly right (latex2mathml does classify \triangle as an identifier while \angle already comes out as an operator, so the minimal scope here is well chosen), and I really appreciate the negative test cases around identifier splitting. Nice work.
While playing with the branch locally I ran into one edge case I'd like to fix before merging:
\text{...} content gets rewritten too. The regex substitution runs over the whole LaTeX string, so a quoted EqEdit literal containing \triangle breaks:
render_equation(r'"\triangle" + x')
# main: <mtext>\triangle</mtext><mo>+</mo><mi>x</mi>
# PR: <mtext>\mathop{\triangle</mtext><mi>}</mi><mo>+</mo>...Rare input, but the tokenizer accepts it and main renders it cleanly. Skipping \text{...} arguments before the substitution (plus a negative test for this script) should cover it. Happy to handle this in a follow-up if you'd prefer.
One question on the authoring direction: since _invert is first-seen, \triangle now authors as lowercase triangle. We got burned by this once with forall — the real Hancom build renders the lowercase form as literal text, which is why authoring emits FORALL (ff79bd8). Do you know whether lowercase triangle has been render-verified on a real build? If it's only been observed in the reading direction, it might be safer to add an explicit "\triangle": "TRIANGLE" override matching the documented spelling until we can verify.
Everything else looks good to me — once the \text case is covered I'm happy to merge.
Summary
TRIANGLEtoken and source-evidenced lowercasetriangletoken to LaTeX\triangleVerification
The change is a general EqEdit token-map correction; it has no document-, school-, hash-, or full-script-specific behavior.