Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
KonnorRogers committed Mar 25, 2024
1 parent ca4cf20 commit 171ab7f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions docs/frontend/javascript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,17 @@ Object.entries(controllers).forEach(([filename, controller]) => {

function enhanceCodeBlocks () {
document.querySelectorAll(":is(.language-bash, .language-shell, .language-zsh, .language-sh, .language-console).highlighter-rouge pre.highlight > code").forEach((el) => {
el.innerHTML = el.innerHTML.split("\n").map((str) => {
return str.replace(/^(\w)/, "<span class='highlight-command-line-start'>$</span>$1")
}).join("\n")
if (el.dataset.enhanced === "true") {
return
}

el.dataset.enhanced = "true"

el.innerHTML = el.innerHTML.split(/\n/).map((str, index, ary) => {
if (!str && ary.length - 1 === index) return ""
// return str.replace(/^([])/, "<span class='highlight-command-line-start'>$</span>$1")
return "<span class='highlight-command-line-start'>$</span>" + str
}).join("\n").trimEnd()
})
}

Expand Down

0 comments on commit 171ab7f

Please sign in to comment.