Skip to content

Commit

Permalink
Make sure we use text nodes for the start and end locations. Resolves…
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvc committed Sep 15, 2019
1 parent 5573bb0 commit 97dcd58
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ts/handlers/html/HTMLDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ export class HTMLDocument<N, T, D> extends AbstractMathDocument<N, T, D> {
* @return {Location} The Location object for the position of the delimiter in the document
*/
protected findPosition(N: number, index: number, delim: string, nodes: HTMLNodeArray<N, T>): Location<N, T> {
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;
}
Expand Down

0 comments on commit 97dcd58

Please sign in to comment.