🐛 Fix copy button copying HTML tags from termynal command lines#15941
Open
shreyash0k wants to merge 1 commit into
Open
🐛 Fix copy button copying HTML tags from termynal command lines#15941shreyash0k wants to merge 1 commit into
shreyash0k wants to merge 1 commit into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
📝 Docs previewLast commit 707f2f1 at: https://bb3e5baf.fastapitiangolo.pages.dev Modified Pages |
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.
I reported this bug in this discussion: #15700
Issue: on several docs pages, the copy button on termynal terminal blocks copies HTML styling tags into the clipboard instead of the plain shell command. For example, on https://fastapi.tiangolo.com/fastapi-cli/ copying the first terminal block gives
<font color="#4E9A06">fastapi</font> devinstead offastapi dev.Fix: the command lines in the markdown can contain HTML styling tags (e.g.
<font color="...">).custom.jsbuilds a hiddencodeelement with the raw input lines for the copy button to read, so the tags end up in the clipboard. This change extracts only the plain text when building that element, the same way Termynal itself does when typing the command lines. This keeps the formatting in the markdown source (so it can still be rendered in the future) and fixes all translated docs at once.Testing: tested locally with the docs live server on all the affected pages (
/fastapi-cli/,/tutorial/,/tutorial/first-steps/,/deployment/manually/,/deployment/server-workers/), including commands that also contain<u>tags. The copy button now copies clean commands and the terminal animation renders as before.Made with Cursor