A web component to render KaTeX expression
npm install @navsnpm/katex-expressionA web component/custom element () to render KaTeX expressions.



- Installation
- HTML
- React/Angular/Vue
- Usage
- Basic
- Katex Options
- Error Handling
- Properties
- Events
Insert the following script tags in the section of your html
``html`
Install using npm`
`
npm i --save @navsnpm/katex-expression
- Angular 8 example: Refer the repo katex-expression-ng
> Note: Katex css, js, & fonts are bundled in this package. You can skip including them in your application. Please refer package.json for KaTeX version.
Use the tag anywhere in your html. Set the expression attribute to the katex expression.
`html`
katex-options accepts a json str for KaTeX rendering options. Refer KaTeX API Options for more information. Example usage for katex-options:
`html`
katex-options='{ "displayMode": true , "throwOnError": true }'>
Error objects are emitted via the onError event. Handle this event to re-throw, pipe exceptions to Sentry or elsewhere. Example non-JSX usage below:
`html
expression='\gte'
katex-options='{ "displayMode": true , "throwOnError": true }'>
`
> Note: Katex errors are emitted if katex-options.throwOnError is true. Other exceptions are emitted by default.
| Property | Attribute | Description | Type | Default |
| -------------- | --------------- | -------------------------- | -------- | ----------- |
| expression | expression | katex expression to render | string | undefined |katexOptions
| | katex-options | Katex options json | string | undefined |
| Event | Description | Type |
| --------- | ------------------------------- | ------------------ |
| onError | Emits Error object on exception | CustomEvent |