diff --git a/scanner/context.go b/scanner/context.go index f231f8e..06e1fc4 100644 --- a/scanner/context.go +++ b/scanner/context.go @@ -89,26 +89,26 @@ func (c *Context) getMultiLineState() *MultiLineState { return c.mstate } -func (c *Context) setLiteral(opt string) { +func (c *Context) setLiteral(lastDelimColumn int, opt string) { mstate := &MultiLineState{ isLiteral: true, opt: opt, } indent := firstLineIndentColumnByOpt(opt) if indent > 0 { - mstate.firstLineIndentColumn = indent + 1 + mstate.firstLineIndentColumn = lastDelimColumn + indent } c.mstate = mstate } -func (c *Context) setFolded(opt string) { +func (c *Context) setFolded(lastDelimColumn int, opt string) { mstate := &MultiLineState{ isFolded: true, opt: opt, } indent := firstLineIndentColumnByOpt(opt) if indent > 0 { - mstate.firstLineIndentColumn = indent + 1 + mstate.firstLineIndentColumn = lastDelimColumn + indent } c.mstate = mstate } diff --git a/scanner/scanner.go b/scanner/scanner.go index a090a85..4cf70f2 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -1147,10 +1147,10 @@ func (s *Scanner) scanMultiLineHeaderOption(ctx *Context) error { switch header { case '|': ctx.addToken(token.Literal("|"+opt, headerBuf, s.pos())) - ctx.setLiteral(opt) + ctx.setLiteral(s.lastDelimColumn, opt) case '>': ctx.addToken(token.Folded(">"+opt, headerBuf, s.pos())) - ctx.setFolded(opt) + ctx.setFolded(s.lastDelimColumn, opt) } if commentIndex > 0 { comment := string(value[commentValueIndex+1:]) diff --git a/yaml_test_suite_test.go b/yaml_test_suite_test.go index 95011ff..dd39e22 100644 --- a/yaml_test_suite_test.go +++ b/yaml_test_suite_test.go @@ -36,7 +36,6 @@ var failureTestNames = []string{ "invalid-comma-in-tag", "invalid-tag", // pass yamlv3. "legal-tab-after-indentation", // pass yamlv3. - "literal-scalars", // pass yamlv3. "mapping-key-and-flow-sequence-item-anchors", // no json. "multiline-plain-value-with-tabs-on-empty-lines", // pass yamlv3. "multiline-scalar-at-top-level", // pass yamlv3.