Skip to content

Commit a1ca9b0

Browse files
authored
Merge pull request #1893 from progfay/issue-1892
Resolve issue: "Cannot parse `[$ 1+1=2][- [link] ]`"
2 parents 04aa814 + fb43c96 commit a1ca9b0

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"build": "tsdown",
2424
"prepare": "npm run build",
2525
"test": "node --experimental-default-config-file --test --experimental-test-coverage",
26-
"test:update": "npm test -- --experimental-test-snapshots",
26+
"test:update": "npm test -- --test-update-snapshots",
2727
"lint": "npm run lint:biome && npm run lint:tsc",
2828
"lint:biome": "biome check .",
2929
"lint:tsc": "tsc -p ./tsconfig.lint.json",

src/block/node/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ export const convertToNodes: ReturnType<typeof combineNodeParsers> =
5454
NumberListNodeParser,
5555
CodeNodeParser,
5656
CommandLineNodeParser,
57-
FormulaNodeParser,
5857
BlankNodeParser,
5958
DecorationNodeParser,
59+
FormulaNodeParser,
6060
StrongImageNodeParser,
6161
StrongIconNodeParser,
6262
StrongNodeParser,

test/line/formula.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,11 @@ describe("formula", () => {
1717
it("Formula includes [] without tail half-space", ({ assert }) => {
1818
assert.snapshot(parse("[$ [x]]", { hasTitle: false }));
1919
});
20+
21+
// ref. https://github.com/progfay/scrapbox-parser/issues/1892
22+
it("Formula followed immediately by a decoration notation with trailing spaces", ({
23+
assert,
24+
}) => {
25+
assert.snapshot(parse("[$ 1+1=2][. [link] ]", { hasTitle: false }));
26+
});
2027
});

test/line/formula.test.ts.snapshot

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1+
exports[`formula > Formula followed immediately by a decoration notation with trailing spaces 1`] = `
2+
[
3+
{
4+
"indent": 0,
5+
"type": "line",
6+
"nodes": [
7+
{
8+
"type": "formula",
9+
"raw": "[$ 1+1=2]",
10+
"formula": "1+1=2"
11+
},
12+
{
13+
"type": "decoration",
14+
"raw": "[. [link] ]",
15+
"rawDecos": ".",
16+
"decos": [
17+
"."
18+
],
19+
"nodes": [
20+
{
21+
"type": "link",
22+
"raw": "[link]",
23+
"pathType": "relative",
24+
"href": "link",
25+
"content": ""
26+
},
27+
{
28+
"type": "plain",
29+
"raw": " ",
30+
"text": " "
31+
}
32+
]
33+
}
34+
]
35+
}
36+
]
37+
`;
38+
139
exports[`formula > Formula includes [] with tail half-space 1`] = `
240
[
341
{

0 commit comments

Comments
 (0)