Files
gitbook/lib/parse/include.js
T
2014-11-01 15:00:13 +01:00

13 lines
355 B
JavaScript

var _ = require('lodash');
module.exports = function(markdown, includer) {
// Memoized include function (to cache lookups)
var _include = _.memoize(includer);
return markdown.replace(/{{([\s\S]+?)}}/g, function(match, key) {
// If fails leave content as is
key = key.trim();
return _include(key) || match;
});
};