A web component using Prism.
Without any attributes, the language will default to clike
and theme to prism
.
<code-block></code-block>
<script>
document.querySelector('code-block').code = `function print(msg) {
console.log(msg);
}
print('Hello, World!');`;
</script>
You can specify the language and theme with the language
and theme
attributes, respectively.
<code-block language="java" theme="prism-tomorrow"></code-block>
If you want to remove the theme's background graphics, use the plain
attribute.
<code-block plain></code-block>
This code is under the BSD 3-Clause.
If you like my work and want to support it, please consider sponsoring me. It's how I make the time to code great things!