Prism.js wrapper with built-in line numbers
DEMO: https://ngx-numbered-codeblock.netlify.com/
npm install @ctrl/ngx-numbered-codeblock
Latest version available for each version of Angular
@ctrl/ngx-numbered-codeblock | Angular |
---|---|
2.0.2 | 8.x |
3.0.1 | 9.x |
current | >= 10 |
Import the module
// Added to NgModule
import { NumberedCodeblockModule } from '@ctrl/ngx-numbered-codeblock';
// Import your required language in main.ts or at the root of your application
import 'prismjs';
// typescript
import 'prismjs/components/prism-typescript';
// javascript
import 'prismjs/components/prism-javascript';
Use The Component
<ngx-numbered-codeblock [code]="code"></ngx-numbered-codeblock>
Import a theme or create your own
code
- a formatted string of the code to displaylanguague
- default:typescript
the code parser to use with prismjslineNumbers
- default:true
if line numbers should be shown
MIT