dart-lang / yaml_edit

A library for YAML manipulation with comment and whitespace preservation.
https://pub.dev/packages/yaml_edit
BSD 3-Clause "New" or "Revised" License
27 stars 16 forks source link

whitespace newline whitespace in folded string causes errors in `ScalarStyle.FOLDED` #41

Closed jonasfj closed 2 months ago

jonasfj commented 1 year ago

Example

import 'package:yaml/yaml.dart';
import 'package:yaml_edit/yaml_edit.dart';

void main() {
  final doc = YamlEditor('''
"hello"
''');

  final node = wrapAsYamlNode(
    'hello \n world',
    scalarStyle: ScalarStyle.FOLDED,
  );
  doc.update([], node);

  print(doc);
}

We need to:

Maybe, there are some cases where we have to output as "hello \n world" in double quoted mode. If we can't find a reasonably safe way to output in folded style, then it's safer to fallback to double quoted mode.

But ideally, we won't have to fallback in all non-trivial cases.

gantanikhilraj commented 1 year ago

Hello @jonasfj, I would like to work on this, could you please brief the issue? and also assign it to me.