fix newline handling

This commit is contained in:
Robert Kaussow 2019-12-02 15:00:32 +01:00
parent 5da5539254
commit c5833fc12a
2 changed files with 13 additions and 11 deletions

View File

@ -119,9 +119,10 @@ class Annotation:
multiline = []
stars_with_annotation = r"(\#\ *[\@][\w]+)"
current_file_position = self._file_handler.tell()
newline = ""
while True:
next_line = self._file_handler.readline()
next_line = self._file_handler.readline().lstrip()
if not next_line.strip():
self._file_handler.seek(current_file_position)
@ -132,22 +133,22 @@ class Annotation:
self._file_handler.seek(current_file_position)
break
# match if empty line or commented empty line
test_line = next_line.replace("#", "").strip()
if len(test_line) == 0:
self._file_handler.seek(current_file_position)
break
# match if does not start with comment
test_line2 = next_line.strip()
if test_line2[:1] != "#":
self._file_handler.seek(current_file_position)
break
final = next_line.replace("#", "").rstrip()
if final[:1] == " ":
final = final[1:]
multiline.append(final)
final = newline + next_line.replace("#", "").strip()
# match if empty line or commented empty line
test_line = next_line.replace("#", "").strip()
if len(test_line) == 0:
newline = "\n\n"
continue
else:
newline = ""
multiline.append(newline + final)
if parts[2].startswith("$"):
source = "".join([x.strip() for x in multiline])

View File

@ -6,6 +6,7 @@ type: docs
---
{% endif %}
{% if description | deep_get(meta, "description.value") %}
{{ meta.description.value | save_join(" ") }}
{% endif %}