diff options
author | Anthon van der Neut <anthon@mnt.org> | 2018-08-05 12:27:52 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2018-08-05 12:27:52 +0200 |
commit | 06ea5a9886a6abb88b7a81481c6600477088f2c6 (patch) | |
tree | c8f72ab953eab349348714b2f5b65ce5356622d6 /representer.py | |
parent | 9b15f5f59e52ce2257a579900d8315cd7d46e4c9 (diff) | |
download | ruamel.yaml-06ea5a9886a6abb88b7a81481c6600477088f2c6.tar.gz |
leading empty lines and comments on root level literal scalars not preserved0.15.49
added test, fixed both now you can have
--- !some_tag | # with a comment
this is a multi-
line literal scalar
Diffstat (limited to 'representer.py')
-rw-r--r-- | representer.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/representer.py b/representer.py index 7b821fe..07b2535 100644 --- a/representer.py +++ b/representer.py @@ -148,7 +148,12 @@ class BaseRepresenter(object): # type: (Any, Any, Any) -> Any if style is None: style = self.default_style - node = ScalarNode(tag, value, style=style) + comment = None + if style and style[0] == '|': + comment = getattr(value, 'comment', None) + if comment: + comment = [None, [comment]] + node = ScalarNode(tag, value, style=style, comment=comment) if self.alias_key is not None: self.represented_objects[self.alias_key] = node return node |