CodeHighlighterCodeHighlighter is an attribute directive to highlight code blocks using PrismJS
Documentation
PrismJS
npm install prismjs --save
Include the javascript and a theme css from Prism. Example for angular.json configuration of a CLI project would be as follows. Refer to the PrismJS documentation for the list of available languages.
"styles": [
"./node_modules/prism/themes/prism.css",
//...
],
"scripts": [
"node_modules/prismjs/prism.js",
//...
]
Import
import {CodeHighlighterModule} from 'primeng/codehighlighter';
Getting Started
CodeHighlighter is applied to a code element with [pCode] directive. The <code> should have a style class having language- prefix to specify the language to highlight. See Prismjs docs for the list of available languages. An example block with css code would be as follows.
<pre>
<code class="language-css" pCode>
.ui-datatable table {
border-collapse:collapse;
width: 100%;
table-layout: fixed;
}
</code>
</pre>
Dependencies
Prismjs