Skip to content

Fix Firefox code copying (2)#2126

Merged
philipp-spiess merged 4 commits intotailwindlabs:mainfrom
wongjn:fix-firefox-code-copy-2
Mar 5, 2025
Merged

Fix Firefox code copying (2)#2126
philipp-spiess merged 4 commits intotailwindlabs:mainfrom
wongjn:fix-firefox-code-copy-2

Conversation

@wongjn
Copy link
Copy Markdown
Contributor

@wongjn wongjn commented Mar 4, 2025

Alternative to #2120 that is simpler and (hopefully) without regressions!

Replaces <span> elements for lines with <div> elements, since these seem to copy properly as newlines in Firefox. Though please note the HTML spec technically disallows this 😥.

Fixes #1972
Closes #2120

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tailwindcss-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2025 10:52am

@philipp-spiess
Copy link
Copy Markdown
Contributor

@wongjn seems like [!code] blocks are no longer processed (or maybe processed in the wrong order?) now: https://tailwindcss-com-git-fork-wongjn-fix-firefox-f600d6-tailwindlabs.vercel.app/docs/hover-focus-and-other-states#differentiating-nested-groups

@philipp-spiess
Copy link
Copy Markdown
Contributor

Okay that was just the custom [!code classes:…] code that needed fixing. I tested this in Firefox/Chrome/Safari now and it seems fine. Happy to give this a spin. Thanks for your awesome help!

@philipp-spiess philipp-spiess merged commit 5a77fe6 into tailwindlabs:main Mar 5, 2025
2 checks passed
@wongjn wongjn deleted the fix-firefox-code-copy-2 branch March 5, 2025 11:19
thecrypticace added a commit that referenced this pull request May 14, 2025
This basically reverts the FF fix from #2126 which fixed FF but broke
word highlights. Also divs aren't allowed in `<code>` elements so
Shiki's assumption that it really only needs to look inside `<span>`s
isn't a terrible one in this case.

We'll have to come up with some other solution to work around the FF bug
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.

Docs installation step wrong code format on copy

2 participants