Fix missing extracted classes in mdx files#19711
Merged
RobinMalfait merged 2 commits intomainfrom Feb 22, 2026
Merged
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 WalkthroughThe markdown preprocessor was updated to track nested bracketed punctuation inside directives using a bracket_stack (for (, [, {, < and their closers). Dot-to-space replacement now occurs only when that stack is empty, preventing replacements inside nested bracketed content. The code pushes on opening punctuation and pops on matching closers while in a directive. Two tests were added to verify that class names and bracketed tokens containing dots (e.g., 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
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.
In Tailwind CSS v4.1.14 we released a fix for a bug where we didn't extract classes used in markdown directives (#18071). E.g.:
The fix was simple, we pre-process classes once we we are inside
{…}. The pre-processing just replaces.withso thetext-gray-500from above would be extracted properly.This fix introduced a bug for mdx files if you use syntax like this:
This is the exact kind of syntax we use in our documentation as well. Because of this fix, we didn't properly extract the
p-2.5class.This new PR fixes that by ensuring that classes that are not top-level will stay as-is instead of being pre-processed.
This fix assumes that when you have
<,{,[or(somewhere after the initial{character then we start nesting. The moment we see>,},]or)we end the current nesting level.If we are not nesting anymore, only then do we pre-process the class again.
This fix is also a simple implementation (on purpose), there could be even more edge cases that we might run into (order of bracket types, non-matching brackets, strings, escaped values, skipping code blocks, etc.) but I only want to tackle those when we actually run into these issues.
It looks like nobody ran into this (I didn't see a bug report about it). So I don't think it's worth the effort to make it even more robust (and potentially more complex which could result in more bugs).
Test plan
Before:

After:
