diff --git a/ansibledoctor/annotation.py b/ansibledoctor/annotation.py index a2c86c4..5d620bb 100644 --- a/ansibledoctor/annotation.py +++ b/ansibledoctor/annotation.py @@ -131,7 +131,8 @@ class Annotation: multiline = [] stars_with_annotation = r"(\#\ *[\@][\w]+)" current_file_position = self._file_handler.tell() - newline = "" + before = "" + after = "" while True: next_line = self._file_handler.readline().lstrip() @@ -154,17 +155,23 @@ class Annotation: final = re.findall(r"\#(.*)", next_line)[0].rstrip() if final[:1] == " ": final = final[1:] - final = newline + final + final = before + final # match if empty line or commented empty line test_line = next_line.replace("#", "").strip() if len(test_line) == 0: - newline = "\n\n" + before = "\n\n" continue else: - newline = "" + before = "" - multiline.append(newline + final) + if test_line.endswith("\\"): + final = final.rstrip("\\").strip() + after = "\n" + else: + after = "" + + multiline.append(before + final + after) if parts[2].startswith("$"): source = "".join([x.strip() for x in multiline]) diff --git a/ansibledoctor/doc_generator.py b/ansibledoctor/doc_generator.py index 9cd738a..5bf72ce 100644 --- a/ansibledoctor/doc_generator.py +++ b/ansibledoctor/doc_generator.py @@ -160,9 +160,11 @@ class Generator: if isinstance(value, str): value = [value] - joined = jinja2.filters.do_join(eval_ctx, value, d, attribute=None) - nornalized = re.sub(r" +(\n|\t| )", "\\1", joined) - return nornalized + normalized = jinja2.filters.do_join(eval_ctx, value, d, attribute=None) + for s in [r" +(\n|\t| )", r"(\n|\t) +"]: + normalized = re.sub(s, "\\1", normalized) + + return normalized def render(self): self.logger.info("Using output dir: " + self.config.config.get("output_dir"))