Skip to content

Jaya-sys/marked-katex-extension

 
 

Repository files navigation

marked-katex-extension

Render katex code in marked

Note: Block level katex requires at least 2 $ at the beginning and end.

This is inline katex: $c = \\pm\\sqrt{a^2 + b^2}$

This is block level katex:

$$
c = \\pm\\sqrt{a^2 + b^2}
$$

You will still need to include the css in your html document to allow katex styles.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-bYdxxUwYipFNohQlHt0bjN/LCpueqWz13HufFEV1SUatKs1cm4L6fFgCi1jT643X" crossorigin="anonymous">

Usage

const {marked} = require("marked");
const markedKatex = require("marked-katex-extension");

// or ES Module script
// import marked from "https://cdn.jsdelivr.net/gh/markedjs/marked/lib/marked.esm.js";
// import markedKatex from "https://cdn.jsdelivr.net/gh/UziTech/marked-katex-extension/lib/index.mjs";

const options = {
  throwOnError: false
};

marked.use(markedKatex(options));

marked("katex: $c = \\pm\\sqrt{a^2 + b^2}$");

image

options

Options are sent directly to katex.renderToString

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%