Skip to content

Block with indent indicator is not parsed correctly #399

@martin-sucha

Description

@martin-sucha

Describe the bug
Yaml with block indent indicator is not parsed corrrectly, the spaces at the beginning are trimmed.

To Reproduce

package main

import (
	"os"

	"github.com/goccy/go-yaml/parser"
)

func main() {
	input, err := os.ReadFile("input6.yaml")
	if err != nil {
		panic(err)
	}
	f, err := parser.ParseBytes(input, 0)
	if err != nil {
		panic(err)
	}
	_, err = os.Stdout.Write([]byte(f.String()))
	if err != nil {
		panic(err)
	}
}
|2-

                  text

Expected behavior

Expected to get the same output as input, but got:

2-
text

The yaml should be equivalent to

"\n                text"

Version Variables

  • Go version: go1.21.1
  • go-yaml's Version: v1.11.2

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions