Random Page

Adding Markdown and Syntax Highlight to My Blog by Jason Ramsey on Sunday, August 4th 2019

There are hundreds of different places and frameworks to create and manage blog posts. I am still dealing with my own system because I like to re-write the wheel - however, I do want to take advantage of some great things people have created like Markdown and Syntax highlighting.

Insert Markdown and PrismJS

I still need to learn how to fully take advantage of these items, but I've code the base examples working. I started with grabbing Parsedown. This allows me to use Markdown directly in my php code.

Source: Parsedown

$Parsedown = new Parsedown();
echo $Parsedown->text('Jaseowns now has _Parsedown_!');

After I got that working, I was sad that the javascript was not highlighting automagically. The quickest fix was to just fine a JS library that worked well with Parsedown out of the box. Insert PrismJS!

Source: PrismJS

<head>
 <link rel="stylesheet" href="/css/prism.min.css">
 <script src="/js/prism.js"></script>
</head>

If this in-fact worked correctly, the above items should be highlighted and the source links look like...

Source: [PrismJS](https://prismjs.com/)

Bringing Jaseowns.com into the new age!

Back to List Next Entry