diff --git a/demo/test-cases.html b/demo/test-cases.html index 67a25c3..4348358 100644 --- a/demo/test-cases.html +++ b/demo/test-cases.html @@ -283,6 +283,7 @@

Super and Subscripts

(X^T)_ i.,j = X_ j.,i ||bf a||^2 |bf b|_i + ||a*b||^2 ln x = int_1^x 1/t dt diff --git a/src/compiler/parser/handlers/infix.js b/src/compiler/parser/handlers/infix.js index dc23403..8a5cccb 100644 --- a/src/compiler/parser/handlers/infix.js +++ b/src/compiler/parser/handlers/infix.js @@ -210,15 +210,16 @@ function rightAssociate(op, [left, right]) { * @returns {boolean} */ function isPipeDelimited(nodes) { - if (nodes.length !== 3) { + if (nodes.length < 3) { return false; } - const [open, , close] = nodes; + const open = nodes.at(0); + const close = nodes.at(-1); return ( - open.type === "OperatorLiteral" && - close.type === "OperatorLiteral" && + open?.type === "OperatorLiteral" && + close?.type === "OperatorLiteral" && (open.value === "|" || open.value === "โˆฅ" || open.value === "โ€–") && open.value === close.value ); diff --git a/test/snapshots/sub-supscripts.js.md b/test/snapshots/sub-supscripts.js.md index 81db9b3..6f94c99 100644 --- a/test/snapshots/sub-supscripts.js.md +++ b/test/snapshots/sub-supscripts.js.md @@ -99,3 +99,9 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 '|๐›|i' + +## Norm of the dot product square + +> Snapshot 1 + + 'โ€–aยทbโ€–2' diff --git a/test/snapshots/sub-supscripts.js.snap b/test/snapshots/sub-supscripts.js.snap index eea6a89..7a1e061 100644 Binary files a/test/snapshots/sub-supscripts.js.snap and b/test/snapshots/sub-supscripts.js.snap differ diff --git a/test/sub-supscripts.js b/test/sub-supscripts.js index 3c276cb..fd4aa4e 100644 --- a/test/sub-supscripts.js +++ b/test/sub-supscripts.js @@ -68,3 +68,7 @@ test("Square of a norm", (t) => { test("Index of a magnitute", (t) => { t.snapshot(render("|bf b|_i")); }); + +test("Norm of the dot product square", (t) => { + t.snapshot(render("||a*b||^2")); +});