benjaminhoegh / parsedown-math
Parsedown 的扩展,增加了对 LaTeX 的支持。
v2.0-beta1
2021-12-11 17:50 UTC
Requires
- php: ^7.1||^8.0
- ext-mbstring: *
- erusev/parsedown: ^2.0.0|2.0.x@dev
This package is auto-updated.
Last update: 2024-08-26 22:26:22 UTC
README
ParsedownMath
在 Parsedown 中添加 LaTeX 支持
注意
尚未包含 ParsedownExtended v1.2.0 的最新更改
功能
- 与 Parsedown 和 ParsedownExtra 都兼容
- 在 php 7.0 到 8.0 上进行过测试
开始使用
- 确保您已下载并包含 Parsedown 或 ParsedownExtra
- 下载最新版本 latest release 并包含 ParsedownMath.php
- 下载并包含 Katex.js 和 auto-render.js 到您的 HTML 中
如何编写匹配部分
行内
\( ... \)
$ ... $
如果启用
块
\[ ... \]
$$ ... $$
示例
行内
Inline \(tag{E=mc^2}\) math <!-- Or --> Inline $tag{E=mc^2}$ math
块
$$ 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 \]
选项
您可以通过以下方式切换数学公式
$Parsedown = new ParsedownMath([ 'math' => [ 'enabled' => true // Write true to enable the module ] ]);
或者,如果您只想使用行内或块,可以使用
'math' => [ ['inline'] => [ 'enabled' => false // false disable the module ], // Or ['block'] => [ 'enabled' => false ] ]
启用单美元符号进行行内匹配
$Parsedown = new ParsedownMath([ 'math' => [ 'matchSingleDollar' => true // default false ] ]);