Skip to content

Commit 152257e

Browse files
author
Sethen Maleno
committed
Added functionality for adding custom tags
1 parent 40dae60 commit 152257e

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

bin/cli.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env node
22

3+
/* eslint-env node */
4+
'use strict';
5+
36
var markdownJson = process.argv[2];
47
var markdownInclude = require('../markdown-include');
58

markdown-include.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,13 @@ exports.compileFiles = function (path) {
134134
self.build[file].parsedData = self.options.tableOfContents.heading + '\n\n' + self.tableOfContents + '\n\n' + self.build[file].parsedData;
135135
}
136136
}
137+
}
137138

138-
deferred.resolve(self.writeFile(self.build[file].parsedData));
139+
if (self.customTags && self.customTags.length) {
140+
self.build[file].parsedData = self.resolveCustomTags(self.build[file].parsedData);
139141
}
142+
143+
deferred.resolve(self.writeFile(self.build[file].parsedData));
140144
});
141145

142146
return deferred.promise;
@@ -336,6 +340,28 @@ exports.replaceWith = function (obj) {
336340
return replaced;
337341
};
338342

343+
exports.resolveCustomTags = function (data) {
344+
if (data) {
345+
var k;
346+
347+
for (k = 0; k < this.customTags.length; k += 1) {
348+
var customTagObj = this.customTags[k];
349+
var replacedData;
350+
351+
if (replacedData) {
352+
customTagObj.data = replacedData;
353+
}
354+
else {
355+
customTagObj.data = data;
356+
}
357+
358+
replacedData = this.stripTagsInFile(customTagObj);
359+
}
360+
361+
return replacedData;
362+
}
363+
};
364+
339365
/**
340366
* For stripping a pattern out of a tag
341367
* @param {Object} obj Key value pair include tag and pattern to strip

0 commit comments

Comments
 (0)