From 97dcd58e1283a50a38c08361f582655417f79151 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Sun, 15 Sep 2019 18:47:48 -0400 Subject: [PATCH] Make sure we use text nodes for the start and end locations. Resolves issue mathjax/MathJax#2202 --- ts/handlers/html/HTMLDocument.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ts/handlers/html/HTMLDocument.ts b/ts/handlers/html/HTMLDocument.ts index 511979b33..b14c3ffb8 100644 --- a/ts/handlers/html/HTMLDocument.ts +++ b/ts/handlers/html/HTMLDocument.ts @@ -94,10 +94,11 @@ export class HTMLDocument extends AbstractMathDocument { * @return {Location} The Location object for the position of the delimiter in the document */ protected findPosition(N: number, index: number, delim: string, nodes: HTMLNodeArray): Location { + const adaptor = this.adaptor; for (const list of nodes[N]) { let [node, n] = list; - if (index <= n) { - return {node: node, n: index, delim: delim}; + if (index <= n && adaptor.kind(node) === '#text') { + return {node: node, n: Math.max(index, 0), delim: delim}; } index -= n; }