markdown-it-katex-newcommand

1.1.1 • Public • Published

markdown-it-katex-newcommand

Plugin markdown-it for katex rendering with ability to add global \newcommand

Installation

yarn add markdown-it-katex-newcommand
# or 
npm install markdown-it-katex-newcommand --save

Add CSS:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous">

Basic

const md = require('markdown-it')();
const mkn = require('markdown-it-katex-newcommand');
md.use(mkn);

## Add newcommands

Example:

const md = require('markdown-it')();
const mynewcommands = '\\displaystyle'
   +'\\newcommand{\\vect}[1]{\\overrightarrow{#1}}'
   +'\\newcommand{\\Oij}{\\left(O;\\vect{i};\\vect{j}\\right)}';
const mkn = require('markdown-it-katex-newcommand');
md.use(mkn, {
     "newcommands": mynewcommands
   });

## Katex

Katex supported functions

The native katex syntax also is supported:

const mymacroskatex = {
   "\\f": "f(#1)"
};
const mynewcommands = '\\newcommand{\\g}[1]{g\\left(#1\\right)}';
const mkn = require('markdown-it-katex-newcommand');
md.use(mkn, {
   "macros": mymacroskatex,
   "newcommands": mynewcommands
})

Package Sidebar

Install

npm i markdown-it-katex-newcommand

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

9.49 kB

Total Files

4

Last publish

Collaborators

  • davidcouronne