diff --git a/lib/markdown2.py b/lib/markdown2.py
index fdc01309..380b36d3 100755
--- a/lib/markdown2.py
+++ b/lib/markdown2.py
@@ -833,6 +833,11 @@ def _detab(self, text):
_block_tags_b = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math'
_block_tags_b += _html5tags
+ _span_tags = (
+ 'a|abbr|acronym|b|bdo|big|br|button|cite|code|dfn|em|i|img|input|kbd|label|map|object|output|q'
+ '|samp|script|select|small|span|strong|sub|sup|textarea|time|tt|var'
+ )
+
_liberal_tag_block_re = re.compile(r"""
( # save in \1
^ # start of line (with re.M)
@@ -927,6 +932,14 @@ def _hash_html_blocks(self, text, raw=False):
# Now match more liberally, simply from `\n` to `\n`
text = self._liberal_tag_block_re.sub(hash_html_block_sub, text)
+ # now do the same for spans that are acting like blocks
+ # eg: an anchor split over multiple lines for readability
+ text = self._strict_tag_block_sub(
+ text, self._span_tags,
+ # inline elements can't contain block level elements, so only span gamut is required
+ lambda t: hash_html_block_sub(self._run_span_gamut(t))
+ )
+
# Special case just for
. It was easier to make a special
# case than to make the other regex more complicated.
if "
+
+
+
+Some markdown text as well, but no block level elements, since we're still inside a span
+
+
diff --git a/test/tm-cases/block_like_spans.text b/test/tm-cases/block_like_spans.text
new file mode 100644
index 00000000..c715406f
--- /dev/null
+++ b/test/tm-cases/block_like_spans.text
@@ -0,0 +1,7 @@
+
+
+
+
+Some **markdown** text as well, but _no_ block level elements, since we're still [inside a span](https://google.com)
+
+