summaryrefslogtreecommitdiff
path: root/scanner.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2017-02-12 17:55:11 +0100
committerAnthon van der Neut <anthon@mnt.org>2017-02-12 17:55:11 +0100
commit42045042017443f395a97b134516672d56766732 (patch)
tree764999c10468ed0ddedeceb2024c0c44012f63b8 /scanner.py
parentbbd2e8ac8fb9ba2aee8b8f95cc5e9c05d46b79cd (diff)
downloadruamel.yaml-42045042017443f395a97b134516672d56766732.tar.gz
fix #99: no RT on block scalar + empty line + comment0.13.14
Diffstat (limited to 'scanner.py')
-rw-r--r--scanner.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/scanner.py b/scanner.py
index 95e9d0a..51f6cb9 100644
--- a/scanner.py
+++ b/scanner.py
@@ -1070,22 +1070,28 @@ class Scanner(object):
# Process trailing line breaks. The 'chomping' setting determines
# whether they are included in the value.
- comment = []
+ trailing = []
if chomping in [None, True]:
chunks.append(line_break)
if chomping is True:
chunks.extend(breaks)
elif chomping in [None, False]:
- comment.extend(breaks)
+ trailing.extend(breaks)
# We are done.
- token = ScalarToken(u''.join(chunks), False, start_mark, end_mark,
- style)
- if len(comment) > 0:
- # Keep track of the trailing whitespace as a comment token, if
- # isn't all included in the actual value.
+ token = ScalarToken(u''.join(chunks), False, start_mark, end_mark, style)
+ if len(trailing) > 0:
+ # print('trailing 1', trailing) # XXXXX
+ # Eat whitespaces and comments until we reach the next token.
+ comment = self.scan_to_next_token()
+ while comment:
+ trailing.append(comment[0])
+ comment = self.scan_to_next_token()
+
+ # Keep track of the trailing whitespace and following comments
+ # as a comment token, if isn't all included in the actual value.
comment_end_mark = self.get_mark()
- comment = CommentToken(''.join(comment), end_mark,
+ comment = CommentToken(''.join(trailing), end_mark,
comment_end_mark)
token.add_post_comment(comment)
return token