Skip to content

Commit

Permalink
Fixes #169. Remove JS-Yaml and use YAML-Front-Matter, resolving conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavin001 committed Jan 2, 2015
1 parent e507701 commit f280469
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
4 changes: 0 additions & 4 deletions examples/simple-jsbeautifyrc/markdown/expected/test.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
{}
---

- item
- item
- item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions lib/langs/markdown-beautify.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
###
Requires http: //johnmacfarlane.net/pandoc/
###
yamlFront = null
fs = null
yaml = null
allowUnsafeNewFunction = null
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/options.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f280469

Please sign in to comment.