diff --git a/src/index.ts b/src/index.ts
index dae82ca..dc418f9 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -109,7 +109,7 @@ class MarkDownConcatenator {
ignore = [],
decreaseTitleLevels = false,
startTitleLevelAt = 1,
- joinString = "\n",
+ joinString,
titleKey,
dirNameAsTitle = false,
fileNameAsTitle = false,
@@ -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;
diff --git a/test/index.test.ts b/test/index.test.ts
index 01a22e8..621779d 100644
--- a/test/index.test.ts
+++ b/test/index.test.ts
@@ -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");
diff --git a/test/test-helper/expected/join-separator.txt b/test/test-helper/expected/join-separator.txt
new file mode 100644
index 0000000..a9a42e0
--- /dev/null
+++ b/test/test-helper/expected/join-separator.txt
@@ -0,0 +1,22 @@
+
+
+
+# Doc A
+
+---
+
+
+
+# Doc B1
+
+---
+
+
+
+# Doc B2
+
+---
+
+
+
+# Doc BSub