Skip to content

Commit

Permalink
cst/PlainValue: Allow :, to start a plain value in flow-out (Fixes #56)
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Dec 11, 2018
1 parent bf9947c commit dfac964
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions __tests__/cst/corner-cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,14 @@ test('eemeli/yaml#38', () => {
expect(item.error).toBe(null)
})
})

test('eemeli/yaml#56', () => {
const src = ':,\n'
const doc = parse(src)[0]
expect(doc.contents).toHaveLength(1)
expect(doc.contents[0]).toMatchObject({
error: null,
strValue: ':,',
type: 'PLAIN'
})
})
5 changes: 4 additions & 1 deletion src/cst/PlainValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export default class PlainValue extends Node {
const next = src[offset + 1]
if (
ch === ':' &&
(next === '\n' || next === '\t' || next === ' ' || next === ',')
(next === '\n' ||
next === '\t' ||
next === ' ' ||
(inFlow && next === ','))
)
break
if ((ch === ' ' || ch === '\t') && next === '#') break
Expand Down

0 comments on commit dfac964

Please sign in to comment.