summaryrefslogtreecommitdiff
path: root/constructor.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2018-08-05 12:27:52 +0200
committerAnthon van der Neut <anthon@mnt.org>2018-08-05 12:27:52 +0200
commit06ea5a9886a6abb88b7a81481c6600477088f2c6 (patch)
treec8f72ab953eab349348714b2f5b65ce5356622d6 /constructor.py
parent9b15f5f59e52ce2257a579900d8315cd7d46e4c9 (diff)
downloadruamel.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 'constructor.py')
-rw-r--r--constructor.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/constructor.py b/constructor.py
index 6a26da3..c830580 100644
--- a/constructor.py
+++ b/constructor.py
@@ -979,7 +979,10 @@ class RoundTripConstructor(SafeConstructor):
)
if node.style == '|' and isinstance(node.value, text_type):
- return PreservedScalarString(node.value)
+ pss = PreservedScalarString(node.value)
+ if node.comment and node.comment[1]:
+ pss.comment = node.comment[1][0]
+ return pss
elif bool(self._preserve_quotes) and isinstance(node.value, text_type):
if node.style == "'":
return SingleQuotedScalarString(node.value)