Fix splice list insertion (#84) * Fix spliceList error for nested lists * Fix list indentation calculation * Add golden tests for spliceList * Remove skip flag on test added in 8cc8580 * Add missing line at end of file * Add spliceList tests * Skip random test that fails (20th iteration) * Add deeply nested input in golden tests for spliceList * Fix formatting to account for space in nested list * Add golden tests for weird spaces in nested list * Run dart format * Update `_formatNewBlock` to return indent size instead of the indent * Update test/testdata/input/splice_list_in_nested_block_with_weird_spaces.test --------- Co-authored-by: Jonas Finnemann Jensen <jopsen@gmail.com>
A library for YAML manipulation while preserving comments.
A simple usage example:
import 'package:yaml_edit/yaml_edit.dart'; void main() { final yamlEditor = YamlEditor('{YAML: YAML}'); yamlEditor.update(['YAML'], "YAML Ain't Markup Language"); print(yamlEditor); // Expected output: // {YAML: YAML Ain't Markup Language} }
void main() { final jsonString = r''' { "key": "value", "list": [ "first", "second", "last entry in the list" ], "map": { "multiline": "this is a fairly long string with\nline breaks..." } } '''; final jsonValue = json.decode(jsonString); // Convert jsonValue to YAML final yamlEditor = YamlEditor(''); yamlEditor.update([], jsonValue); print(yamlEditor.toString()); }
Testing is done in two strategies: Unit testing (/test/editor_test.dart) and Golden testing (/test/golden_test.dart). More information on Golden testing and the input/output format can be found at /test/testdata/README.md.
These tests are automatically run with pub run test.