Skip to content

Commit 546a12e

Browse files
authored
fix: preserve newlines in markdown lists (#697)
1 parent 5b34a49 commit 546a12e

File tree

6 files changed

+312
-310
lines changed

6 files changed

+312
-310
lines changed

src/AnnotationsReader/ExtendedAnnotationsReader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class ExtendedAnnotationsReader extends BasicAnnotationsReader {
4545

4646
return {
4747
description: comments
48-
.map((comment) => comment.text.replace(/\r/g, "").replace(/(?<=[^\n])\n(?=[^\n])/g, " "))
48+
.map((comment) => comment.text.replace(/\r/g, "").replace(/(?<=[^\n])\n(?=[^\n*-])/g, " "))
4949
.join(" "),
5050
};
5151
}

test/config/jsdoc-complex-extended/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ export interface MyObject {
1616
*
1717
* The type of this field is integer.
1818
*
19+
* This is of type
20+
* - integer
21+
* - number
22+
*
1923
* @title Number field title
2024
* @exclusiveMaximum 10
2125
* @multipleOf 3

test/config/jsdoc-complex-extended/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"numberValue": {
1515
"type": "integer",
1616
"title": "Number field title",
17-
"description": "This field is of integer type. Integer!\n\nThe type of this field is integer.",
17+
"description": "This field is of integer type. Integer!\n\nThe type of this field is integer.\n\nThis is of type\n- integer\n- number",
1818
"exclusiveMaximum": 10,
1919
"multipleOf": 3
2020
},

test/utils.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,16 @@ export function assertValidSchema(
4141
}
4242

4343
const generator = createGenerator(config);
44-
4544
const schema = generator.createSchema(type);
46-
const expected: any = JSON.parse(readFileSync(resolve(`${basePath}/${relativePath}/schema.json`), "utf8"));
47-
const actual: any = JSON.parse(JSON.stringify(schema));
45+
const schemaFile = resolve(`${basePath}/${relativePath}/schema.json`);
4846

4947
if (process.env.UPDATE_SCHEMA) {
50-
writeFileSync(
51-
resolve(`${basePath}/${relativePath}/schema.json`),
52-
stringify(schema, { space: 2 }) + "\n",
53-
"utf8"
54-
);
48+
writeFileSync(schemaFile, stringify(schema, { space: 2 }) + "\n", "utf8");
5549
}
5650

51+
const expected: any = JSON.parse(readFileSync(schemaFile, "utf8"));
52+
const actual: any = JSON.parse(JSON.stringify(schema));
53+
5754
expect(typeof actual).toBe("object");
5855
expect(actual).toEqual(expected);
5956

test/vega-lite.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ describe("vega-lite", () => {
1616

1717
const generator = createGenerator(config);
1818
const schema = generator.createSchema(type);
19+
const schemaFile = resolve("test/vega-lite/schema.json");
1920

2021
if (process.env.UPDATE_SCHEMA) {
21-
writeFileSync(resolve("test/vega-lite/schema.json"), stringify(schema, { space: 2 }) + "\n", "utf8");
22+
writeFileSync(schemaFile, stringify(schema, { space: 2 }) + "\n", "utf8");
2223
}
2324

24-
const vegaLiteSchema = JSON.parse(readFileSync(resolve("test/vega-lite/schema.json"), "utf8"));
25+
const vegaLiteSchema = JSON.parse(readFileSync(schemaFile, "utf8"));
2526

2627
expect(schema).toEqual(vegaLiteSchema);
2728
});

0 commit comments

Comments
 (0)