Skip to content

Commit f464fe6

Browse files
docs: fix line breaks when copying commands from website
The MkDocs Material theme's anchor_linenums feature injects <a id="__codelineno-*"> elements inside code line spans. Firefox on Linux treats these as DOM selection boundaries, inserting line breaks when users copy code from the documentation. Fix by using display:contents on the anchor elements to remove them from the rendering tree and user-select:none to exclude them from copy selection. Also force display:inline on token-level spans. Fixes: #482 Signed-off-by: Git-HimanshuRathi <himanshurathiwork@gmail.com>
1 parent 1946259 commit f464fe6

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

docs/assets/stylesheets/theme.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@
129129
pointer-events: none;
130130
}
131131

132+
/* =======================
133+
Code Block Copy Fix
134+
======================= */
135+
.md-code__content a[id^="__codelineno"] {
136+
display: contents !important;
137+
user-select: none !important;
138+
-moz-user-select: none !important;
139+
pointer-events: none !important;
140+
}
141+
142+
.md-code__content > span > span {
143+
display: inline !important;
144+
}
145+
132146
/* =======================
133147
General Typography (Optional)
134148
======================= */

0 commit comments

Comments
 (0)