Skip to content

Commit 3718e54

Browse files
authored
Merge pull request #1755 from progfay/fix-number-list-nesting
fix Inconsistent parsing of number list with non-plain text
2 parents 0ae0c4d + 1d353d2 commit 3718e54

File tree

5 files changed

+69
-3
lines changed

5 files changed

+69
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"build:vite": "vite build",
2222
"prepare": "npm run build",
2323
"test": "vitest run --coverage",
24-
"test:update": "vitest run --updateSnapshot --no-cache",
24+
"test:update": "vitest run -u",
2525
"lint": "run-p lint:*",
2626
"lint:biome": "biome check .",
2727
"lint:tsc": "tsc -p ./tsconfig.lint.json",

src/block/node/NumberListNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const createNumberListNode: NodeCreator<NumberListNode | PlainNode> = (
2525
raw,
2626
rawNumber,
2727
number,
28-
nodes: convertToNodes(text, { ...opts, nested: true }),
28+
nodes: convertToNodes(text, { ...opts, nested: false }),
2929
},
3030
];
3131
};

src/block/node/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const convertToNodes: ReturnType<typeof combineNodeParsers> =
5151
FalsyEliminator,
5252
QuoteNodeParser,
5353
HelpfeelNodeParser,
54+
NumberListNodeParser,
5455
CodeNodeParser,
5556
CommandLineNodeParser,
5657
FormulaNodeParser,
@@ -65,5 +66,4 @@ export const convertToNodes: ReturnType<typeof combineNodeParsers> =
6566
GoogleMapNodeParser,
6667
InternalLinkNodeParser,
6768
HashTagNodeParser,
68-
NumberListNodeParser,
6969
);

tests/line/__snapshots__/numberList.test.ts.snap

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,63 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3+
exports[`numberList > 1. with code 1`] = `
4+
[
5+
{
6+
"indent": 0,
7+
"nodes": [
8+
{
9+
"nodes": [
10+
{
11+
"raw": "\`code\`",
12+
"text": "code",
13+
"type": "code",
14+
},
15+
],
16+
"number": 1,
17+
"raw": "1. \`code\`",
18+
"rawNumber": "1",
19+
"type": "numberList",
20+
},
21+
],
22+
"type": "line",
23+
},
24+
]
25+
`;
26+
27+
exports[`numberList > 1. with decoration 1`] = `
28+
[
29+
{
30+
"indent": 0,
31+
"nodes": [
32+
{
33+
"nodes": [
34+
{
35+
"decos": [
36+
"*-1",
37+
],
38+
"nodes": [
39+
{
40+
"raw": "deco",
41+
"text": "deco",
42+
"type": "plain",
43+
},
44+
],
45+
"raw": "[* deco]",
46+
"rawDecos": "*",
47+
"type": "decoration",
48+
},
49+
],
50+
"number": 1,
51+
"raw": "1. [* deco]",
52+
"rawNumber": "1",
53+
"type": "numberList",
54+
},
55+
],
56+
"type": "line",
57+
},
58+
]
59+
`;
60+
361
exports[`numberList > 1. with no space is not numberList 1`] = `
462
[
563
{

tests/line/numberList.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ describe("numberList", () => {
1818
).toMatchSnapshot();
1919
});
2020

21+
it("1. with decoration", () => {
22+
expect(parse("1. [* deco]", { hasTitle: false })).toMatchSnapshot();
23+
});
24+
25+
it("1. with code", () => {
26+
expect(parse("1. `code`", { hasTitle: false })).toMatchSnapshot();
27+
});
28+
2129
it("1. with no space is not numberList", () => {
2230
expect(
2331
parse("1.not numberList", {

0 commit comments

Comments
 (0)