From 3365a1bcc8842e4b97bf52a63e89348593e69469 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Thu, 24 Oct 2024 09:12:17 -0400 Subject: [PATCH] Improve merging of math lists (mathjax/MathJax#3301). --- ts/handlers/html/HTMLDocument.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ts/handlers/html/HTMLDocument.ts b/ts/handlers/html/HTMLDocument.ts index 385ffd584..cabdd1f74 100644 --- a/ts/handlers/html/HTMLDocument.ts +++ b/ts/handlers/html/HTMLDocument.ts @@ -124,14 +124,16 @@ export class HTMLDocument extends AbstractMathDocument { nodes: HTMLNodeArray ): Location { const adaptor = this.adaptor; - for (const list of nodes[N]) { - const [node, n] = list; + const inc = 1 / (nodes[N].length || 1); + let i = N; + for (const [node, n] of nodes[N]) { if (index <= n && adaptor.kind(node) === '#text') { - return { node: node, n: Math.max(index, 0), delim: delim }; + return { i, node, n: Math.max(index, 0), delim }; } index -= n; + i += inc; } - return { node: null, n: 0, delim: delim }; + return { node: null, n: 0, delim }; } /**