Skip to content

Commit 946ea38

Browse files
authored
Merge pull request #2639 from bladerunner2020/master
fix: empty markdown files in external documents
2 parents 59b11bd + f26d981 commit 946ea38

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

src/lib/converter/comments/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export function parseCommentString(
203203
// Check for frontmatter
204204
let frontmatterData: Record<string, unknown> = {};
205205
const firstBlock = content[0];
206-
if (firstBlock.text.startsWith("---\n")) {
206+
if (firstBlock?.text?.startsWith("---\n")) {
207207
const end = firstBlock.text.indexOf("\n---\n");
208208
if (end !== -1) {
209209
const yamlText = firstBlock.text.slice("---\n".length, end);

src/test/converter2/issues/gh2638/empty.md

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* @module
3+
* @document empty.md
4+
*/
5+
export const a = 123;

src/test/issues.c2.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,4 +1655,12 @@ describe("Issue Tests", () => {
16551655
const sig = querySig(project, "B.constructor");
16561656
equal(sig.parameters?.length, 1);
16571657
});
1658+
1659+
it("#2638 empty markdown file", () => {
1660+
const project = convert();
1661+
equal(
1662+
project.documents?.map((d) => d.content),
1663+
[[]],
1664+
);
1665+
});
16581666
});

0 commit comments

Comments
 (0)