From 89884423fa7584572752352ef80019ea1bc5e721 Mon Sep 17 00:00:00 2001 From: Ben Ledbury Date: Wed, 9 Feb 2022 11:13:50 +0000 Subject: [PATCH] Allow inclusion of markdown from files --- app/lib/gruntConfig.js | 1 + app/lib/loadYaml.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/lib/gruntConfig.js b/app/lib/gruntConfig.js index 5385a5d6..693d4a7f 100644 --- a/app/lib/gruntConfig.js +++ b/app/lib/gruntConfig.js @@ -189,6 +189,7 @@ module.exports = function(grunt, options, spec) { templates: { files: [ options.specFile, + path.dirname(options.specFile) + '/**/*.md', options.appDir + '/views/**/*.hbs', options.appDir + '/helpers/**/*.js', options.appDir + '/lib/**/*.js' diff --git a/app/lib/loadYaml.js b/app/lib/loadYaml.js index 3bae679e..70de5a75 100644 --- a/app/lib/loadYaml.js +++ b/app/lib/loadYaml.js @@ -1,7 +1,14 @@ const fs = require('fs') -const yaml = require('js-yaml') +const p = require('path'); +const yaml = require('js-yaml'); + module.exports = function (path) { + const extendedSchema = yaml.DEFAULT_SCHEMA.extend({ + explicit: [ + new yaml.Type('!file', { kind: 'scalar', construct: function (relPath) { return fs.readFileSync(p.join(p.dirname(path), relPath), "utf8") }}) + ] + }); const fileContent = fs.readFileSync(path, "utf8") - return yaml.load(fileContent) + return yaml.load(fileContent, { schema: extendedSchema, filename: path }) } \ No newline at end of file