Skip to content

Commit

Permalink
Merge pull request #2639 from bladerunner2020/master
Browse files Browse the repository at this point in the history
fix: empty markdown files in external documents
  • Loading branch information
Gerrit0 committed Jul 13, 2024
2 parents 59b11bd + f26d981 commit 946ea38
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/converter/comments/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export function parseCommentString(
// Check for frontmatter
let frontmatterData: Record<string, unknown> = {};
const firstBlock = content[0];
if (firstBlock.text.startsWith("---\n")) {
if (firstBlock?.text?.startsWith("---\n")) {
const end = firstBlock.text.indexOf("\n---\n");
if (end !== -1) {
const yamlText = firstBlock.text.slice("---\n".length, end);
Expand Down
Empty file.
5 changes: 5 additions & 0 deletions src/test/converter2/issues/gh2638/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* @module
* @document empty.md
*/
export const a = 123;
8 changes: 8 additions & 0 deletions src/test/issues.c2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1655,4 +1655,12 @@ describe("Issue Tests", () => {
const sig = querySig(project, "B.constructor");
equal(sig.parameters?.length, 1);
});

it("#2638 empty markdown file", () => {
const project = convert();
equal(
project.documents?.map((d) => d.content),
[[]],
);
});
});

0 comments on commit 946ea38

Please sign in to comment.