summaryrefslogtreecommitdiff
path: root/scanner.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2017-01-28 09:44:09 +0100
committerAnthon van der Neut <anthon@mnt.org>2017-01-28 09:44:09 +0100
commitff73e0fb35a923af7d9c372068236d7ee3cca253 (patch)
treefcc8218663222eb5e771507f1678daf55036fe64 /scanner.py
parent8515cf0bca030f732ee40645328cf20f22c1f4bc (diff)
downloadruamel.yaml-ff73e0fb35a923af7d9c372068236d7ee3cca253.tar.gz
fix #96: RT indented mapping with empty line0.13.12
Diffstat (limited to 'scanner.py')
-rw-r--r--scanner.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/scanner.py b/scanner.py
index ce12500..a925fc3 100644
--- a/scanner.py
+++ b/scanner.py
@@ -1,7 +1,6 @@
# coding: utf-8
-from __future__ import absolute_import
-from __future__ import print_function
+from __future__ import print_function, absolute_import, division, unicode_literals
# Scanner produces tokens of the following types:
# STREAM-START
@@ -1326,7 +1325,7 @@ class Scanner(object):
def scan_plain(self):
# See the specification for details.
# We add an additional restriction for the flow context:
- # plain scalars in the flow context cannot contain ',', ':' and '?'.
+ # plain scalars in the flow context cannot contain ',', ': ' and '?'.
# We also keep track of the `allow_simple_key` flag here.
# Indentation rules are loosed for the flow context.
chunks = []
@@ -1596,8 +1595,13 @@ class RoundTripScanner(Scanner):
self.tokens_taken += 1
return self.tokens.pop(0)
- def fetch_comment(self, comment): # XXXX
+ def fetch_comment(self, comment):
value, start_mark, end_mark = comment
+ while value and value[-1] == u' ':
+ # empty line within indented key context
+ # no need to update end-mark, that is not used
+ value = value[:-1]
+ print('comment', repr(value))
self.tokens.append(CommentToken(value, start_mark, end_mark))
# scanner