Skip to content
This repository has been archived by the owner on Feb 27, 2022. It is now read-only.

Commit

Permalink
Use block string as cheap string escape
Browse files Browse the repository at this point in the history
Strings like '[Date 01:23:45] foo' cannot be bare strings in YAML

This fixes some TAP parsing errors when stderr is timestamped

see: http://pyyaml.org/wiki/YAMLColonInFlowContext
  • Loading branch information
rmg committed Apr 9, 2014
1 parent 8a2ec25 commit 2938a0e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion yamlish.js
Expand Up @@ -20,7 +20,7 @@ function encode (obj, indent) {
switch (typeof obj) {
case "string":
obj = obj.trim()
if (obj.indexOf("\n") !== -1) {
if (/[:\n\[\]]/g.test(obj)) {
return "|\n" + indent + obj.split(/\r?\n/).join("\n"+indent)
} else {
return (obj)
Expand Down

0 comments on commit 2938a0e

Please sign in to comment.