diff --git a/hamlpy/nodes.py b/hamlpy/nodes.py index 89daabe..a5e7e4a 100644 --- a/hamlpy/nodes.py +++ b/hamlpy/nodes.py @@ -593,10 +593,14 @@ def _render(self): if self.children: if not _markdown_available: raise NotAvailableError("Markdown is not available") - self.before = self.render_newlines()[1:] indent_offset = len(self.children[0].spaces) - text = ''.join(''.join([c.spaces[indent_offset:], c.haml, c.render_newlines()]) for c in self.children) - self.before += markdown(text) + lines = [] + for c in self.children: + haml = c.raw_haml.lstrip() + if haml[-1] == '\n': + haml = haml[:-1] + lines.append(c.spaces[indent_offset:] + haml + c.render_newlines()) + self.before += markdown( ''.join(lines)) else: self.after = self.render_newlines() diff --git a/hamlpy/test/templates/filtersMarkdown.hamlpy b/hamlpy/test/templates/filtersMarkdown.hamlpy index c97726c..becf36a 100644 --- a/hamlpy/test/templates/filtersMarkdown.hamlpy +++ b/hamlpy/test/templates/filtersMarkdown.hamlpy @@ -2,6 +2,9 @@ hello no paragraph + line break + follow + New paragraph - test + code block diff --git a/hamlpy/test/templates/filtersMarkdown.html b/hamlpy/test/templates/filtersMarkdown.html index 49f148a..1b1a9a8 100644 --- a/hamlpy/test/templates/filtersMarkdown.html +++ b/hamlpy/test/templates/filtersMarkdown.html @@ -1,5 +1,7 @@

hello no paragraph

+

line break
+follow

New paragraph

-
test
-
+
code block
+
\ No newline at end of file