Add math.number element, to separate number vs number-like text in math #7577
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new math element
math.numberwith the introduction of structNumberElem, so that number (e.g.$2.1$) and number-like text (e.g.$"2.1"$) can be differentiated. A number can contain multiple digits and a decimal point in the middle, as controlled by the lexer'smath_text().This way, as demonstrated in the new ref image
math-number-parsed.png, we can apply a different rendering procedure to the numbers (see the changes in this PR's math/text.rs).This PR fixes #7574 (see the new ref image
issue-7574-footnote-inside-math.png). The footnote notation (e.g.1andnote 2) doesn't really have the semantics of a number in math, and thus should be rendered as text. See comments this and this on that issue.This PR changed the ref image
enum-numbering-closure-nested-complex.png, because a numbered list isn't in a math context, and therefore the bullet point indexes should be rendered as text.This PR changed the code snippet of test
math-attach-nested-baseinattach.typ, because[0]is a content block holding a text of zero, while[$0$]forces the zero to be a number in math context. This difference is also specifically tested in the new testmath-number-parsed(seea0andb0there).CC @mkorje