summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_test/test_literal.py12
-rw-r--r--emitter.py9
2 files changed, 17 insertions, 4 deletions
diff --git a/_test/test_literal.py b/_test/test_literal.py
index 698ece5..a9b34e1 100644
--- a/_test/test_literal.py
+++ b/_test/test_literal.py
@@ -217,6 +217,18 @@ class TestNoIndent:
print(type(d), repr(d))
yaml.round_trip(inp)
+ def test_nested_literal_doc_indent_marker(self):
+ yaml = YAML()
+ yaml.explicit_start = True
+ inp = """
+ ---
+ a: |2
+ some more
+ text
+ """
+ d = yaml.load(inp)
+ print(type(d), repr(d))
+ yaml.round_trip(inp)
class Test_RoundTripLiteral:
def test_rt_root_literal_scalar_no_indent(self):
diff --git a/emitter.py b/emitter.py
index 5bac4ae..b739a28 100644
--- a/emitter.py
+++ b/emitter.py
@@ -1485,10 +1485,11 @@ class Emitter(object):
self.write_line_break()
else:
self.write_line_break(br)
- if ch is not None and (not self.root_context or self.requested_indent):
- self.write_indent()
- if ch is not None and _indent:
- self.stream.write(u' ' * _indent)
+ if ch is not None:
+ if _indent:
+ self.stream.write(u' ' * _indent)
+ elif not self.root_context or self.requested_indent:
+ self.write_indent()
start = end
else:
if ch is None or ch in u'\n\x85\u2028\u2029':