Skip to content

Render Codeforces statement math markup#53

Merged
enlorik merged 1 commit into
mainfrom
codex/fix-math-rendering-in-codeforces-statements
Jun 22, 2026
Merged

Render Codeforces statement math markup#53
enlorik merged 1 commit into
mainfrom
codex/fix-math-rendering-in-codeforces-statements

Conversation

@enlorik

@enlorik enlorik commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Problem statements from Codeforces often include pre-rendered math markup that was lost when parsing to plain text, making equations and symbols unreadable in the app.
  • Preserve safe, minimal HTML fragments so math-related markup like tex-span, sup, and sub can be rendered in the workspace while still stripping unsafe elements.

Description

  • Added a conservative HTML sanitizer safeHtml with ALLOWED_TAGS and ALLOWED_CLASS_PREFIXES to preserve Codeforces' math-related elements while removing scripts, styles, links and other unsafe attributes in cfStatementParser.js.
  • Returned new fields statementHtml, inputSpecificationHtml, and outputSpecificationHtml from parseCFProblemStatement alongside the existing plain-text fields to remain backward-compatible.
  • Updated the problem workspace to render sanitized HTML via a new StatementHtml component that uses dangerouslySetInnerHTML and falls back to plain text when HTML is not available in src/components/ProblemWorkspace.jsx.
  • Added CSS adjustments in src/components/ProblemWorkspace.css to improve spacing and prevent inline math fragments from wrapping awkwardly.
  • Extended tests in cfStatementParser.test.js to assert the presence and sanitization of preserved math markup.

Testing

  • Ran npm test -- cfStatementParser.test.js and the parser test file passed (all tests succeeded).
  • Ran npm run lint and the linter completed without errors.
  • Ran npm run build and the production build completed successfully.

Codex Task

@enlorik
enlorik marked this pull request as ready for review June 22, 2026 14:25
@enlorik
enlorik merged commit 9e738c7 into main Jun 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant