GitXplorerGitXplorer
U

marked-katex-extension

public
67 stars
18 forks
0 issues

Commits

List of commits on branch main.
Verified
dba3c33a3524cbae868a6447a37799bb2021aca9

Merge pull request #495 from UziTech/dependabot/npm_and_yarn/rollup-4.30.1

ggithub-actions[bot] committed 5 days ago
Verified
a290520bae5a8c1a87f8eb98424a907846158280

Merge pull request #494 from UziTech/dependabot/npm_and_yarn/katex-0.16.20

ggithub-actions[bot] committed 5 days ago
Verified
25ace2a6338355b0d72810442f8ff875d0402d70

chore(deps-dev): bump rollup from 4.30.0 to 4.30.1

ddependabot[bot] committed 5 days ago
Verified
86b7ae3937874b34726981d28b4c1200e3d0f47e

chore(deps-dev): bump katex from 0.16.19 to 0.16.20

ddependabot[bot] committed 5 days ago
Verified
ace22ee1821917ee2995c784c2a9123b3037a631

Merge pull request #492 from UziTech/dependabot/npm_and_yarn/semantic-release-24.2.1

ggithub-actions[bot] committed 12 days ago
Verified
3e62a727eb2b0374871622e591196e8405f6b8b4

chore(deps-dev): bump semantic-release from 24.2.0 to 24.2.1

ddependabot[bot] committed 12 days ago

README

The README file for this repository.

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