feat: 添加 \\(...\\) 内联数学公式支持
This commit is contained in:
parent
f7b48027ce
commit
97355cefad
|
|
@ -121,6 +121,25 @@ const blockMathExtension = {
|
|||
},
|
||||
};
|
||||
|
||||
// marked extension for inline math \(...\)
|
||||
const bracketInlineMathExtension = {
|
||||
name: 'bracketInlineMath',
|
||||
level: 'inline',
|
||||
start(src) {
|
||||
const idx = src.indexOf('\\(');
|
||||
return idx === -1 ? undefined : idx;
|
||||
},
|
||||
tokenizer(src) {
|
||||
const match = src.match(/^\\\((.+?)\\\)/);
|
||||
if (match) {
|
||||
return { type: 'bracketInlineMath', raw: match[0], text: match[1].trim() };
|
||||
}
|
||||
},
|
||||
renderer(token) {
|
||||
return renderMath(token.text, false);
|
||||
},
|
||||
};
|
||||
|
||||
// marked extension for \[...\] block math
|
||||
const bracketMathExtension = {
|
||||
name: 'bracketMath',
|
||||
|
|
@ -186,6 +205,7 @@ marked.use({
|
|||
extensions: [
|
||||
blockMathExtension,
|
||||
bracketMathExtension,
|
||||
bracketInlineMathExtension,
|
||||
envMathExtension,
|
||||
mathExtension,
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue