Implement math.var to differentiate $a$ and $"a"$ in equations.#4638
Implement math.var to differentiate $a$ and $"a"$ in equations.#4638wrzian wants to merge 6 commits intotypst:mainfrom
math.var to differentiate $a$ and $"a"$ in equations.#4638Conversation
math.var to finally differentiate $a$ and $"a"$ in equations.math.var to differentiate $a$ and $"a"$ in equations.
|
I believe this also closes #3727. I'll double check when adding tests to |
b4ee161 to
5f31dcc
Compare
|
Rebased onto main. Still need to document what the changes and tradeoffs are before review. |
|
I'm sorry for completely ignoring this PR for months. It fell into the unforunate spot of being a very complex and intricate topic that is quite far removed from anything else I'd been thinking about at the time. I took a look at the changes now and I must admit that I have a somewhat uneasy feeling about having a bool in symbol that states whether it came from math. It feels wrong somehow. What's your take on this particular change? |
14b0207 to
e3d1be6
Compare
|
No worries on the delay! This change is a necessary fix, but certainly not the most urgent. It's also been a while since I've touched this, but that's given me some time to cook. I was able to rebase from Having rewritten most of the code again, I agree that just a bool in |
|
We should probably discuss this more on Discord. |
|
Maybe some more direct discussion would be nice. How about having an actual Zoom or Discord design call about this sometime in January? |
|
Rebased from main, but still need to fix a few things |
Test intentionally had `math.var` layout behavior, but only by implicitly having single characters in certain content -- updated by editing the code to explicitly or implicitly call `math.var`. (implicitly by changing strings to character escapes in equations) ``` math/alignment.typ:4 : math-align-weird math/attach.typ:164 : math-attach-nested-base math/delimited.typ:42 : math-lr-color math/interactions.typ:92 : issue-math-realize-scripting math/stretch.typ:57 : math-stretch-shorthand math/text.typ:29 : math-optical-size-primes foundations/content.typ:53 : content-fields-complex model/enum.typ:86 : enum-numbering-closure-nested-complex ``` Test did not intend to use `math.var` behavior -- fixed by updating the reference image ``` math/interactions.typ:15 : math-equation-auto-wrapping math/mat.typ:109 : math-mat-align-implicit math/mat.typ:117 : math-mat-align-explicit-left math/mat.typ:101 : math-mat-align-explicit-alternating math/mat.typ:125 : math-mat-align-explicit-right math/vec.typ:13 : math-vec-align-explicit-alternating ```
|
Cleaned this pull request up for historical purposes, but we had our call and the resolution was to not create VarElem at the moment, but convert MathText kinds into a new SymbolElem that will be used for symbols going forward. We'll do the larger change of something like VarElem later, but SymbolElem should allow us to close #274. Closing this for now and will open a new PR soon. |
This is a draft implementation of the
math.varupdates for semantically separating math variables from other text in equations.This will close the ancient #274 and is the beginning of a solution for #254, #366, and #1125.
This removes the auto-italics correction on single-character text in math that is not a
math.varelement. However, my intent is that math layout will eventually be updated to only use the math font withinmath.varelements and use the document font for strings and normal content in math. That update will likely come in a later PR, and I would like to leave it as a separate discussion for now, see #366.This is similar to PR #1779 by @damaxwell. However, with the updates to the layout system, I wasn't able to use much of that code at all and wrote most of this from scratch. That PR was closed for a number of open questions around show rules and regex replacement. This PR is focused mainly on fixing the auto-italics issue and leaving deeper language changes related to show-rules or new syntax for a later date.
There is still a lot to do and many details to fuss over, but the core has been implemented, and I'm happy to report only 4 tests are currently failing! There have been so many edge cases and horrible details in implementing this, but I'd love to nail the remaining ones down and maybe get this shipped for 0.12.
The four currently failing tests are the following:math-attach-show-limit (tests/suite/math/attach.typ:106)andmath-symbol-show-rule (tests/suite/math/interactions.typ:67)These two are related to show-rules on symbol elements in math not working at all right now.
enum-numbering-closure-nested-complex (tests/suite/model/enum.typ:86)This one is probably just weird behavior that we're going to ignore. But I'm really not sure what to do for it.
math-lr-color (tests/suite/math/delimited.typ:42)This is related to the semantic difference between
math.varandtextin general. Not sure what the resolution should be here, but requires some thought about howtextandmath.varare styled.I'm not fully sure how to fix these right now, and would love any guidance or suggestions from others.EDIT: fixed the remaining failures! Will add an explanation for the test updates below.
I'll also make a general call for help: I would love any help updating documentation around symbols/
math.varor adding tests tovar.typ. I'll be doing this myself as I can, but would appreciate any others chipping-in.