diff --git a/templar/markdown.py b/templar/markdown.py
index 36a6d78..ef67218 100644
--- a/templar/markdown.py
+++ b/templar/markdown.py
@@ -70,6 +70,7 @@ def preprocess(text, markdown_obj):
text, references = get_references(text)
text = remove_pandoc_comments(text)
text = handle_whitespace(text)
+ text = space_out_block_tags(text)
return text, variables, references, footnotes
TAB_SIZE = 4
@@ -228,6 +229,13 @@ def get_footnote_backreferences(text, markdown_obj):
def remove_pandoc_comments(text):
return re_pandoc_comment.sub('', text)
+re_block_tag = re.compile(r"""
+ (\n|\A)[^\n]*?<\s*/?\s*block\s+[^\n]+?\s*>.*?(\n|\Z)
+""", re.X | re.S)
+def space_out_block_tags(text):
+ return re_block_tag.sub(lambda m: '\n' + m.group(0) + '\n', text)
+
+
######################
# Hashed Conversions #
diff --git a/tests/test_markdown/test_tag.py b/tests/test_markdown/test_tag.py
index b842d91..a6b2e5f 100644
--- a/tests/test_markdown/test_tag.py
+++ b/tests/test_markdown/test_tag.py
@@ -62,6 +62,24 @@ def testPrecedingParagraph(self):
"""
self.assertMarkdown(text, expect)
+ def testBlockTagInParagraphs(self):
+ text = """
+ Stuff here
+
Stuff here
+ +This is a paragraph.
+ +