Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate the "joinString" content from the concatenated files by line breaks #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class MarkDownConcatenator {
ignore = [],
decreaseTitleLevels = false,
startTitleLevelAt = 1,
joinString = "\n",
joinString,
titleKey,
dirNameAsTitle = false,
fileNameAsTitle = false,
Expand All @@ -121,7 +121,7 @@ class MarkDownConcatenator {
this.ignore = ignore;
this.decreaseTitleLevels = decreaseTitleLevels;
this.startTitleLevelAt = startTitleLevelAt;
this.joinString = joinString;
this.joinString = joinString ? `\n${joinString}\n` : "\n";
this.titleKey = titleKey;
this.dirNameAsTitle = dirNameAsTitle;
this.fileNameAsTitle = fileNameAsTitle;
Expand Down
8 changes: 8 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ describe("concat", () => {
expect(result).toBe(expected);
});

it("should join concatenated files using a specified string.", async () => {
const result = await concat(join(__dirname, "test-helper/main"), {
joinString: "---",
});
const expected = await getExpected("join-separator.txt");
expect(result).toBe(expected);
});

it("should add toc tag and table of contents.", async () => {
const result = await concat(join(__dirname, "test-helper/main"), { toc: true });
const expected = await getExpected("toc-tag.txt");
Expand Down
22 changes: 22 additions & 0 deletions test/test-helper/expected/join-separator.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

<a name="dir-aamd"></a>

# Doc A

---

<a name="dir-bb1md"></a>

# Doc B1

---

<a name="dir-bb2md"></a>

# Doc B2

---

<a name="dir-bdir-b-subdir-b-sub-subb-submd"></a>

# Doc BSub