fix: JCEF 코드포스 수식 중복 표시·번역 마크업 파괴 해소 (#25)#26
Merged
Conversation
JCEF 폴백은 MathJax가 이미 렌더링한 DOM을 가져와 수식마다 렌더링 span과 원본 TeX script가 공존했음. 이로 인해 수식이 두 번씩 표시되고, 번역 시 구글 번역이 span의 속성 마크업까지 번역하며 본문이 파괴됨. - CodeforcesCrawler: MathJax 렌더링 잔여물 제거 + script의 원본 TeX를 $$$ 구분자로 복원해 Jsoup 경로와 동일한 형태로 정규화 (원본 HTML에는 해당 노드가 없어 no-op) - TranslateService: 번역 보호 대상을 <pre> 외에 수식 구간($...$, $$...$$)까지 확장. 보호 구간을 플레이스홀더로 치환해 한 번에 번역한 뒤 복원 — 구간별 API 호출 폭증(수식 개수만큼) 방지 - MathJax 정리·번역 보호 단위 테스트 추가
가져오기 시점 정리만으로는 수정 이전 버전에서 JCEF 폴백으로 가져와 problem.json에 오염된 채 저장된 문제가 그대로 남는다. 저장된 문제를 불러올 때도 stripMathJaxArtifacts로 정리해 재가져오기 없이 표시·번역이 정상화되도록 함. 오염되지 않은 본문은 문자열 검사만 하고 그대로 반환.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #25
증상
JCEF 폴백으로 가져온 코드포스 문제(예: 2241E)에서 수식이 두 번씩 표시되고(
n n,u u), 번역하면role="presentation" style="위치: 상대;"같은 HTML 속성 조각이 본문에 노출되며 완전히 깨짐.원인
TranslateService가 이 HTML을 통째로 구글 번역에 보내면서 속성 마크업까지 번역·파괴됨변경
CodeforcesCrawler (근본 원인)
script[type=math/tex]의 원본 TeX를$$$구분자 텍스트로 복원 (display 수식은$$$$$$) → 기존 정규화를 그대로 타서 Jsoup 경로와 동일한 결과.MathJax,.MathJax_Preview,.MathJax_Display등) 제거TranslateService (2차 방어 + 성능)
<pre>외에 수식 구간($...$,$$...$$)까지 확장 — KaTeX 소스가 번역되며 깨지는 것 방지__CTKn__)로 치환해 한 번에 번역 후 복원 — 기존 구간별 호출 방식이면 수식 50개짜리 문제에서 API 호출이 50회로 폭증했을 것테스트