Skip to content

feat: support equals sign and surrounding whitespace in \htmlData attribute values#4112

Merged
edemaine merged 6 commits intoKaTeX:mainfrom
AljoschaMeyer:dataAttributesWithEqualsSigns
Dec 7, 2025
Merged

feat: support equals sign and surrounding whitespace in \htmlData attribute values#4112
edemaine merged 6 commits intoKaTeX:mainfrom
AljoschaMeyer:dataAttributesWithEqualsSigns

Conversation

@AljoschaMeyer
Copy link
Contributor

What is the previous behavior before this PR?

\htmlData{foo=<value>}{} results in a parse error if <value> contains equals signs.

What is the new behavior after this PR?

All equals signs but the first (which marks where the attribute name ends and the value starts) are ignored. Values can contain equals signs now.

Closes #4108


@edemaine Continuing from #4109, with apologies for failing to git properly.

New changes compared to #4109:

  • Implemented splitting at the first "=" via indexOf.
  • Added explicit (but primitive) tests ensuring that empty keys and empty values are not rejected by the parser.
  • "Squashed" everything into a single commit.

As before, I am unable to get the dev setup working locally; I have run none of the tests.

Copy link
Member

@edemaine edemaine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I edited the code style a bit, and added some more tests.

I also changed the behavior for how the value gets treated, removing the trim that removed any whitespace. (Kept it for the key though.) I figure that, while we're enabling = in the value, we should do the same for leading and trailing whitespace. This may change some values out there, but I think this can be viewed as a bug fix. Let me know whether you agree; if so, I'll merge.

@AljoschaMeyer
Copy link
Contributor Author

Yes, I like keeping whitespace for the value, too 👍

Thank you for bearing with my technical restrictions that led to some subpar commits =)

@edemaine edemaine changed the title feat: support equals signs in \htmlData attributes feat: support equals sign and surrounding whitespace in \htmlData attribute values Dec 7, 2025
@edemaine edemaine merged commit c77aaec into KaTeX:main Dec 7, 2025
8 checks passed
KaTeX-bot added a commit that referenced this pull request Dec 7, 2025
## [0.16.27](v0.16.26...v0.16.27) (2025-12-07)

### Features

* support equals sign and surrounding whitespace in \htmlData attribute values ([#4112](#4112)) ([c77aaec](c77aaec))
@KaTeX-bot
Copy link
Member

🎉 This PR is included in version 0.16.27 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

Data attributes via \htmlData cannot contain equals signs

3 participants