Problem
In mixed Hebrew/English scientific content, a value and its unit can appear in an unintuitive visual order when only the number is authored as math:
The number is an isolated left-to-right math node, while mm Hg remains sibling prose inside an RTL sentence. The unit's internal order stays correct, but the unit can appear on the opposite side of the value from the intended complete measurement.
Verified diagnosis
- The source separates the number and unit at the math boundary.
ScientMathHtml applies dir="ltr" to the math node, and the bidi stylesheet isolates it.
- The following unit remains part of the surrounding prose direction.
- The equivalent complete measurement
\(12.8\,\mathrm{mm\,Hg}\) provides the intended semantic grouping.
- This is independent of rejected dollar-math recognition and KaTeX failure.
Relevant code:
apps/web/src/scient/math/ScientMath.tsx
apps/web/src/scient/presentation/scient-bidi.css
apps/web/src/scient/presentation/rehypeScientBidi.ts
Desired behavior
Hebrew prose should remain RTL while complete scientific measurements, comparisons, and similar opposite-direction phrases retain their intended internal order and attachment. Copying and accessibility reading order must remain faithful to source.
Investigation and smallest safe scope
- Build a source/render corpus for numbers plus units, comparisons, ranges, percentages, arrows, Latin identifiers, punctuation, tables, lists, and ordinary LTR paragraphs.
- Determine which examples are correctly solved by authoring the complete expression inside math and which reveal a product-level bidi defect.
- Document complete-expression authoring immediately.
- Only add renderer behavior if a bounded semantic rule can be defined without guessing arbitrary Latin suffixes or rewriting source.
Non-goals
- Do not remove math isolation globally.
- Do not attach arbitrary following Latin words to math.
- Do not guess units from a medical-only allowlist.
- Do not treat column alignment as semantic grouping.
Validation
Verify visual order manually in RTL and LTR, plus source preservation, selection copy, message copy, editor round trips, keyboard selection, and accessibility reading order.
Related: the broader comparison/direction-symbol RTL finding currently tracked as DF-019 in the Scient planning inbox.
Problem
In mixed Hebrew/English scientific content, a value and its unit can appear in an unintuitive visual order when only the number is authored as math:
The number is an isolated left-to-right math node, while
mm Hgremains sibling prose inside an RTL sentence. The unit's internal order stays correct, but the unit can appear on the opposite side of the value from the intended complete measurement.Verified diagnosis
ScientMathHtmlappliesdir="ltr"to the math node, and the bidi stylesheet isolates it.\(12.8\,\mathrm{mm\,Hg}\)provides the intended semantic grouping.Relevant code:
apps/web/src/scient/math/ScientMath.tsxapps/web/src/scient/presentation/scient-bidi.cssapps/web/src/scient/presentation/rehypeScientBidi.tsDesired behavior
Hebrew prose should remain RTL while complete scientific measurements, comparisons, and similar opposite-direction phrases retain their intended internal order and attachment. Copying and accessibility reading order must remain faithful to source.
Investigation and smallest safe scope
Non-goals
Validation
Verify visual order manually in RTL and LTR, plus source preservation, selection copy, message copy, editor round trips, keyboard selection, and accessibility reading order.
Related: the broader comparison/direction-symbol RTL finding currently tracked as DF-019 in the Scient planning inbox.