From 80d97b8bf7edfae72cfd3ab3d2cda5030160bbf4 Mon Sep 17 00:00:00 2001
From: Waylan Limberg
Date: Wed, 14 Oct 2020 16:07:30 -0400
Subject: [PATCH 1/2] Bring md_in_html behavior inline with base.
---
.../test_syntax/extensions/test_md_in_html.py | 46 +++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/tests/test_syntax/extensions/test_md_in_html.py b/tests/test_syntax/extensions/test_md_in_html.py
index 433cdd559..38020f1b4 100644
--- a/tests/test_syntax/extensions/test_md_in_html.py
+++ b/tests/test_syntax/extensions/test_md_in_html.py
@@ -390,6 +390,52 @@ def test_md1_nested_empty_block(self):
)
)
+ def test_md1_no_blank_line_before(self):
+ self.assertMarkdownRenders(
+ self.dedent(
+ """
+ A _Markdown_ paragraph with no blank line after.
+
+ A _Markdown_ paragraph in an HTML block with no blank line before.
+
+ """
+ ),
+ self.dedent(
+ """
+ A Markdown paragraph with no blank line after.
+
+
A Markdown paragraph in an HTML block with no blank line before.
+
+ """
+ )
+ )
+
+ def test_md1_no_line_break(self):
+ # The div here is parsed as a span-level element. Bad input equals bad output!
+ self.assertMarkdownRenders(
+ 'A _Markdown_ paragraph with no _line break_.
',
+ 'A Markdown paragraph with
no line break.
'
+ )
+
+ def test_md1_in_tail(self):
+ self.assertMarkdownRenders(
+ self.dedent(
+ """
+
+ A _Markdown_ paragraph in an HTML block in tail of previous element.
+
+ """
+ ),
+ self.dedent(
+ """
+
+
+
A Markdown paragraph in an HTML block in tail of previous element.
+
+ """
+ )
+ )
+
def test_md_span_paragraph(self):
self.assertMarkdownRenders(
'*foo*
',
From dcada156c96d26c7939c48935c13395618403538 Mon Sep 17 00:00:00 2001
From: Waylan Limberg
Date: Wed, 14 Oct 2020 16:08:25 -0400
Subject: [PATCH 2/2] Fix for no line break case.
---
markdown/extensions/md_in_html.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/markdown/extensions/md_in_html.py b/markdown/extensions/md_in_html.py
index 174224ab9..39b77f719 100644
--- a/markdown/extensions/md_in_html.py
+++ b/markdown/extensions/md_in_html.py
@@ -93,7 +93,7 @@ def handle_starttag(self, tag, attrs):
attrs = {key: value if value is not None else key for key, value in attrs}
state = self.get_state(tag, attrs)
- if self.inraw or (state in [None, 'off'] and not self.mdstack):
+ if self.inraw or (state in [None, 'off'] and not self.mdstack) or not self.at_line_start():
# fall back to default behavior
attrs.pop('markdown', None)
super().handle_starttag(tag, attrs)