fix: hwpeq inf 기호(∞) 우선순위 복원 (closes #762)#764
Conversation
PR edwardkim#563 (1차: \frac, \sqrt) 이후 추가 LaTeX 명령어 지원: - \dfrac, \tfrac → Fraction (display/text 스타일 분수) - \text{...} → FontStyle(Roman) (본문 텍스트) - \mathrm, \mathit, \mathbf → 기존 FontStyleKind 매핑 - \mathbb, \mathcal, \mathfrak, \mathsf, \mathtt → 신규 FontStyleKind 5종 - \overline, \underline, \not → 소문자 DECORATIONS 별칭 (대소문자 호환) - \widehat, \widetilde, \overrightarrow → 기존 DecoKind 매핑 - \textbf, \textrm, \textit → FontStyleKind 매핑 Refs edwardkim#143 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
LaTeX 환경(environment) 구문을 기존 수식 AST로 매핑:
- \begin{pmatrix}...\end{pmatrix} → Matrix(Paren)
- \begin{bmatrix}...\end{bmatrix} → Matrix(Bracket)
- \begin{vmatrix}...\end{vmatrix} → Matrix(Vert)
- \begin{matrix}...\end{matrix} → Matrix(Plain)
- \begin{cases}...\end{cases} → Cases
- \begin{aligned}...\end{aligned} → EqAlign
- \begin{align}...\end{align} → EqAlign
토크나이저: \\ (이중 백슬래시) → Whitespace("#") 변환으로 hwpeq의 # (행 구분)과 동일하게 처리.
Refs edwardkim#143
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
native-skia feature 활성화 시 equation_conv.rs의 FontStyleKind 매치에 Blackboard/Calligraphy/Fraktur/SansSerif/Monospace 분기가 누락되어 CI 빌드 실패. svg_render.rs/canvas_render.rs와 동일한 패턴으로 수정. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- FontStyleKind::Bold: 기존 동작 (italic, true) 복원. Blackboard만 upright+bold.
→ bold+italic 중첩 (it {bold {...}}) 정상 동작 보장
- \text{...} 주석에 공백 제한사항 문서화 (토크나이저 skip_spaces)
3개 렌더러 (svg_render, canvas_render, skia/equation_conv) 모두 동일 수정.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
LaTeX 수식 입력 호환성을 넓히기 위한 명령어 추가:
기호 별칭 (~60개):
- 관계/논리: \leq, \geq, \neq, \approx, \equiv, \subset, \forall, \exists 등
- 화살표: \rightarrow, \leftarrow, \implies, \iff, \mapsto, \to, \gets 등
- 연산자: \cdot, \times, \div, \pm, \cup, \cap, \oplus, \otimes 등
- 기호: \infty, \nabla, \partial, \emptyset, \dots, \perp 등
- 큰 연산자: \sum, \prod, \int, \iint, \iiint, \oint, \bigcup, \bigcap 등
구조 명령어 (5개):
- \operatorname{...} → 로만체 연산자명 (hwpeq rm 매핑)
- \phantom{...}, \vphantom, \hphantom → 보이지 않는 공간
- \overbrace, \underbrace → hwpeq arch/under 장식 매핑
간격 명령어 (7개):
- \quad, \qquad → em/2em 공백
- \, \: \; \! → thin/medium/thick/negative 공백
- 토크나이저 레벨에서 \+기호 → THINSPACE 등 명령어 변환
함수명 (6개): \sup, \inf, \lim, \limsup, \liminf, \Pr
테스트: latex_compat_tests 모듈에 11개 추가 (총 29개)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
구조 명령어 추가:
- \overset{over}{base} → Superscript AST (위 첨자로 매핑)
- \underset{under}{base} → Subscript AST (아래 첨자로 매핑)
- \stackrel{over}{base} → Superscript AST
LaTeX 환경 추가:
- \begin{array}...\end{array} → Plain Matrix
- \begin{smallmatrix}...\end{smallmatrix} → Plain Matrix
- \begin{Bvmatrix}...\end{Bvmatrix} → Vert Matrix (이중 세로선)
- \begin{split}, \begin{gather}, \begin{gathered} → EqAlign
테스트 6개 추가 (총 35개 LaTeX 호환 테스트)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
토크나이저:
- \{ → LBrace, \} → RBrace (LaTeX 이스케이프 중괄호)
- \| → Symbol(|), \# → Whitespace(#)
괄호 별칭 추가:
- \langle/\rangle → ⟨/⟩ (각도 괄호)
- \lbrace/\rbrace → {/} (소문자 별칭)
- \lceil/\rceil, \lfloor/\rfloor (소문자 별칭)
- \lvert/\rvert → |, \lVert/\rVert → ‖
테스트 2개 추가 (총 37개 LaTeX 호환 테스트)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PR #729에서 FUNCTIONS HashMap에 ("inf", "inf")을 추가하면서,
hwpeq의 inf → ∞ 매핑이 함수 텍스트 "inf"로 대체되는 회귀 발생.
수정: parser.rs에서 lookup_symbol (Unicode 기호 매핑)을
is_function (함수명 매칭)보다 먼저 점검하도록 우선순위 조정.
- inf → ∞ (기존 hwpeq 동작 복원)
- deg → ° (기존 hwpeq 동작 복원)
- sin, cos, log 등 → 기호 테이블에 없으므로 함수로 정상 처리
회귀 가드 테스트 2건 추가:
- test_hwpeq_inf_remains_symbol: lim _{n→inf} 에서 ∞ 출력 확인
- test_hwpeq_deg_remains_symbol: 90 deg 에서 ° 출력 확인
Closes edwardkim#762
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Restores hwpeq command handling so symbol lookups (e.g., inf→∞, deg→°) take precedence over function-name rendering, addressing a regression introduced by adding inf to the function table.
Changes:
- Reordered command resolution in the equation parser to prefer
lookup_symbol(cmd)overis_function(cmd). - Expanded LaTeX tokenization/parsing support (spacing commands, escaped characters, environments) and added/updated symbol/function/style tables accordingly.
- Updated SVG/Canvas/Skia equation renderers to handle newly added
FontStyleKindvariants and added regression/compat tests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/renderer/skia/equation_conv.rs |
Updates font-style rendering decisions to cover new FontStyleKind variants. |
src/renderer/equation/tokenizer.rs |
Adds LaTeX-specific tokenization (e.g., \\, spacing commands, escaped characters). |
src/renderer/equation/symbols.rs |
Extends symbol/operator/arrow/bracket/function tables and adds new font style kinds. |
src/renderer/equation/svg_render.rs |
Updates font-style rendering decisions to cover new FontStyleKind variants. |
src/renderer/equation/parser.rs |
Changes symbol-vs-function precedence and adds multiple LaTeX parsing paths + tests. |
src/renderer/equation/canvas_render.rs |
Updates font-style rendering decisions to cover new FontStyleKind variants. |
Comments suppressed due to low confidence (1)
src/renderer/equation/symbols.rs:273
is_structure_commandincludes"lim" | "Lim", but call sites (e.g. parser font-style lookahead) pass an uppercased command string. That meanslimbecomes"LIM"and won’t be recognized as a structure command in that path. Consider normalizing case insideis_structure_command(or adding"LIM") so case handling is consistent with the parser’s usage.
"CASES" | "PILE" | "LPILE" | "RPILE" |
"CHOOSE" | "BINOM" |
"lim" | "Lim" |
"REL" | "BUILDREL" |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| '{' => Some(Token::new(TokenType::LBrace, "{", start)), | ||
| '}' => Some(Token::new(TokenType::RBrace, "}", start)), | ||
| '|' => Some(Token::new(TokenType::Symbol, "|", start)), | ||
| '#' => Some(Token::new(TokenType::Whitespace, "#", start)), |
| '{' => Some(Token::new(TokenType::LBrace, "{", start)), | ||
| '}' => Some(Token::new(TokenType::RBrace, "}", start)), |
| } | ||
|
|
||
| #[test] | ||
| #[test] |
| // LaTeX 분수: \frac{a}{b}, \dfrac{a}{b}, \tfrac{a}{b} | ||
| if matches!(cu, "FRAC" | "DFRAC" | "TFRAC") { | ||
| return self.parse_latex_fraction(); | ||
| } | ||
|
|
| // LaTeX \phantom{...} — 보이지 않는 공간 (레이아웃 정렬용) | ||
| if matches!(cu, "PHANTOM" | "VPHANTOM" | "HPHANTOM") { | ||
| self.parse_single_or_group(); | ||
| return EqNode::Text(" ".to_string()); | ||
| } |
PR #729 (Task #143 LaTeX 호환 확장 1차, 5/9 머지) 회귀 정정 — FUNCTIONS HashMap 영역 ('inf', 'inf') 추가 영역 기존 hwpeq inf → ∞ 매핑이 함수 텍스트로 대체됨. 정정 (parser.rs +36/-7): lookup_symbol (Unicode 기호) 영역 is_function (함수명) 영역 먼저 점검: - inf → ∞ (기존 동작 복원) - deg → ° (기존 동작 복원) - sin/cos/log 등 → 함수 처리 (정합) 회귀 가드 테스트 2건 추가: - test_hwpeq_inf_remains_symbol - test_hwpeq_deg_remains_symbol 본 환경 head commit 만 cherry-pick (옵션 1) — PR 본문 영역 본질 (Issue #762 정정) 만 적용, commit 6~8 (Task #143 추가 LaTeX 확장) 영역 별 본질 영역 별 PR 안내. 검증: - cargo build/test/clippy --release ALL GREEN (clippy -D warnings) - 회귀 가드 2건 PASS - 광범위 sweep 168 same / 2 diff (exam_math_014/016 — 의도된 시각 변경: ∞ 기호 복원, PR 본문 정합) - WASM 4.66 MB 재빌드 - 작업지시자 시각 판정 ✅ 통과 이전 abandon (Service Worker 캐시 결함) 영역 다시 시도 — 본 환경 영역 정합 진행. closes #762
|
@oksure 검토 완료했습니다. 감사합니다. 처리 결과Merge commit: 본질PR #729 (Task #143 LaTeX 확장 1차) 머지 후 회귀 정정 — 본 환경 처리 — head commit 만 cherry-pick (옵션 1)본 PR 영역 8 commits 누적 영역 본 환경 영역 head commit (
PR 본문 영역 Issue #762 정정만 명시되어 있어, commit 6 검증
Issue #762 close. 5/10 사이클 27번째 PR — 수고하셨습니다. |
|
Merged. Merge commit: 4cf0831 |
문제
PR #729 (LaTeX 명령어 호환 확장)에서
FUNCTIONSHashMap에("inf", "inf")을 추가하면서, 기존 hwpeq의inf→∞매핑이 함수 텍스트"inf"로 대체되는 회귀 발생.samples/exam_math.hwp페이지 14/16에서∞기호가inf텍스트로 출력됨.원인
parser.rs에서is_function(cmd)(라인 500)이lookup_symbol(cmd)(라인 511)보다 먼저 점검되므로,inf가 기호(∞)가 아닌 함수 텍스트(inf)로 처리됨.수정
lookup_symbol(Unicode 기호 매핑)을is_function(함수명 매칭)보다 먼저 점검하도록 우선순위 조정.inf→lookup_symbol→INF→∞(기존 hwpeq 동작 복원)deg→lookup_symbol→DEG→°(기존 hwpeq 동작 복원)sin,cos,log등 → 기호 테이블에 없으므로 함수로 정상 처리회귀 가드
테스트 2건 추가:
test_hwpeq_inf_remains_symbol:lim _{n→inf}에서∞출력 확인test_hwpeq_deg_remains_symbol:90 deg에서°출력 확인검증
cargo test --lib: 1207 passed, 0 failedcargo clippy -- -D warnings: 경고 0건Closes #762
감사합니다.