benjaminhoegh/parsedown-math

An extension of Parsedown that adds support for LaTeX.

Maintainers

👁 BenjaminHoegh

Package info

github.com/BenjaminHoegh/ParsedownMath

pkg:composer/benjaminhoegh/parsedown-math

Statistics

Installs: 177

Dependents: 0

Suggesters: 0

Stars: 18

Open Issues: 0

v2.0-beta1 2021-12-11 17:50 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 95897d169dcb654a97d80e40d7ee2267ed6bfaf5

parsermarkdownlatexparsedown

This package is auto-updated.

Last update: 2026-05-30 23:18:08 UTC


README

👁 ParsedownMath

ParsedownMath

👁 GitHub release
👁 GitHub

Latex support in Parsedown

Note

Does not yet include the lasted changes in ParsedownExtended v1.2.0

Features

  • Works with both Parsedown and ParsedownExtra
  • Tested in php 7.4 to 8.4

Get started

  1. Make sure you have downloaded and included Parsedown or ParsedownExtra
  2. Download the latest release and include ParsedownMath.php
  3. Download and include Katex.js and auto-render.js your HTML

How to write a match section

Inline:

  • \( ... \)
  • $ ... $ if enabled

Block:

  • \[ ... \]
  • $$ ... $$

Examples:

Inline

Inline \(tag{E=mc^2}\) math

<!-- Or -->

Inline $tag{E=mc^2}$ math

Block

$$
 f(x) = \int_{-\infty}^\infty
 \hat f(\xi)\,e^{2 \pi i \xi x}
 \,d\xi
$$

<!-- Or -->

\[
 f(x) = \int_{-\infty}^\infty
 \hat f(\xi)\,e^{2 \pi i \xi x}
 \,d\xi
\]

Options

You can toggle math by doing the following:

$Parsedown = new ParsedownMath([
 'math' => [
 'enabled' => true // Write true to enable the module
 ]
]);

Or if you only want inline or block you can use:

'math' => [
 ['inline'] => [
 'enabled' => false // false disable the module
 ],
 // Or
 ['block'] => [
 'enabled' => false
 ]
]

To enable single dollar sign for inline match:

$Parsedown = new ParsedownMath([
 'math' => [
 'matchSingleDollar' => true // default false
 ]
]);