BenjaminHoegh / ParsedownMath

LaTeX support in Parsedown

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.0 to 8.0

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
    ]
]);

About

LaTeX support in Parsedown

License:MIT License


Languages

Language:PHP 100.0%