New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

marked-katex-extension

Package Overview
Dependencies
Maintainers
0
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marked-katex-extension

MarkedJS extesion to render katex

  • 5.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
increased by0.01%
Maintainers
0
Weekly downloads
 
Created
Source

marked-katex-extension

Render katex code in marked

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/katex@0.16.8/dist/katex.min.css" integrity="sha384-GvrOXuhMATgEsSwCs4smul74iXGOixntILdUW9XmUC6+HX0sLNAK3q71HotJqlAn" crossorigin="anonymous">

Usage

import {marked} from "marked";
import markedKatex from "marked-katex-extension";

// or in the browser
// <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@{version}/dist/katex.min.css" crossorigin="anonymous">
// <script src="https://cdn.jsdelivr.net/npm/katex@{version}/dist/katex.min.js" crossorigin="anonymous"></script>
// <script src="https://cdn.jsdelivr.net/npm/marked@{version}/lib/marked.umd.js"></script>
// <script src="https://cdn.jsdelivr.net/npm/marked-katex-extension@{version}/lib/index.umd.js"></script>

const options = {
  throwOnError: false
};

marked.use(markedKatex(options));

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

image

Block level

You can include newlines in block level katex. Block level katex must contain starting and ending delimiters on their own line.

marked.parse(`
$$
\\begin{array}{cc}
   a & b \\\\
   c & d
\\end{array}
$$
`);

DisplayMode

displayMode will be on by default when using two dollar signs ($$) in inline or block katex. And it will be off by default for a single dollar sign ($) in inline or block katex.

Non Standard

If you want to be able to parse mathematical formulas in non-standard markdown format, that is, without spaces before and after $ or $$, you can turn on the nonStandard option.

import {marked} from "marked";
import markedKatex from "marked-katex-extension";

const options = {
  nonStandard: true
};

marked.use(markedKatex(options));

marked.parse(`
afdaf$x=x^2$4$x=x^2$

$$
x = x^2
$$
`);

image

options

Options are sent directly to katex

Keywords

FAQs

Package last updated on 24 Dec 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc