From 25e8370ba87b287b7a896ee9371674c48280ff0c Mon Sep 17 00:00:00 2001 From: Max Mueller Date: Wed, 20 Apr 2022 13:51:06 -0400 Subject: [PATCH 1/2] Support filenames with multiple dots --- markdown-include.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown-include.js b/markdown-include.js index 304cc63..db9a6e8 100644 --- a/markdown-include.js +++ b/markdown-include.js @@ -12,7 +12,7 @@ var q = require('q'); this.ignoreTag = ' !ignore'; this.headingTag = ' !heading'; -this.includePattern = /^#include\s"(.+\/|\/|\w|-|\/)+\.(md|markdown)"/gm; +this.includePattern = /^#include\s"(.+\/|\/|\w|-|\/|\.)+\.(md|markdown)"/gm; this.ignorePattern = new RegExp('^#include\\s"(.+\\/|\\/|\\w|-|\\/)+\.(md|markdown)"' + this.ignoreTag, 'gm'); this.headingPattern = new RegExp('^#+\\s.+' + this.headingTag, 'gm'); this.tableOfContents = ''; From 280ad490a324a47c9925c437dd0cf822b307b934 Mon Sep 17 00:00:00 2001 From: Max Mueller Date: Wed, 20 Apr 2022 14:01:34 -0400 Subject: [PATCH 2/2] Update unit tests --- tests/data/docs/has_include_tags.md | 3 ++- tests/unit/findIncludeTags.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/data/docs/has_include_tags.md b/tests/data/docs/has_include_tags.md index 3f26199..ba34bd4 100644 --- a/tests/data/docs/has_include_tags.md +++ b/tests/data/docs/has_include_tags.md @@ -1,2 +1,3 @@ #include "tests/data/docs/1.md" -#include "tests/data/docs/2.md" \ No newline at end of file +#include "tests/data/docs/2.md" +#include "tests/data/docs/3.extradot.md" \ No newline at end of file diff --git a/tests/unit/findIncludeTags.js b/tests/unit/findIncludeTags.js index df29983..f1d2090 100644 --- a/tests/unit/findIncludeTags.js +++ b/tests/unit/findIncludeTags.js @@ -8,7 +8,7 @@ define([ bdd.it('should return an array if include tags are found', function () { var file = fs.readFileSync('tests/data/docs/has_include_tags.md').toString(); var findHeadingTags = markdownInclude.findIncludeTags(file); - assert.equal(findHeadingTags.length, 2, 'Heading tags length match'); + assert.equal(findHeadingTags.length, 3, 'Heading tags length match'); }); }); }); \ No newline at end of file