diff options
author | Anthon van der Neut <anthon@mnt.org> | 2021-03-05 08:11:32 +0100 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2021-03-05 08:11:32 +0100 |
commit | 1c31c7f46cfbc1f363c793f7bdf42c9f5fa239c6 (patch) | |
tree | edc414926de0c4611dcf875a00ab37d5254203f8 /comments.py | |
parent | 4f1ad1c392bd557405e9901c5b8750d12a4f1260 (diff) | |
download | ruamel.yaml-1c31c7f46cfbc1f363c793f7bdf42c9f5fa239c6.tar.gz |
fix #371
Diffstat (limited to 'comments.py')
-rw-r--r-- | comments.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/comments.py b/comments.py index a091d37..13a519e 100644 --- a/comments.py +++ b/comments.py @@ -230,7 +230,10 @@ class CommentedBase(object): comment = comment[:-1] # strip final newline if there start_mark = CommentMark(indent) for com in comment.split('\n'): - pre_comments.append(CommentToken('# ' + com + '\n', start_mark, None)) + c = com.strip() + if len(c) > 0 and c[0] != '#': + com = '# ' + com + pre_comments.append(CommentToken(com + '\n', start_mark, None)) def yaml_set_comment_before_after_key( self, key, before=None, indent=0, after=None, after_indent=None |