Skip to content

fix: Typst codegen bugs for math markup and edge cases#87

Merged
developer0hye merged 1 commit intomainfrom
ralph/phase15-typst-codegen-fixes
Mar 1, 2026
Merged

fix: Typst codegen bugs for math markup and edge cases#87
developer0hye merged 1 commit intomainfrom
ralph/phase15-typst-codegen-fixes

Conversation

@developer0hye
Copy link
Owner

Summary

  • US-310: Add groupChr element handling — maps OMML (overbrace) and (underbrace) to Typst overbrace() / underbrace() functions
  • US-311: Subscript/superscript syntax already correctly wraps multi-token content in parentheses via wrap_if_needed(); added regression tests
  • US-312: Fix empty radicand in sqrt() / root() — emit placeholder "" instead of missing argument to prevent Typst "missing argument: radicand" error
  • US-313: Fix delimiter balancing — when begChr or endChr is empty, omit both delimiters to prevent unmatched bracket errors in Typst
  • US-314: Wrap non-ASCII alphabetic text (Cyrillic, CJK, etc.) in math mode with upright("...") to prevent Typst "unknown variable" errors
  • US-315: Escape [, ], {, } in text content alongside existing Typst special character escaping to prevent premature content block closure
  • US-316: Fall back to solid fill when gradient has < 2 stops — prevents Typst "a gradient must have at least two stops" error

Related: #80, #81

Test plan

  • Unit tests for all 7 user stories (groupChr, sub/superscript, empty radicand, delimiter balancing, non-ASCII math text, text escaping, single-stop gradient)
  • cargo test --workspace passes (722+ tests)
  • cargo fmt --all -- --check passes
  • cargo clippy --workspace -- -D warnings passes
  • CI passes

🤖 Generated with Claude Code

- Add groupChr element handling for OMML overbrace/underbrace (US-310)
- Fix subscript/superscript parentheses via existing wrap_if_needed (US-311)
- Handle empty radicand in sqrt/root with placeholder (US-312)
- Fix delimiter balancing by omitting empty delimiter pairs (US-313)
- Wrap non-ASCII alphabetic text in math mode with upright() (US-314)
- Escape brackets and braces in text content for Typst (US-315)
- Fall back to solid fill for single-stop gradients (US-316)

Closes #80, Closes #81

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
@developer0hye developer0hye force-pushed the ralph/phase15-typst-codegen-fixes branch from 3780013 to 0200b47 Compare March 1, 2026 08:27
@developer0hye developer0hye merged commit 23de658 into main Mar 1, 2026
14 checks passed
@developer0hye developer0hye deleted the ralph/phase15-typst-codegen-fixes branch March 1, 2026 08:37
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