1
0
hugo/static/js/highlight-prompt.js
2024-04-23 22:21:26 +09:00

14 lines
557 B
JavaScript

function highlight_prompt() {
var list = document.body.getElementsByClassName("language-sh hljs bash");
if ( list.length >= 1 ) {
for(i=0; i <= list.length-1; i++){
var nodes = list[i].innerHTML;
if (nodes.match(/\$ /)){
t = nodes.replace(/^\$ /mg,"<span class='prompt'>$ </span>");
document.getElementsByClassName("language-sh hljs bash")[i].innerHTML = '';
document.getElementsByClassName("language-sh hljs bash")[i].insertAdjacentHTML('afterbegin', t);
};
};
};
}