![]() ![]() This very blog you are reading uses Shiki to highlight code snippets. In the browser, this will be displayed as: ![]() use Spatie\ShikiPhp\Shiki Shiki :: highlight ( code : '', language : 'php', theme : 'github-light', ) Using Shiki is simple, you pass it some code, the language of the code you are passing and one of the many available themes. Here's a good first example where we are going to highlight a simple PHP script. The first package we released, spatie/shiki-php, allows you to highlight any given code snippet. My colleague Rias used that blog post as inspiration to toy with Shiki and bringing its magic to the PHP world. Miguel's blog post mentioned how you could use Shiki in a JS / Node environment. Its highlighting is near perfect, and it can even handle modern PHP Syntax. Shiki is the code renderer behind VSCode. While the highlighting provides by highlight.php/js is pretty good, it's not perfect.Ī couple of months ago, Miguel Piedrafita blogged about highlighting using Shiki. Highlight.php is inspired by hightlight.js. This renderer uses highlight.php to render code blocks in Markdown. This package offers a renderer class that can be used with the league's popular commonmark package. On this very blog, spatie.be and related sites, we have relied on our trusty commonmark-highlighter package for the past couple of years. We're already using this package to render all our documentation pages, our guidelines, and this very blog you are reading.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |