Skip to content

Fix omml template bugs. - #2257

Merged
afourney merged 1 commit into
mainfrom
fix_omml_formats
Jul 29, 2026
Merged

Fix omml template bugs.#2257
afourney merged 1 commit into
mainfrom
fix_omml_formats

Conversation

@afourney

Copy link
Copy Markdown
Member

Fix fallback handling for unrecognized OMML attribute values

get_val() returned the lookup key itself when an OMML attribute value was not
found in its mapping table. Callers use that result as a str.format() template,
so an unrecognized value produced malformed LaTeX or raised (ValueError,
IndexError, KeyError) rather than falling back to a sensible default. Because
pre_process_docx catches exceptions per part, a single unrecognized value
silently disabled equation conversion for an entire document.xml.

get_val() now falls back to the caller's default on a miss, so only templates
defined in latex_dict.py reach .format(). The two call sites that legitimately
pass a character through as literal text (do_d delimiters, do_nary operators)
now use a new get_char() helper that retains the previous behavior.

do_groupchr() passed no default at all; added CHR_DEFAULT["GROUP_CHR_VAL"]
(\underbrace, matching ECMA-376's U+23DF default for the grouping character).
This also fixes an AttributeError when <m:groupChr> has no <m:chr> child.

Affected handlers: do_acc, do_bar, do_f, do_groupchr. Recognized values are
unchanged. Existing tests pass, including test_docx_equations.

@afourney
afourney merged commit 007ea02 into main Jul 29, 2026
6 checks passed
@afourney
afourney deleted the fix_omml_formats branch July 29, 2026 17:08
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