summaryrefslogtreecommitdiff
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
parent8515cf0bca030f732ee40645328cf20f22c1f4bc (diff)
downloadruamel.yaml-ff73e0fb35a923af7d9c372068236d7ee3cca253.tar.gz
fix #96: RT indented mapping with empty line0.13.12
-rw-r--r--README.rst6
-rw-r--r--__init__.py5
-rw-r--r--scanner.py12
3 files changed, 15 insertions, 8 deletions
diff --git a/README.rst b/README.rst
index fcc517a..c4803e4 100644
--- a/README.rst
+++ b/README.rst
@@ -18,10 +18,14 @@ ChangeLog
.. should insert NEXT: at the beginning of line for next key
+0.13.12 (2017-01-28):
+ - fix for issue 96: prevent insertion of extra empty line if indented mapping entries
+ are separated by an empty line. Reported by Derrick Sawyer
+
0.13.11 (2017-01-23):
- allow ':' in flow style scalars if not followed by space. Also don't
quote such scalar as this is no longer necessary.
- - add python 3.6 manylinux wheel to PyPI
+ - add python 3.6 manylinux wheel to PyPI
0.13.10 (2017-01-22):
- fix for issue 93, insert spurious blank line before single line comment
diff --git a/__init__.py b/__init__.py
index 4cbf3b2..117b8ea 100644
--- a/__init__.py
+++ b/__init__.py
@@ -1,7 +1,6 @@
# coding: utf-8
-from __future__ import print_function
-from __future__ import absolute_import
+from __future__ import print_function, absolute_import, division, unicode_literals
# install_requires of ruamel.base is not really required but the old
# ruamel.base installed __init__.py, and thus a new version should
@@ -9,7 +8,7 @@ from __future__ import absolute_import
_package_data = dict(
full_package_name="ruamel.yaml",
- version_info=(0, 13, 11),
+ version_info=(0, 13, 12),
author="Anthon van der Neut",
author_email="a.van.der.neut@ruamel.eu",
description="ruamel.yaml is a YAML parser/emitter that supports roundtrip preservation of comments, seq/map flow style, and map key order", # NOQA
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