dart-lang / yaml

A Dart YAML parser.
https://pub.dev/packages/yaml
MIT License
169 stars 58 forks source link

Incorrect handling of block scalars #132

Open bwilkerson opened 1 year ago

bwilkerson commented 1 year ago

When a block scalar using both folded and strip (>-) is processed, the newlines do not appear to be replaced by spaces. I haven't tested to see whether other forms of folded scalars are handled correctly.

jonasfj commented 3 months ago

FYI @kekavc24, I suppose we should investigate this.

I mean, if package:yaml_edit produces folded strings correctly and package:yaml parses them incorrectly, that'd probably cause some of our tests to fail :see_no_evil:

note to self: there is nice documentation of multi-line YAML strings at https://yaml-multiline.info/

kekavc24 commented 3 months ago

I think this issue should be closed. package: yaml does the right thing.

print(
    loadYaml('''
>-
  foo
  bar
''',
    ),
  ); // Prints "foo bar"

print(
    loadYaml('''
>-
  foo

  bar
''',
    ),
  ); // Prints "foo\nbar"
kekavc24 commented 3 months ago

note to self: there is nice documentation of multi-line YAML strings at https://yaml-multiline.info/

@jonasfj Indeed. 😅 What actually fails are the indentation indicators. Maybe he included them? I thought we could use them for strings with leading spaces but encountered an error from package: yaml for the fix in some cases. Had to fallback to double quotes.