Skip to content

Conversation

Khlick
Copy link

@Khlick Khlick commented Aug 8, 2025

Summary

Adds a new MathJax4 plugin that supports MathJax 4.0.0 with proper async startup handling.

Changes

  • New plugin: plugin/math/mathjax4.js with MathJax 4.0.0 support
  • Updated plugin wrapper: Added MathJax4 to plugin/math/plugin.js exports
  • Example updated: examples/math.html now demonstrates MathJax4 configuration
  • Tests added: Comprehensive test suite in test/test-mathjax4.html (all passing)
  • Built files: Updated math.js and math.esm.js with new plugin
  • Version bump: Package version updated to 5.2.2

Key Features

  • MathJax 4.0.0 Support: Uses latest MathJax CDN with async startup
  • Macros Support: Compatible macro configuration similar to MathJax3
  • Async Startup: Proper handling of MathJax 4's async initialization
  • Slide Change Support: Re-typesets math when slides become visible
  • Backward Compatible: Same API as other math plugins

Configuration Example

mathjax4: {
    tex: {
        inlineMath: [['$', '$'], ['\\(', '\\)']],
        displayMath: [['$$', '$$'], ['\\[', '\\]']],
        macros: {
            R: '\\mathbb{R}',
            set: ['\\left\\{#1 \\; ; \\; #2\\right\\}', 2]
        }
    },
    options: {
        skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    },
    output: {
        font: 'mathjax-stix2',
        displayOverflow: 'linebreak',
        linebreaks: {
            inline: true,
            width: '100%',
            lineleading: .2
        }
    }
}

Testing

  • QUnit Tests: All 5 tests passing in test/test-mathjax4.html
    • Plugin availability and structure ✅
    • Plugin initialization ✅
    • MathJax 4.0.0 loading and math processing ✅
    • Custom macros functionality ✅
  • Manual Verification: Tested examples/math.html with HTTP server
  • Math Rendering: Verified inline and display math render correctly
  • Macros: Confirmed custom macros (R, set) work as expected
  • Async Startup: Confirmed proper handling of MathJax 4's async initialization
  • Slide Changes: Verified math re-renders when navigating slides

Browser Compatibility

Tested on modern browsers that support MathJax 4.0.0.

Khlick added 4 commits August 7, 2025 19:59
- Add plugin/math/mathjax4.js with MathJax 4.0.0 support
- Update plugin/math/plugin.js to include MathJax4 export
- Add MathJax4 configuration example in examples/math.html
- Add comprehensive tests in test/test-mathjax4.html
- Rebuild math.js and math.esm.js with new plugin
- Bump version to 5.2.2
- Support for MathJax 4.0.0 async startup procedure
- Compatible macros configuration similar to MathJax3
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