|
@@ -10,6 +10,8 @@
|
|
|
|
|
|
|
|
import type {
|
|
import type {
|
|
|
BlockContext,
|
|
BlockContext,
|
|
|
|
|
+ InlineContext,
|
|
|
|
|
+ InlineParser,
|
|
|
LeafBlock,
|
|
LeafBlock,
|
|
|
LeafBlockParser,
|
|
LeafBlockParser,
|
|
|
MarkdownConfig,
|
|
MarkdownConfig,
|
|
@@ -118,12 +120,12 @@ function createPatternExtension(patterns: MarkdownPattern[]): MarkdownConfig {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function createInlineMathParser(): MarkdownConfig["parseInline"] {
|
|
|
|
|
|
|
+function createInlineMathParser(): InlineParser {
|
|
|
const nodeType = "InlineMath"
|
|
const nodeType = "InlineMath"
|
|
|
return {
|
|
return {
|
|
|
name: nodeType,
|
|
name: nodeType,
|
|
|
before: "Link",
|
|
before: "Link",
|
|
|
- parse(cx, _next, pos) {
|
|
|
|
|
|
|
+ parse(cx: InlineContext, _next: number, pos: number) {
|
|
|
if (cx.char(pos) !== 36) return -1 // '$'
|
|
if (cx.char(pos) !== 36) return -1 // '$'
|
|
|
|
|
|
|
|
// Don't consume $$ as inline math
|
|
// Don't consume $$ as inline math
|
|
@@ -281,15 +283,11 @@ export function createMarkdownExtensions(
|
|
|
|
|
|
|
|
const merged: MarkdownConfig = {
|
|
const merged: MarkdownConfig = {
|
|
|
defineNodes: [
|
|
defineNodes: [
|
|
|
- ...((patternExt.defineNodes as Array<{ name: string; block: boolean }>) ??
|
|
|
|
|
- []),
|
|
|
|
|
|
|
+ ...(patternExt.defineNodes ?? []),
|
|
|
{ name: "InlineMath", block: false },
|
|
{ name: "InlineMath", block: false },
|
|
|
],
|
|
],
|
|
|
parseInline: [
|
|
parseInline: [
|
|
|
- ...((patternExt.parseInline as Array<{
|
|
|
|
|
- name: string
|
|
|
|
|
- parse: (cx: unknown, next: number, pos: number) => number
|
|
|
|
|
- }>) ?? []),
|
|
|
|
|
|
|
+ ...(patternExt.parseInline ?? []),
|
|
|
inlineMathParser,
|
|
inlineMathParser,
|
|
|
],
|
|
],
|
|
|
}
|
|
}
|