docs: fix line breaks when copying commands from website#483
docs: fix line breaks when copying commands from website#483Git-HimanshuRathi wants to merge 1 commit intourunc-dev:mainfrom
Conversation
The MkDocs Material theme's CSS rule for .md-code__content applies display: block to all child span elements, including token-level spans (keywords, whitespace, variables) and hidden anchor tags. This causes browsers to insert line breaks between these elements when users copy code snippets from the documentation. Add CSS overrides scoped to .md-code__content to force token-level spans and anchor tags inside line spans to display: inline, fixing the copy behavior. Fixes: urunc-dev#482 Signed-off-by: Git-HimanshuRathi <himanshurathiwork@gmail.com>
✅ Deploy Preview for urunc ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@cmainas can u allow workflow to run ? |
| } | ||
|
|
||
| /* ======================= | ||
| Fix line breaks when copying commands from docs |
There was a problem hiding this comment.
I tested the fix manually, but it does not seem to work for me.
I was able to reproduce the issue only on Firefox (v147.0.3) running on Linux. Chrome and Firefox on macOS worked fine even without the fix. @cmainas, could you confirm the environment where this issue occurred?
From what I understand, the problem might be related to how <a id="__codelineno-*"> is rendered inside the span elements. However, I’m not sure why this happens only on Firefox, so it would be good to investigate this further.
There was a problem hiding this comment.
I have also encountered the issue only on Linux with Firefox (v147.0.3) and not in Chromium.
There was a problem hiding this comment.
The suggested fix does not work in my environment either.
The MkDocs Material theme's CSS rule for .md-code__content applies display: block to all child span elements, including token-level spans (keywords, whitespace, variables) and hidden anchor tags. This causes browsers to insert line breaks between these elements when users copy code snippets from the documentation.
Add CSS overrides scoped to .md-code__content to force token-level spans and anchor tags inside line spans to display: inline, fixing the copy behavior.
Fixes: #482
Description
This change fixes an issue where copying commands from the documentation resulted in unwanted line breaks (e.g.,
wget\n -qinstead ofwget -q).The root cause was a broad CSS rule in the MkDocs Material theme that sets
display: blockon all spans inside.md-code__content. This PR adds scopedCSS overrides so that only line-level spans remain block elements, while
token-level spans and anchor tags render inline. This preserves syntax
highlighting and layout while ensuring correct copy behavior.
How was this tested?
Tested locally by running the MkDocs development server and navigating to the
installation guide. Verified that copying commands using both manual text
selection and the copy button preserves correct formatting without unwanted
line breaks.
Before fix (copied text):
After fix (copied text):
LLM usage
N/A
Checklist
make lint).make test_ctr,make test_nerdctl,make test_docker,make test_crictl).