diff --git a/plugins/command-line/prism-command-line.css b/plugins/command-line/prism-command-line.css index 60ab996d62..153a87076a 100644 --- a/plugins/command-line/prism-command-line.css +++ b/plugins/command-line/prism-command-line.css @@ -15,11 +15,15 @@ .command-line-prompt > span:before { color: #999; - content: "[" attr(data-user) "@" attr(data-host) "] $"; + content: ' '; display: block; padding-right: 0.8em; } +.command-line-prompt > span[data-user]:before { + content: "[" attr(data-user) "@" attr(data-host) "] $"; +} + .command-line-prompt > span[data-user="root"]:before { content: "[" attr(data-user) "@" attr(data-host) "] #"; } @@ -27,7 +31,3 @@ .command-line-prompt > span[data-prompt]:before { content: attr(data-prompt); } - -.command-line-prompt > span.output:before { - content: ' '; -} diff --git a/plugins/command-line/prism-command-line.js b/plugins/command-line/prism-command-line.js index cadc7069ed..979906111b 100644 --- a/plugins/command-line/prism-command-line.js +++ b/plugins/command-line/prism-command-line.js @@ -63,7 +63,10 @@ Prism.hooks.add('complete', function (env) { if (!isNaN(outputStart) && !isNaN(outputEnd)) { for (var j = outputStart; j <= outputEnd && j <= prompt.children.length; j++) { - prompt.children[j - 1].className = 'output'; + var node = prompt.children[j - 1]; + node.removeAttribute('data-user'); + node.removeAttribute('data-host'); + node.removeAttribute('data-prompt'); } } } diff --git a/plugins/command-line/prism-command-line.min.js b/plugins/command-line/prism-command-line.min.js index b7ec8c6221..23c6bea8e0 100644 --- a/plugins/command-line/prism-command-line.min.js +++ b/plugins/command-line/prism-command-line.min.js @@ -1 +1 @@ -!function(){"undefined"!=typeof self&&self.Prism&&self.document&&Prism.hooks.add("complete",function(e){if(e.code){var t=e.element.parentNode,a=/\s*\bcommand-line\b\s*/;if(t&&/pre/i.test(t.nodeName)&&(a.test(t.className)||a.test(e.element.className))&&!e.element.querySelector(".command-line-prompt")){a.test(e.element.className)&&(e.element.className=e.element.className.replace(a,"")),a.test(t.className)||(t.className+=" command-line");var n=new Array(1+e.code.split("\n").length),s=t.getAttribute("data-prompt")||"";if(""!==s)n=n.join('');else{var l=t.getAttribute("data-user")||"user",r=t.getAttribute("data-host")||"localhost";n=n.join('')}var m=document.createElement("span");m.className="command-line-prompt",m.innerHTML=n;var o=t.getAttribute("data-output")||"";o=o.split(",");for(var i=0;i=u&&u<=m.children.length;u++)m.children[u-1].className="output"}e.element.innerHTML=m.outerHTML+e.element.innerHTML}}})}(); \ No newline at end of file +!function(){"undefined"!=typeof self&&self.Prism&&self.document&&Prism.hooks.add("complete",function(e){if(e.code){var t=e.element.parentNode,a=/\s*\bcommand-line\b\s*/;if(t&&/pre/i.test(t.nodeName)&&(a.test(t.className)||a.test(e.element.className))&&!e.element.querySelector(".command-line-prompt")){a.test(e.element.className)&&(e.element.className=e.element.className.replace(a,"")),a.test(t.className)||(t.className+=" command-line");var n=new Array(1+e.code.split("\n").length),s=t.getAttribute("data-prompt")||"";if(""!==s)n=n.join('');else{var r=t.getAttribute("data-user")||"user",l=t.getAttribute("data-host")||"localhost";n=n.join('')}var m=document.createElement("span");m.className="command-line-prompt",m.innerHTML=n;var o=t.getAttribute("data-output")||"";o=o.split(",");for(var i=0;i=u&&u<=m.children.length;u++){var N=m.children[u-1];N.removeAttribute("data-user"),N.removeAttribute("data-host"),N.removeAttribute("data-prompt")}}e.element.innerHTML=m.outerHTML+e.element.innerHTML}}})}(); \ No newline at end of file