mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-13 11:55:38 +00:00
parent
fa322aec33
commit
7f26d91cd0
@ -37,7 +37,7 @@ func (dec *yamlDecoder) processReadStream(reader *bufio.Reader) (io.Reader, stri
|
|||||||
var yamlDirectiveLineRegEx = regexp.MustCompile(`^\s*%YA`)
|
var yamlDirectiveLineRegEx = regexp.MustCompile(`^\s*%YA`)
|
||||||
var sb strings.Builder
|
var sb strings.Builder
|
||||||
for {
|
for {
|
||||||
peekBytes, err := reader.Peek(3)
|
peekBytes, err := reader.Peek(4)
|
||||||
if errors.Is(err, io.EOF) {
|
if errors.Is(err, io.EOF) {
|
||||||
// EOF are handled else where..
|
// EOF are handled else where..
|
||||||
return reader, sb.String(), nil
|
return reader, sb.String(), nil
|
||||||
@ -51,7 +51,15 @@ func (dec *yamlDecoder) processReadStream(reader *bufio.Reader) (io.Reader, stri
|
|||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return reader, sb.String(), err
|
return reader, sb.String(), err
|
||||||
}
|
}
|
||||||
} else if string(peekBytes) == "---" {
|
} else if string(peekBytes) == "--- " {
|
||||||
|
_, err := reader.ReadString(' ')
|
||||||
|
sb.WriteString("$yqDocSeparator$\n")
|
||||||
|
if errors.Is(err, io.EOF) {
|
||||||
|
return reader, sb.String(), nil
|
||||||
|
} else if err != nil {
|
||||||
|
return reader, sb.String(), err
|
||||||
|
}
|
||||||
|
} else if string(peekBytes) == "---\n" {
|
||||||
_, err := reader.ReadString('\n')
|
_, err := reader.ReadString('\n')
|
||||||
sb.WriteString("$yqDocSeparator$\n")
|
sb.WriteString("$yqDocSeparator$\n")
|
||||||
if errors.Is(err, io.EOF) {
|
if errors.Is(err, io.EOF) {
|
||||||
|
@ -7,6 +7,18 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var yamlFormatScenarios = []formatScenario{
|
var yamlFormatScenarios = []formatScenario{
|
||||||
|
{
|
||||||
|
description: "scalar with doc separator",
|
||||||
|
skipDoc: true,
|
||||||
|
input: "--- cat",
|
||||||
|
expected: "---\ncat\n",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "scalar with doc separator",
|
||||||
|
skipDoc: true,
|
||||||
|
input: "---cat",
|
||||||
|
expected: "---cat\n",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: "basic - null",
|
description: "basic - null",
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user