summaryrefslogtreecommitdiff
path: root/emitter.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2019-08-15 12:18:08 +0200
committerAnthon van der Neut <anthon@mnt.org>2019-08-15 12:18:08 +0200
commitff8e03fe5542a9d7930a5720450c59bb9e9eaaf3 (patch)
tree6f22060b92e421ca0bad2a2df0eb499518c4b07e /emitter.py
parentc355613aea4e2045fa5360837bd0b622fb84877b (diff)
downloadruamel.yaml-ff8e03fe5542a9d7930a5720450c59bb9e9eaaf3.tar.gz
preserve directives, optional push root level scalar to own line
You need to set YAML().scalar_after_indicator = False to get a single scalar document starting on its own line (instead of after the directives end indicator: --- abc") fixes issue #304 *When this change indeed resolves your problem, please **Close** this issue*. *(You can do so using the WorkFlow pull-down (close to the top right of this page))*
Diffstat (limited to 'emitter.py')
-rw-r--r--emitter.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/emitter.py b/emitter.py
index 14277fc..7cdebcd 100644
--- a/emitter.py
+++ b/emitter.py
@@ -204,6 +204,8 @@ class Emitter(object):
self.analysis = None # type: Any
self.style = None # type: Any
+ self.scalar_after_indicator = True # write a scalar on the same line as `---`
+
@property
def stream(self):
# type: () -> Any
@@ -408,6 +410,8 @@ class Emitter(object):
and self.sequence_context
):
self.sequence_context = False
+ if root and isinstance(self.event, ScalarEvent) and not self.scalar_after_indicator:
+ self.write_indent()
self.process_tag()
if isinstance(self.event, ScalarEvent):
# nprint('@', self.indention, self.no_newline, self.column)