tag:support.markedapp.com,2011-09-11:/discussions/questions/9105-custom-code-fence-syntax-highlightMarked: Discussion 2018-04-24T18:36:46Ztag:support.markedapp.com,2011-09-11:Comment/451625472018-04-24T14:18:55Z2018-04-24T14:18:55ZCustom Code Fence Syntax Highlight<div><p>I'm afraid there's not really a great way to customize the syntax<br>
highlighting code that Marked uses automatically.</p>
<p>You do have the option of disabling syntax highlighting and then using<br>
your own, either manually including a <br>
with a custom processor that injects it automatically when rendering the<br>
page.
<p>Hope that provides some options, though I know it's a hassle.
<p>-Brett
</p></div>Bretttag:support.markedapp.com,2011-09-11:Comment/451625472018-04-24T18:20:14Z2018-04-24T18:20:15ZCustom Code Fence Syntax Highlight<div><p>No worries, thanks for the quick reply. If others stumble across this post, I was able to solve this using custom JavaScript. The regex below will have to be adjusted for different prompt usage (e.g. <code>hostname $</code>, etc.)</p>
<p>Thanks Brett!</p>
<p>-Josh</p>
<pre>
<code class="js">const codeTags = document.querySelectorAll('code.text');
codeTags.forEach(updateTag);
function updateTag(tag) {
let text = tag.innerText;
text = text.replace(/^(# )(.*)$/gm, '$1<strong>$2</strong>');
text = text.replace(/^($ )(.*)$/gm, '$1<strong>$2</strong>');
tag.innerHTML = text;
}
<pre><code></code>
</pre></code>
</pre></div>Joshua Wrighttag:support.markedapp.com,2011-09-11:Comment/451625472018-04-24T18:36:45Z2018-04-24T18:36:45ZCustom Code Fence Syntax Highlight<div><p>I salute your resourcefulness!</p>
<p>-Brett</p></div>Brett