New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-autolatex

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-autolatex

Auto-render LaTeX in React

latest
Source
npmnpm
Version
2.0.1
Version published
Weekly downloads
10
-28.57%
Maintainers
1
Weekly downloads
 
Created
Source

react-autolatex

Auto-render LaTeX in React.

Based on KaTeX. TypeScript declaration supported.

Installation

npm install react-autolatex

Usage

Normal:

import 'katex/dist/katex.min.css';
import AutoLaTeX from 'react-autolatex';

export default () => {
  return (
    <AutoLaTeX>{'LaTeX string or HTML rich text with LaTeX like $c = \\pm\\sqrt{a^2 + b^2}$'}</AutoLaTeX>    
  );
};

With TypeScript:

import 'katex/dist/katex.min.css';
import AutoLaTeX, { RenderMathInElementOptions } from 'react-autolatex';

export default () => {
  const options: RenderMathInElementOptions = {
    delimiters: [
      { left: '$$', right: '$$', display: true },
      { left: '$', right: '$', display: false },
    ],
    errorCallback(msg: string, err: Error) {
      console.error('[Error]', msg, err);
    },
  };
  return (
    <AutoLaTeX options={options}>{'LaTeX string or HTML rich text with LaTeX like $c = \\pm\\sqrt{a^2 + b^2}$'}</AutoLaTeX>    
  );
};

Note: You may need to handle XSS before passing string to AutoLaTeX.

Props

NameTypeDefaultDescription
childrenstring, required''The string content to render
optionsRenderMathInElementOptions*see belowRender options (doc)
classNamestring''Class name for the container to render LaTeX
styleReact.CSSProperties{}Style for the container to render LaTeX

options default:

{
  delimiters: [
    { left: "$$", right: "$$", display: true },
    { left: "\\[", right: "\\]", display: true },
    { left: "$", right: "$", display: false },
    { left: "\\(", right: "\\)", display: false },
  ],
}

License

MIT

Keywords

react

FAQs

Package last updated on 16 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts