diff --git a/plugins/command-line/prism-command-line.js b/plugins/command-line/prism-command-line.js index 69bc2a8daa..0d1392ff8e 100644 --- a/plugins/command-line/prism-command-line.js +++ b/plugins/command-line/prism-command-line.js @@ -23,9 +23,10 @@ Prism.hooks.add('before-highlight', function (env) { return; } - if (env.element.querySelector('.command-line-prompt')) { // Abort if prompt already exists. - commandLine.complete = true; - return; + // The element might be highlighted multiple times, so we just remove the previous prompt + var existingPrompt = env.element.querySelector('.command-line-prompt'); + if (existingPrompt) { + existingPrompt.remove(); } var codeLines = env.code.split('\n'); diff --git a/plugins/command-line/prism-command-line.min.js b/plugins/command-line/prism-command-line.min.js index 2aa2544f59..b0f6cd1557 100644 --- a/plugins/command-line/prism-command-line.min.js +++ b/plugins/command-line/prism-command-line.min.js @@ -1 +1 @@ -!function(){if("undefined"!=typeof self&&self.Prism&&self.document){var u=/(?:^|\s)command-line(?:\s|$)/;Prism.hooks.add("before-highlight",function(e){var t=e.vars=e.vars||{},a=t["command-line"]=t["command-line"]||{};if(!a.complete&&e.code){var n=e.element.parentNode;if(n&&/pre/i.test(n.nodeName)&&(u.test(n.className)||u.test(e.element.className)))if(e.element.querySelector(".command-line-prompt"))a.complete=!0;else{var r=e.code.split("\n");a.numberOfLines=r.length;var s=a.outputLines=[],o=n.getAttribute("data-output"),i=n.getAttribute("data-filter-output");if(o||""===o){o=o.split(",");for(var l=0;lr.length&&(d=r.length),d--;for(var c=--p;c<=d;c++)s[c]=r[c],r[c]=""}}}else if(i)for(l=0;l');else{var i=r("data-user","user"),l=r("data-host","localhost");s=s.join('')}var m=document.createElement("span");m.className="command-line-prompt",m.innerHTML=s;for(var p=0,d=(a.outputLines||[]).length;ps.length&&(c=s.length),c--;for(var u=--p;u<=c;u++)o[u]=s[u],s[u]=""}}}else if(l)for(m=0;m');else{var i=r("data-user","user"),l=r("data-host","localhost");s=s.join('')}var m=document.createElement("span");m.className="command-line-prompt",m.innerHTML=s;for(var d=0,p=(a.outputLines||[]).length;d