A quick test of Prism.js

Sorry for the noise folks. This is really just a test post. But if you've never tried Prism before for code highlighting, I definitely recommend it. I'm using it over on JavaScript Cookbook and I've decided to start using it here as well.

I've went through a couple of different code highlighters over the past ten years. Most recently I've made use of Gists. I really liked the idea of offloading the code to another server, but when gists.github.com went down, it ended up completely breaking my blog posts. I certainly don't blame them (and they go down much less often than my own blog does), but I thought it might be nice to try something internal, simpler, and less prone to error.

Prism.js is the framework I'm going to use. Here is a real example.

<html>

<head>
<title>Foo</title>
</head>

<body>

<p>
Stuff
</p>

</body>
</html>

The only thing I need now is a quick way to escape HTML. Posting JavaScript won't be an issue but I need to escape my HTML examples. For what you saw above I used this app (Online HTML Escape Tool) but I am going to want something more direct. I'll probably use a bookmarklet or add something to my blog form.

Another example without line numbers.

<html>

<head>
<title>Foo</title>
</head>

<body>

<p>
Stuff
</p>

</body>
</html>
Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate looking for his next gig. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments