Skip to content

fix: correct \underleftarrow macro and map math italic h in equation conversion - #2293

Open
Guillermo Dols (gdols) wants to merge 1 commit into
microsoft:mainfrom
gdols:fix/omml-latex-symbol-table
Open

fix: correct \underleftarrow macro and map math italic h in equation conversion#2293
Guillermo Dols (gdols) wants to merge 1 commit into
microsoft:mainfrom
gdols:fix/omml-latex-symbol-table

Conversation

@gdols

Copy link
Copy Markdown

Two small fixes in the OMML → LaTeX tables used to convert equations out of .docx. I ran into both while auditing the symbol tables after #2228 and #2257; neither is covered by an open PR as far as I can tell.

1. U+20EE emits a macro that does not exist

CHR maps U+20EE COMBINING LEFT ARROW BELOW to \underledtarrow. That is not a LaTeX macro — the name is a scrambled \underleftarrow. The two neighbouring entries in the same table make the intent clear:

"⃭": "\\underleftharpoondown{{{0}}}",
"⃮": "\\underledtarrow{{{0}}}",       # <-- here
"⃯": "\\underrightarrow{{{0}}}",

and U+20D6, the "above" counterpart, is already \overleftarrow.

The template is still well formed, so nothing raises and the conversion looks like it succeeded — the equation just carries an undefined control sequence that no renderer can typeset. The entry dates back to the original dwml table this module was adapted from.

2. Math italic h is the only Latin letter left untranslated

T normalizes the Mathematical Alphanumeric Symbols back to ASCII so equations come out as readable LaTeX. It walks U+1D434U+1D44D for AZ and U+1D44EU+1D467 for az, but math italic small h has no codepoint inside that block: U+1D455 is permanently reserved, because Unicode unifies that letter with U+210E PLANCK CONSTANT. Following the contiguous range therefore skipped h, and it is the single letter of the alphabet that survives into the output.

An expression written with math italic codepoints:

output
before ℎ(x)=g(x)
after h(x)=g(x)

Tests

Added packages/markitdown/tests/test_docx_math_symbols.py. All five tests fail on main and pass with this change. One of them walks the entire math italic alphabet and asserts every letter round-trips to ASCII, so a future gap in that range cannot slip back in unnoticed.

5 passed

The rest of the suite is unaffected, and black reports no changes.

…conversion

U+20EE COMBINING LEFT ARROW BELOW mapped to \underledtarrow, which is not a
LaTeX macro -- the name is a scrambled \underleftarrow. The two neighbouring
entries in the same table show the intent: U+20D6 -> \overleftarrow and
U+20EF -> \underrightarrow. The template still formats, so nothing raises;
the equation just ends up with an undefined control sequence.

T normalizes the Mathematical Alphanumeric Symbols back to ASCII, but skipped
math italic small h. That letter has no codepoint of its own: U+1D455 is
permanently reserved because Unicode unifies it with U+210E PLANCK CONSTANT.
Following the contiguous block left h as the only Latin letter to survive
untranslated, so an equation reading h(x)=g(x) converted to "ℎ(x)=g(x)".
@gdols

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant