mirror of
https://github.com/kotaindah55/extended-markdown-syntax.git
synced 2026-07-22 05:38:06 +00:00
fix(parser): error when encounter math syntax in a blockquote
This happen when getShifterStart() was trying to get math open inside a blockquote. Normally, getOpen() method in the ShifterNodeConfigs will recursively look for any of shifter node behind, using node.prevSibling prop to catch it. It doesn't result null value, except for the mentioned case above. So, we need to track the parent firstly, in this case it's a blockquote node, then get the previous sibling (it's blockquote too) and pick its last child (which is another math node).
This commit is contained in:
parent
17d3c9ce34
commit
92830cafab
1 changed files with 3 additions and 1 deletions
|
|
@ -20,7 +20,9 @@ export const ShifterNodeConfigs: Record<string, { query: string, getOpen: (node:
|
|||
query: "math",
|
||||
getOpen(node) {
|
||||
while (!node.name.includes("math-begin")) {
|
||||
node = node.prevSibling!;
|
||||
let prevSibling = node.prevSibling ?? node.parent?.prevSibling?.lastChild ?? null;
|
||||
if (!prevSibling) { return null }
|
||||
node = prevSibling;
|
||||
}
|
||||
if (node.to - node.from != 1) { return null }
|
||||
else { return node }
|
||||
|
|
|
|||
Loading…
Reference in a new issue