HTML5 custom element that extends <pre>
element with syntax highlighting using ShikiJS
Screen.Recording.2021-12-08.at.13.41.16.mov
- Load Shiki into DOM
<script src="https://unpkg.com/shiki@latest/dist/index.unpkg.iife.js"></script>
- Load the custom element
<script src="https://unpkg.com/pre-highlighted@latest"></script>
Using npm
npm i pre-highlighted
<pre-highlighted lang="css" theme="github-dark">
.red {
background: red;
}
</pre-highlighted>
Or alternatively:
<pre is="pre-highlighted" lang="css" theme="github-dark">
.red {
background: red;
}
</pre>
lang
, programming languagetheme
, theme, consult Shiki docs for more