Skip to content

Commit b85576a

Browse files
修复疏松列表的问题;release 0.0.2
1 parent b3bcf04 commit b85576a

File tree

5 files changed

+23
-37
lines changed

5 files changed

+23
-37
lines changed

examples/SupportedGrammer/problem-0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ This is `inline code`
3838
2. item 2
3939
3. item 3
4040

41+
- item 1
42+
43+
- item 2
44+
4145
[NOI website](https://noi.cn/)
4246

4347
![1.jpg](https://private-static.mrpython.top/cnoi-gen-test-img_324e0508.jpg)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"private": true,
44
"description": "A website to generate CNOI-style statements for competitive programming.",
55
"license": "AGPL-3.0",
6-
"version": "0.0.1",
6+
"version": "0.0.2",
77
"type": "module",
88
"repository": {
99
"url": "https://github.com/Mr-Python-in-China/cnoi-statement-generator"

src/compiler/remarkTypst/compiler.ts

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function initContext(): CompilerContext {
4242

4343
export function collectDefinitions(
4444
tree: mdast.Root,
45-
{ definitionById, footnoteById }: CompilerContext,
45+
{ definitionById, footnoteById }: CompilerContext
4646
) {
4747
// Collect definitions and footnote definitions
4848
visit(tree, (node) => {
@@ -60,7 +60,7 @@ export function collectDefinitions(
6060
// Revert reference nodes to plain text
6161
function revert(
6262
node: Extract<mdast.Nodes, mdast.Reference>,
63-
ctx: CompilerContext,
63+
ctx: CompilerContext
6464
) {
6565
const { data } = ctx;
6666
let suffix = '#"]';
@@ -75,7 +75,7 @@ function revert(
7575
'#"!["#"',
7676
node.alt ? escapeTypstString(node.alt) : "",
7777
'"',
78-
suffix,
78+
suffix
7979
);
8080
return;
8181
}
@@ -140,18 +140,18 @@ export const handlers = {
140140
? "txt"
141141
: node.lang === "markdown"
142142
? "md"
143-
: node.lang,
143+
: node.lang
144144
)}", "`,
145145
escapeTypstString(node.value),
146-
'")\n',
146+
'")\n'
147147
);
148148
},
149149
inlineCode: (node, ctx) => {
150150
const { data } = ctx;
151151
data.push(
152152
`#raw(block: false, lang: "txt", "`,
153153
escapeTypstString(node.value),
154-
'")',
154+
'")'
155155
);
156156
},
157157
list: (node, ctx) => {
@@ -163,17 +163,6 @@ export const handlers = {
163163
data.push("#list(");
164164
}
165165
data.push("\n");
166-
let loose = node.spread ?? false;
167-
if (!loose)
168-
for (const item of node.children)
169-
if (
170-
item.spread ||
171-
(typeof item.spread !== "boolean" && item.children.length > 1)
172-
) {
173-
loose = true;
174-
break;
175-
}
176-
if (loose) for (const item of node.children) item.spread = true;
177166
for (const item of node.children) {
178167
data.push("[");
179168
parseContent(item, ctx);
@@ -183,7 +172,7 @@ export const handlers = {
183172
},
184173
listItem: (node, ctx) => {
185174
for (const item of node.children) {
186-
if (item.type === "paragraph" && !node.spread)
175+
if (item.type === "paragraph")
187176
for (const child of item.children) parseContent(child, ctx);
188177
else parseContent(item, ctx);
189178
}
@@ -288,7 +277,7 @@ export const handlers = {
288277
data.push(
289278
'#footnote(label("',
290279
FOOTNOTE_ID_PREFIX + escapeTypstString(node.identifier),
291-
'"))',
280+
'"))'
292281
);
293282
} else {
294283
data.push('#"[^', escapeTypstString(node.identifier), ']"');
@@ -300,7 +289,7 @@ export const handlers = {
300289
data.push(
301290
'#raw(block: false, lang: "html", "',
302291
escapeTypstString(node.value),
303-
'")',
292+
'")'
304293
);
305294
},
306295
yaml: () => {
@@ -309,7 +298,7 @@ export const handlers = {
309298
} as const satisfies {
310299
[K in keyof mdast.RootContentMap]: (
311300
node: mdast.RootContentMap[K],
312-
ctx: CompilerContext,
301+
ctx: CompilerContext
313302
) => void;
314303
};
315304

tests/unit/remark-typst.common.test.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,8 @@ describe("Handlers", () => {
525525
);
526526
expect(ctx.data.join("")).toBe(
527527
`#enum(
528-
[#par[#"Item 1"]
529-
],
530-
[#par[#"Item 2"]
531-
],
528+
[#"Item 1"],
529+
[#"Item 2"],
532530
)
533531
`,
534532
);
@@ -567,10 +565,8 @@ describe("Handlers", () => {
567565
);
568566
expect(ctx.data.join("")).toBe(
569567
`#enum(
570-
[#par[#"Item 1"]
571-
],
572-
[#par[#"Item 2"]
573-
],
568+
[#"Item 1"],
569+
[#"Item 2"],
574570
)
575571
`,
576572
);
@@ -610,11 +606,8 @@ describe("Handlers", () => {
610606
);
611607
expect(ctx.data.join("")).toBe(
612608
`#enum(
613-
[#par[#"Item 1.1"]
614-
#par[#"Item 1.2"]
615-
],
616-
[#par[#"Item 2"]
617-
],
609+
[#"Item 1.1"#"Item 1.2"],
610+
[#"Item 2"],
618611
)
619612
`,
620613
);

0 commit comments

Comments
 (0)