summaryrefslogtreecommitdiff
path: root/emitter.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2021-03-26 11:20:38 +0100
committerAnthon van der Neut <anthon@mnt.org>2021-03-26 11:20:38 +0100
commit09f8576ae990234daebf51cca48b52d564f2c2d2 (patch)
treee08953ec5547d9ed05373a3134c3557f6ebf11c6 /emitter.py
parente8719cd39655d98cf2bde1be15366cca7a58fd89 (diff)
downloadruamel.yaml-09f8576ae990234daebf51cca48b52d564f2c2d2.tar.gz
remove support for 2.7, prepare for f-strings0.17.0
Diffstat (limited to 'emitter.py')
-rw-r--r--emitter.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/emitter.py b/emitter.py
index f5313a0..9f37906 100644
--- a/emitter.py
+++ b/emitter.py
@@ -897,8 +897,22 @@ class Emitter(object):
self.write_single_quoted(self.analysis.scalar, split)
elif self.style == '>':
self.write_folded(self.analysis.scalar)
+ if (
+ self.event.comment
+ and self.event.comment[0]
+ and self.event.comment[0].column >= self.indent
+ ):
+ # comment following a folded scalar must dedent (issue 376)
+ self.event.comment[0].column = self.indent - 1
elif self.style == '|':
self.write_literal(self.analysis.scalar, self.event.comment)
+ if (
+ self.event.comment
+ and self.event.comment[0]
+ and self.event.comment[0].column >= self.indent
+ ):
+ # comment following a literal scalar must dedent (issue 376)
+ self.event.comment[0].column = self.indent - 1
else:
self.write_plain(self.analysis.scalar, split)
self.analysis = None
@@ -926,9 +940,7 @@ class Emitter(object):
_F("tag handle must start and end with '!': {handle!r}", handle=handle)
)
for ch in handle[1:-1]:
- if not (
- '0' <= ch <= '9' or 'A' <= ch <= 'Z' or 'a' <= ch <= 'z' or ch in '-_'
- ):
+ if not ('0' <= ch <= '9' or 'A' <= ch <= 'Z' or 'a' <= ch <= 'z' or ch in '-_'):
raise EmitterError(
_F(
'invalid character {ch!r} in the tag handle: {handle!r}',