Skip to content

Text block followed by more items skips said items #15

@michaelcadilhac

Description

@michaelcadilhac

In the following file, the second item (bar) does not appear in the parsed data. Changing the value of foo for an inline value solves the problem.

baz:
  - foo: |
      x
  - bar: y

This is because the first token after the | is an indent, and it is not counted towards the number of indents to undo to finish a textblock. Here's a fix:

diff --git a/yaml.lua b/yaml.lua
index 55211dc..6432b4a 100644
--- a/yaml.lua
+++ b/yaml.lua
@@ -448,6 +448,9 @@ Parser.parseTextBlock = function (self, sep)
   local token = self:advance()
   local result = string_trim(token.raw, "\n")
   local indents = 0
+  if token[1] == "indent" then
+     indents = 1
+  end
   while self:peek() ~= nil and ( indents > 0 or not self:peekType("dedent") ) do
     local newtoken = self:advance()
     while token.row < newtoken.row do

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions