Skip to content

Fix ignore-class substring matching, preserve style on ignored formulas, bundle MathJax in release tarball - #77

Merged
jmnote merged 2 commits into
mainfrom
fix-ignore-class-handling
Sep 6, 2026
Merged

Fix ignore-class substring matching, preserve style on ignored formulas, bundle MathJax in release tarball#77
jmnote merged 2 commits into
mainfrom
fix-ignore-class-handling

Conversation

@jmnote

@jmnote jmnote commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • $wgSmjIgnoreHtmlClass was matched with a plain preg_match() against the whole class attribute, so the pattern matched as a substring anywhere in it. With the default pattern (which includes comment), unrelated classes like commentary or diff-contextual were incorrectly treated as ignored. The match is now anchored to whole space-delimited class tokens ((?:^| )(?:pattern)(?: |$)), mirroring the boundary MathJax's own ignoreHtmlClass option applies internally.
  • An ignored formula unconditionally discarded its entire 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. Now only the default placeholder is stripped, so an editor-supplied style survives on an ignored formula.
  • 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 also attaches SimpleMathJax-<version>-with-mathjax.tar.gz, a second archive with the MathJax submodule's contents merged in, so a plain download works too.
  • Bumped the version to 1.0.1 to ship these fixes.

Testing

  • Added tests/IgnoreHtmlClassTest.php covering exact match, multi-class match, and the substring/prefix/suffix false-positive cases; wired into make test.
  • php tests/QuotesTest.php, php tests/RevisionOverridesTest.php, php tests/IgnoreHtmlClassTest.php, and composer test (parallel-lint, minus-x, phpcs) all pass.
  • Added demo cases to hack/demo/demos.yaml (comment vs commentary, mathjax_ignore + style combo) and regenerated the custom01 screenshots; confirmed visually that commentary now renders and the red style survives on the ignored mathjax_ignore formula.
  • Locally reproduced the release workflow's tarball step against this repo: the resulting SimpleMathJax-1.0.0-with-mathjax.tar.gz (6.2M) contains all 129 MathJax submodule files including tex-chtml.js.

🤖 Generated with Claude Code

jmnote and others added 2 commits September 7, 2026 03:57
$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]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@jmnote
jmnote merged commit 05a44b5 into main Sep 6, 2026
2 checks passed
@jmnote
jmnote deleted the fix-ignore-class-handling branch September 6, 2026 19:06
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