Repository navigation
Show math-only lines whole on iPhone and draw rules in the text color - #318
Conversation
A Text holding only inline math has no text font, so React Native's iOS text makes it one line as tall as the pictures' boxes, with its baseline at its bottom, yet still places each view a TextKit descender higher; Text cuts off what it holds at its frame, so the top of the math and its depth were lost. Such pictures now come down onto the line, and the Text leaves room below its last line for a depth that a text-less line can't hold (#315). MathJax fills a \rule with black when no \color is in effect, and marks its rectangle as a background box. A rule without a \color now takes the text color, counts as ink when deciding whether a picture's colors stand out, and is kept, recolored, when a theme draws a picture without its colors (#317). Verified: checks
|
Preview ready for lh preview 318It runs beside your server on port 3775 with fresh, empty data, and Ctrl+C stops it and deletes it. Release files. Each push builds a new one. |
…ounding A math-only Text's depth room is now added to the bottom padding its style already has, so a table cell keeps its 4 pt. A \rule MathJax filled with black takes the nearest \color above it, which math inside \text doesn't see while it is parsed, and any other fill is left alone. React Native rounds an inline view's origin to the pixel grid, so math-only pictures come down half a point more and keep half a point more room below, and a capped lift stops half a point under its line's top. Verified: checks
|
Round 1 review, addressed in 79818f9. Each fix has a test that fails on 73447c0. Important
Nits
Measured on 73447c0 (run 44908731007, iPhone 3x). Ink extents use a 200 threshold so the faint tips of thin strokes count; a whole pair after text at 16 pt has a 57 px parenthesis rising 5 px above a 39 px zero.
So 73447c0 already showed the pairs whole at 3x. 79818f9 adds the rounding margin for 1x and 2x and keeps the cell padding. Its run: https://github.com/max-miller1204/learnharness-nightly/actions/runs/44946965028. Fingerprints are unchanged (iOS |
|
Room left around the math-only pairs on 73447c0 (run 44908731007, 3x), adding to the table in the round 1 comment. This backs the #315 model. The choice row's borders are pixel-identical before and after: row 2 spans 1491 to 1601 px. The 16 pt checkbox (plus its 3 pt margin) sets the row's height, and the Text is shorter even with its depth room. That pins the Text's frame: its top is the row's top plus a 1 pt border plus 8 pt padding, which is 1518 px.
So at 3x the pair was whole, with under a pixel to spare at each end. At 2x the same placement rounds to -3.0 pt, which would cut 0.24 pt; that's Codex's case, and the 0.5 pt margin in 79818f9 covers it. On 79818f9 the room should grow by 1.5 px at the top and 3 px at the bottom at 3x, with the row's height still set by the checkbox. I'll post that table when run 44946965028 finishes. |
A \rule with no width or no height draws nothing, so it no longer counts as ink when deciding whether a picture's colors stand out, and isn't recolored: a \colorbox holding a strut keeps its box and its text's color again, as on main. The test of a last line holding only math in a Text with text is back, on its own, covering the half point left for pixel rounding there, and the test comments name React Native's functions instead of line numbers. Verified: checks
|
Round 2 review, addressed in 6197bec. Each fix has a test that fails on 79818f9 or 73447c0.
Accepted as noted: an author's explicit All 14 mobile test files pass one at a time under a cap; typecheck and lint pass. Fingerprints are unchanged: iOS |
|
Measured on 6197bec (run 44948230371, green, iPhone 3x). Ink extents use a 200 threshold, so the faint tips of thin strokes count. A whole pair after text at 16 pt has a 57 px parenthesis rising 5 px above a 39 px zero.
The light pages 1 to 3 are pixel-identical to 73447c0 and #314's run. The dark pages and pages 4 to 6 are the same pixels, shifted by scroll and by the lone pair's room (+18 px on page 4). The math-only choice rows keep their height, because the checkbox sets it. The table cell |
|
prove-learnharness: BROKEN for 6197bec Couldn't prove the requested 2.76 pt lift and 4 to 5 pt growth, or preservation of an author's explicit black MathML fill. The math-only table padding was checked in the native component test. Android was driven in light mode, and spoken TalkBack output remains unchecked.
Answer keys were the owner's reports #315 and #317, the paired web renders, main and #314. iPhone artifacts came from runs 44948230371 and 44907871746, with 44889291506 as a cross-check. Receipt: ReceiptReceipt: PR #318 mobile mathVerdict: BROKEN What the change touches
Steps
Evidence
Android setup and evidence
Probes
Retries and fixes
Not covered
Left behind
|
Brings main's phone math fix (#318, apps/mobile only) into the 0.7.0 sync. No conflicts. Verified: checks
The phone now draws `\fcolorbox` as a box with a thin border instead of showing its TeX source. The markup allowlist stays strict: it accepts exactly one style form, `border: <number><px|em|ex> solid <colour>`, only on MathJax's mpadded node, capped at 200 characters and parsed without backtracking. MathJax's border polygons are rewritten as paths from strictly parsed, finite points. Border colours go through one parser, which accepts known names, 3- or 6-digit hex, or an rgb() triple of 0 to 255; anything else, including none, transparent and Object keys like constructor, shows as source. The #318 readability rule covers the border too, and can now measure rgb() colours. Every kept fill and stroke is written in its normalised form, which also fixes padded and mixed-case names (`\color{Navy}`, `\color{red }`) that React Native couldn't draw. The border is KaTeX's 0.04em, matching the web. The spec (mobile-quiz-choice-math.md) describes the allowance. That's an orchestrator decision under the owner's autonomy instruction. Reviews: two rounds with Claude and Codex. Round 1: rgb() with spaces, loose colour grammar, contrast for rgb(), strict points. Round 2: a cubic-backtracking freeze, untrimmed colours drawn invisibly, and Object.prototype names as colours. All fixed. Prove (fresh Claude checker on the Android emulator, head and base APKs, web KaTeX beside it): new boxes PASS in light and dark. Inputs that must stay source PASS, with the 5,000-space input staying responsive and no ANR. Existing colour commands are the same as base or better. TalkBack reads quiz math as one stop per row with no raw TeX. The same run also drove #334's tool steps (on a local merge with main) and #339's braces and bars on Android, which pass. One FAIL is on main already: `\xrightarrow{f}` draws short; it's filed separately. Closes #319 Verified: prove
What changed and why
Two phone math bugs that share the inline math code. Closes #315. Closes #317.
#315, iPhone: a line holding only inline math is cut off at the top (the choice rows "(−0.10, +0.20)" and "(+0.20, −0.10)", and the answered card's lone pair). In the #314 shots, every glyph's ink starts on the same row: 1518 px on the choice rows, 735 px in the card. Alone, the card's pair shows a 45 px parenthesis and 36 px digits; after text, the same pair is 57 px and 39 px.
Cause, in React Native 0.88.1:
Textdefaults tooverflow: 'hidden'(Libraries/Text/Text.js:546-551), so its view clips to its bounds (BaseViewProps.cpp:581-582,RCTViewComponentView.mm:443). Anything inline that lies outside the Text's frame is cut off.RCTAttributedTextUtils.mm:409-419). So itslineHeightdoesn't apply, and its one line is just the pictures' boxes, with the baseline at the bottom. Upstream's Position iOS inline views from their line's actual baseline (#59921) react/react-native#59921 message names the same case.RCTTextLayoutManager.mm:631), TextKit's Helvetica 12 (2.76 pt, as found in Put inline math on the text baseline on iOS #314). So the picture sits 2.76 pt above the Text's top, and that strip is cut off.Predicted cut on the card's pair: 8.3 px at the top, and 6.2 px at the picture's bottom (about 4.7 px at the parenthesis's bottom). Measured: about 8 px and 4 px.
Fix, iOS only (
MathLabel.tsx,NativeMarkdown.tsx):inlineLiftreturns -2.76 pt, bringing each picture down onto the line.depthRoomgives the Text apaddingBottomfor the depth of pictures on a last line with no text. For a Text with text whose last hard line holds only math, that's the depth beyond the 2.76 pt that line already leaves.Such rows grow by the math's depth (about 4 to 5 pt), which is what showing it whole takes. Android keeps its layout: no lift and no padding there.
#317, phone:
\ruledraws black. MathJax's TeX\rulefills its space with the\colorin effect, or withblackwhen there is none (mathjax-fullBaseMethods.js:573,582). Black there stands for the text's colour. The readability check (inks) only looked at token glyphs, so it never saw the rule, and the black rule stayed in both themes. MathJax also marks the rule's rectangledata-bgcolor="true", like a\colorbox, so a picture drawn without its colours deleted the rule outright.Fix (
choice-math.ts, both platforms):\colorin effect becomescurrentColor, so it takes the text colour.mspacegroup) loses its background mark, so a theme that drops colours recolours it instead of deleting it.\colorboxbackgrounds behave as before.Verified
math-baseline.test.ts: math in a Text of its own shows whole (choice, answered card, message, and a math-only last line after text). On main the picture's top is 2.76 pt above the Text's top. Android keeps its layout.choice-math.test.ts: a rule is drawn in the text colour or its own\color, flattened and unflattened.\color{black}stays black in light and is recoloured, not dropped, in dark. A rule beside an unreadable glyph is kept.\colorboxis unchanged. This fails withrulesAsInkremoved.npm run typecheck,npm run lint,npm run deps:check: pass.b294c68b58b762e9cac472a7ee00c0a6127b4216, Androidf5bb079b3763b614ffd3e8076dcba382425718a3. JS only, so it ships as an OTA update.quiz-waitingandquiz-answeredshots and pairs, measured before and after.Source
node_modules/react-native/Libraries/Text/Text.js:546-551(Text's defaultoverflow: 'hidden')ReactCommon/react/renderer/components/view/BaseViewProps.cpp:581-582,React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm:443(overflow becomesclipsToBounds)ReactCommon/react/renderer/textlayoutmanager/platform/ios/.../RCTAttributedTextUtils.mm:409-419,RCTTextLayoutManager.mm:621-632node_modules/mathjax-full/js/input/tex/base/BaseMethods.js:573,582(\rule'smathbackground)