Fixes #169. Remove JS-Yaml and use YAML-Front-Matter, resolving conflict

This commit is contained in:
Glavin Wiechert 2015-01-02 01:30:24 -04:00
parent e507701d13
commit f280469e77
5 changed files with 7 additions and 12 deletions

View File

@ -1,7 +1,3 @@
---
{}
---
- item
- item
- item

View File

@ -10,7 +10,7 @@ pets:
- dog
- bat
match: !<tag:yaml.org,2002:js/regexp> /pattern/gmi
run: !<tag:yaml.org,2002:js/function> "function () {\n \n \n \n\n\n}"
run: !<tag:yaml.org,2002:js/function> "function () {\n \n}"
---
- item

View File

@ -1,7 +1,6 @@
###
Requires http: //johnmacfarlane.net/pandoc/
###
yamlFront = null
fs = null
yaml = null
allowUnsafeNewFunction = null
@ -26,13 +25,13 @@ getCmd = (inputPath, outputPath, options, cb) ->
return cb(err) if err
# Parse with YAML front Matter
yamlFront ?= require "yaml-front-matter"
yaml ?= require "yaml-front-matter"
# console.log('Parse YAML Front Matter')
allowUnsafeNewFunction ?= require("loophole").allowUnsafeNewFunction
results = null
try
allowUnsafeNewFunction ->
results = yamlFront.loadFront(contents)
results = yaml.loadFront(contents)
catch e
return cb(e)
newContents = results.__content # jshint ignore: line
@ -47,10 +46,11 @@ getCmd = (inputPath, outputPath, options, cb) ->
completionCallback = (output, callback) ->
# console.log('Completion callback!')
try
yaml ?= require "js-yaml"
# Pre-pend YAML Front Matter to top of Markdown output
front = yaml.dump(results)
output = "---\n#{front}---\n\n#{output}"
# Check if there is valid `front` to prepend
if front isnt "{}\n"
output = "---\n#{front}---\n\n#{output}"
# console.log('final output!', output)
return callback(output)
catch e

View File

@ -118,7 +118,7 @@ module.exports =
# console.log "Failed parsing config as JSON: " + configPath
# Attempt as YAML
try
yaml ?= require("js-yaml")
yaml ?= require("yaml-front-matter")
externalOptions = yaml.safeLoad(contents)
catch e
console.log "Failed parsing config as YAML and JSON: " + configPath

View File

@ -52,7 +52,6 @@
"emissary": "^1.0.0",
"extend": "^1.2.1",
"js-beautify": "^1.5.4",
"js-yaml": "^3.0.2",
"lodash": "2.4.1",
"loophole": "^1.0.0",
"node-dir": "^0.1.6",