diff --git a/AUTHORS.md b/AUTHORS.md index b9e3aaea1..1eff52cdc 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -175,6 +175,7 @@ date of first contribution): * [Frederik Kemner](https://github.com/040medien) * [Moiz Rasheed](https://github.com/msrasheed) * [Scott Martin](https://github.com/smartin015) + * [Shyam Sunder](https://github.com/sgsunder) OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by [Daid Braam](https://github.com/daid). Parts of its communication layer and diff --git a/src/octoprint/util/yaml.py b/src/octoprint/util/yaml.py index 0a0e3cace..d36f652c4 100644 --- a/src/octoprint/util/yaml.py +++ b/src/octoprint/util/yaml.py @@ -44,6 +44,14 @@ def _save_to_file_base(data, file=None, path=None, pretty=False, **kwargs): except ImportError: from yaml import SafeDumper + # make multiline strings look better by using block scalars + def _block_scalar_str_presenter(dumper, data): + return dumper.represent_scalar( + "tag:yaml.org,2002:str", data, style="|" if "\n" in data else None + ) + + SafeDumper.add_representer(str, _block_scalar_str_presenter) + if pretty: # make each element go on a new line and indent by 2 kwargs.update(default_flow_style=False, indent=2)