Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions demo/test-cases.html
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ <h2>Super and Subscripts</h2>
<test-case display="block">(X^T)_ i.,j = X_ j.,i</test-case>
<test-case display="block">||bf a||^2</test-case>
<test-case display="block">|bf b|_i</test-case>
<test-case display="block">||a*b||^2</test-case>

<test-case display="block">
ln x = int_1^x 1/t dt
Expand Down
9 changes: 5 additions & 4 deletions src/compiler/parser/handlers/infix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
6 changes: 6 additions & 0 deletions test/snapshots/sub-supscripts.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,9 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

'<math><msub><mrow><mo>|</mo><mi>𝐛</mi><mo>|</mo></mrow><mi>i</mi></msub></math>'

## Norm of the dot product square

> Snapshot 1

'<math><msup><mrow><mo>‖</mo><mi>a</mi><mo>·</mo><mi>b</mi><mo>‖</mo></mrow><mn>2</mn></msup></math>'
Binary file modified test/snapshots/sub-supscripts.js.snap
Binary file not shown.
4 changes: 4 additions & 0 deletions test/sub-supscripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
});