Prism plugins

Download

Prism is a lightweight, extensible syntax highlighter, built with modern web standards in mind. It’s used in millions of websites, including some of those you visit daily.

Theme:

Unescaped Markup

Write markup without having to escape anything.

How to use

This plugin provides several methods of achieving the same thing:

<script type="text/plain" class="language-markup">
<p>Example</p>
</script>
<pre class="language-markup"><code><!--
<p>Example</p>
--></code></pre>

This will only work if the code element contains exactly one comment and nothing else (not even spaces). E.g. <code> <!-- some text --></code> and <code>text<!-- more text --></code> will not work.

Examples

View source to see that the following didn’t need escaping (except for </script>, that does):

The next example uses the HTML-comment method:

FAQ

Why not use the HTML <template> tag?

Because it is a PITA to get its textContent and needs to be pointlessly cloned. Feel free to implement it yourself and send a pull request though, if you are so inclined.

Can I use this inline?

Not out of the box, because I figured it’s more of a hassle to type <script type="text/plain"> than escape the 1-2 < characters you need to escape in inline code. Also inline code is not as frequently copy-pasted, which was the major source of annoyance that got me to write this plugin.