Fix ignore-class substring matching, preserve style on ignored formulas, bundle MathJax in release tarball - #77
Merged
Merged
Conversation
$wgSmjIgnoreHtmlClass was matched against the raw class attribute with preg_match(), so it matched anywhere in the string. With the default pattern (which includes "comment"), an unrelated class such as "commentary" or "diff-contextual" was incorrectly treated as ignored and its formula shown as untypeset literal text. Anchor the pattern to whole space-delimited class tokens, matching the boundary MathJax's own ignoreHtmlClass option applies internally. Also, an ignored formula unconditionally discarded its whole "style" attribute, including any style an editor supplied through an allow-listed "style" (via $wgSmjAllowedAttributes), not just the placeholder opacity SimpleMathJax defaults to before typesetting. Only strip the default placeholder now, so an editor-supplied style survives on an ignored formula. Add demo cases and a regression test for both fixes, and correct configuration.md: GitHub's automatically generated release source archives don't include submodule contents, so local-mode users working from one of those archives need to initialize the resources/MathJax submodule themselves. Co-Authored-By: Claude Sonnet 5 <[email protected]>
GitHub's auto-generated release source archives don't include submodule content, so resources/MathJax comes out empty in them and local rendering ($wgSmjCdnEnabled = false) fails for anyone who downloads one instead of cloning with git. The release workflow now checks out the MathJax submodule and attaches a second archive, SimpleMathJax-<version>-with-mathjax.tar.gz, with the submodule's contents merged in, so a plain download works too. Point configuration.md at this asset as the no-git option, alongside the existing git-clone instructions. Bump the version to 1.0.1 to ship this release-workflow change and the ignore-class fixes together. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Sep 6, 2026
Closed
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.
Summary
$wgSmjIgnoreHtmlClasswas matched with a plainpreg_match()against the wholeclassattribute, so the pattern matched as a substring anywhere in it. With the default pattern (which includescomment), unrelated classes likecommentaryordiff-contextualwere incorrectly treated as ignored. The match is now anchored to whole space-delimited class tokens ((?:^| )(?:pattern)(?: |$)), mirroring the boundary MathJax's ownignoreHtmlClassoption applies internally.styleattribute, including any style an editor supplied through an allow-listedstyle(via$wgSmjAllowedAttributes), not just the placeholder opacity SimpleMathJax defaults to before typesetting. Now only the default placeholder is stripped, so an editor-supplied style survives on an ignored formula.resources/MathJaxcomes out empty in them and local rendering ($wgSmjCdnEnabled = false) fails for anyone who downloads one instead of cloning with git. The release workflow now also attachesSimpleMathJax-<version>-with-mathjax.tar.gz, a second archive with the MathJax submodule's contents merged in, so a plain download works too.Testing
tests/IgnoreHtmlClassTest.phpcovering exact match, multi-class match, and the substring/prefix/suffix false-positive cases; wired intomake test.php tests/QuotesTest.php,php tests/RevisionOverridesTest.php,php tests/IgnoreHtmlClassTest.php, andcomposer test(parallel-lint, minus-x, phpcs) all pass.hack/demo/demos.yaml(commentvscommentary,mathjax_ignore+stylecombo) and regenerated thecustom01screenshots; confirmed visually thatcommentarynow renders and the red style survives on the ignoredmathjax_ignoreformula.SimpleMathJax-1.0.0-with-mathjax.tar.gz(6.2M) contains all 129 MathJax submodule files includingtex-chtml.js.🤖 Generated with Claude Code