Skip to content

Resolve issue: "Cannot parse [$ 1+1=2][- [link] ]" #1893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 29, 2025
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"build": "tsdown",
"prepare": "npm run build",
"test": "node --experimental-default-config-file --test --experimental-test-coverage",
"test:update": "npm test -- --experimental-test-snapshots",
"test:update": "npm test -- --test-update-snapshots",
"lint": "npm run lint:biome && npm run lint:tsc",
"lint:biome": "biome check .",
"lint:tsc": "tsc -p ./tsconfig.lint.json",
Expand Down
2 changes: 1 addition & 1 deletion src/block/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ export const convertToNodes: ReturnType<typeof combineNodeParsers> =
NumberListNodeParser,
CodeNodeParser,
CommandLineNodeParser,
FormulaNodeParser,
BlankNodeParser,
DecorationNodeParser,
FormulaNodeParser,
StrongImageNodeParser,
StrongIconNodeParser,
StrongNodeParser,
Expand Down
7 changes: 7 additions & 0 deletions test/line/formula.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ describe("formula", () => {
it("Formula includes [] without tail half-space", ({ assert }) => {
assert.snapshot(parse("[$ [x]]", { hasTitle: false }));
});

// ref. https://github.com/progfay/scrapbox-parser/issues/1892
it("Formula followed immediately by a decoration notation with trailing spaces", ({
assert,
}) => {
assert.snapshot(parse("[$ 1+1=2][. [link] ]", { hasTitle: false }));
});
});
38 changes: 38 additions & 0 deletions test/line/formula.test.ts.snapshot
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
exports[`formula > Formula followed immediately by a decoration notation with trailing spaces 1`] = `
[
{
"indent": 0,
"type": "line",
"nodes": [
{
"type": "formula",
"raw": "[$ 1+1=2]",
"formula": "1+1=2"
},
{
"type": "decoration",
"raw": "[. [link] ]",
"rawDecos": ".",
"decos": [
"."
],
"nodes": [
{
"type": "link",
"raw": "[link]",
"pathType": "relative",
"href": "link",
"content": ""
},
{
"type": "plain",
"raw": " ",
"text": " "
}
]
}
]
}
]
Comment on lines +2 to +36
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as "Expected Output" on #1892

`;

exports[`formula > Formula includes [] with tail half-space 1`] = `
[
{
Expand Down
Loading