In this episode, we're giving our Markdown content some much-needed syntax highlighting upgrades. We kick things off by talking about why and how you might want to use a different Markdown renderer for your app, especially one that offers better syntax highlighting for code blocks.
We start by reviewing the existing content parser, which uses the CommonMark renderer. But instead of hacking away at the package files, we create our own parser so we have more flexibility. It's just a quick copy-and-tweak job — strip out what we don't need, adjust the namespace, and prep it for our new, shiny rendering engine.
Next, we install the Laravel Markdown package, which lets us plug into Sheeky (a front-end library for code highlighting). We go through installing both packages, publishing config files, and setting up the theme — with plenty of pointers on where to flip the switches for different highlighting styles. Don’t forget to clear your cache after making changes so they actually show up!
Finally, we wire up our new parser, render some Markdown, and check out the results. Code blocks look gorgeous with the new theme, and all the colors are customizable. There’s a quick demo of how the caching works and why it’s important for performance. By the end, you’ll know exactly how to swap out your Markdown rendering and get beautiful syntax highlighting in your Laravel app.