Last active
September 18, 2023 15:13
-
-
Save KonnorRogers/e135bd5701403bca7c3cec7be7d3e523 to your computer and use it in GitHub Desktop.
Adding "$" before code blocks that isn't selectable by a user
This file contains 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
var code = document.querySelector(":is(.language-bash, .language-shell, .language-zsh, .language-sh, .language-console).highlighter-rouge pre.highlight > code") | |
code.innerHTML = code.innerHTML.split("\n").map((str) => { | |
return str.replace(/^(\w)/, "<span class='highlight-command-line-start'>$</span>$1") | |
}).join("\n") |
This file contains 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
.highlight-command-line-start { | |
user-select: none; | |
padding-inline-end: 0.45em; | |
color: gray; | |
} |
Author
KonnorRogers
commented
Sep 18, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment