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:
kotaindah55 2025-03-20 16:37:53 +02:00
parent 17d3c9ce34
commit 92830cafab

View file

@ -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 }