aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--markdown/extensions/extra.py2
-rw-r--r--markdown/preprocessors.py6
-rw-r--r--tests/extensions-x-extra/raw-html.html14
-rw-r--r--tests/extensions-x-extra/raw-html.txt12
4 files changed, 32 insertions, 2 deletions
diff --git a/markdown/extensions/extra.py b/markdown/extensions/extra.py
index 4a2ffbf..e569029 100644
--- a/markdown/extensions/extra.py
+++ b/markdown/extensions/extra.py
@@ -44,6 +44,8 @@ class ExtraExtension(markdown.Extension):
def extendMarkdown(self, md, md_globals):
""" Register extension instances. """
md.registerExtensions(extensions, self.config)
+ # Turn on processing of markdown text within raw html
+ md.preprocessors['html_block'].markdown_in_raw = True
def makeExtension(configs={}):
return ExtraExtension(configs=dict(configs))
diff --git a/markdown/preprocessors.py b/markdown/preprocessors.py
index cbf40e3..b199f0a 100644
--- a/markdown/preprocessors.py
+++ b/markdown/preprocessors.py
@@ -227,7 +227,8 @@ class HtmlBlockPreprocessor(Preprocessor):
# if find closing tag
in_tag = False
if self.markdown_in_raw and 'markdown' in attrs.keys():
- start = items[0][:left_index]
+ start = re.sub(r'\smarkdown(=[\'"]?[^> ]*[\'"]?)?',
+ '', items[0][:left_index])
items[0] = items[0][left_index:]
end = items[-1][-len(right_tag)-2:]
items[-1] = items[-1][:-len(right_tag)-2]
@@ -243,7 +244,8 @@ class HtmlBlockPreprocessor(Preprocessor):
if items:
if self.markdown_in_raw and 'markdown' in attrs.keys():
- start = items[0][:left_index]
+ start = re.sub(r'\smarkdown(=[\'"]?[^> ]*[\'"]?)?',
+ '', items[0][:left_index])
items[0] = items[0][left_index:]
end = items[-1][-len(right_tag)-2:]
items[-1] = items[-1][:-len(right_tag)-2]
diff --git a/tests/extensions-x-extra/raw-html.html b/tests/extensions-x-extra/raw-html.html
new file mode 100644
index 0000000..b2a7c4d
--- /dev/null
+++ b/tests/extensions-x-extra/raw-html.html
@@ -0,0 +1,14 @@
+<div>
+
+<p><em>foo</em></p>
+</div>
+
+<div class="baz">
+
+<p><em>bar</em></p>
+</div>
+
+<div>
+
+<p><em>blah</em></p>
+</div> \ No newline at end of file
diff --git a/tests/extensions-x-extra/raw-html.txt b/tests/extensions-x-extra/raw-html.txt
new file mode 100644
index 0000000..284fe0c
--- /dev/null
+++ b/tests/extensions-x-extra/raw-html.txt
@@ -0,0 +1,12 @@
+<div markdown="1">_foo_</div>
+
+<div markdown=1 class="baz">
+_bar_
+</div>
+
+<div markdown>
+
+_blah_
+
+</div>
+