Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text block followed by more items skips said items #15

Open
michaelcadilhac opened this issue Nov 15, 2022 · 0 comments
Open

Text block followed by more items skips said items #15

michaelcadilhac opened this issue Nov 15, 2022 · 0 comments

Comments

@michaelcadilhac
Copy link

michaelcadilhac commented Nov 15, 2022

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant