📝 Fix copy button copying HTML markup on Termynal command lines#15812
Open
patrickwehbe wants to merge 1 commit into
Open
📝 Fix copy button copying HTML markup on Termynal command lines#15812patrickwehbe wants to merge 1 commit into
patrickwehbe wants to merge 1 commit into
Conversation
Several docs have terminal input lines written with HTML coloring, like `$ <font color="#4E9A06">fastapi</font> dev`. Termynal animates the input using textContent, so the <font> tags never render on screen, but the Material copy button reads the underlying code and copies the literal markup. Users end up pasting `<font color="#4E9A06">fastapi</font> dev` instead of the command. Strip the HTML wrappers from only the `$` input command lines so the copy button yields the plain command, matching the homepage block which already uses the plain form. The colored output lines below each command are left unchanged. See discussion fastapi#15700.
Contributor
mohamedtaqysalmi
left a comment
There was a problem hiding this comment.
Stripping Termynal HTML markup from the copy payload fixes a real UX bug where users paste styled spans instead of plain commands. Scoped to deployment/tutorial Termynal blocks — good that tests or manual verification covered multiple pages using the same pattern.
Member
|
@mohamedtaqysalmi : I feel like you're using AI to produce these reviews, is that correct? |
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.
What this fixes
Several pages in the docs write the terminal input lines inside
termy/consoleblocks with HTML coloring, for example:Termynal animates the input line using
textContent, so the<font>tags never render on screen. However, MkDocs Material's copy button reads the underlying code, not the rendered text, so clicking it copies the literal markup:Users then paste the markup instead of the command.
The fix
Strip the HTML wrappers from only the
$input command lines so the copy button yields the plain command. The colored output lines below each command are intentional styling and are left untouched.The homepage block already uses the plain
$ fastapi devform and copies correctly, so this just brings these pages in line with it.Lines changed (input commands only):
docs/en/docs/fastapi-cli.mddocs/en/docs/tutorial/first-steps.mddocs/en/docs/tutorial/index.mddocs/en/docs/deployment/manually.mddocs/en/docs/deployment/server-workers.mdSee discussion #15700.