[#4771] ticket:635 Fix TOC generation for included pages
diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py
index 055a74a..e4ca61c 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -412,6 +412,12 @@
def handleMatch(self, m):
html = self.macro(m.group(2))
+ if m.group(2).startswith('include'):
+ # etree.fromstring parses html with newlines into empty div somehow
+ html = [l.strip() for l in html.splitlines() if l.strip()]
+ html = ''.join(html)
+ return markdown.util.etree.fromstring(html)
+
placeholder = self.markdown.htmlStash.store(html)
return placeholder