Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for math blocks using $$ #5381

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

OEvgeny
Copy link
Collaborator

@OEvgeny OEvgeny commented Nov 15, 2024

Changelog Entry

Added

  • Added support for math blocks using $$ delimiter alongside existing \[...\] and \(...\) notations, in PR #5381, by @OEvgeny

Description

This PR extends math block support by adding the $$ delimiter syntax. The implementation maintains consistency with existing math block handlers while introducing a new syntax option.

Design

The tokenizer implementation uses a state machine approach:

  • Tracks consecutive $ characters via counter to distinguish between potential math delimiters
  • Only commits to math mode after exactly two $ characters ($$) are detected
  • Uses unified state handling for all delimiters ($$, \[...\], \(...\)) with single expected close delimiter variable
  • Rejects mismatched delimiters (e.g., $$$) to prevent incorrect parsing

Specific Changes

  • Updated math tokenizer to handle $$ delimiters for display math mode
  • Modified HTML renderer to process new delimiter syntax
  • Added test coverage for mixed math blocks usage with various mathematical expressions
  • Reorganized code structure for better maintainability:
    • Split math extension into separate files
    • Renamed htmlRenderer.ts to mathHtml.ts for clarity
  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@OEvgeny OEvgeny marked this pull request as ready for review November 15, 2024 02:41
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