markdown: Fix unordered list not rendering in blockquote.

This fixes an issue where the hanging unordered list was not
rendering in blockquote; the problem was that we were not
adding an empty line(to satisfy the markdown) for hanging
unordered list if it is in blockquote. Both blockquote
and code block is fenced but we want to avoid rendering
the list if it's in the code block but not in blockquote.

Fixes: #11916.
This commit is contained in:
overide 2019-03-31 22:10:47 +05:30 committed by Tim Abbott
parent 5bf8917597
commit b263671c9e
2 changed files with 9 additions and 1 deletions

View File

@ -1411,9 +1411,11 @@ class BugdownUListPreprocessor(markdown.preprocessors.Preprocessor):
copy = lines[:]
for i in range(len(lines) - 1):
# Ignore anything that is inside a fenced code block
# but not quoted
m = FENCE_RE.match(lines[i])
if not fence and m:
fence = m.group('fence')
quote = m.group('lang') in ('quote', 'quoted')
fence = m.group('fence') and not quote
elif fence and m and fence == m.group('fence'):
fence = None

View File

@ -155,6 +155,12 @@
"expected_output": "<p>Plain list</p>\n<ul>\n<li>Alpha</li>\n<li>Beta</li>\n</ul>\n<p>And Again:</p>\n<ul>\n<li>A</li>\n<li>B</li>\n<li>C</li>\n</ul>\n<p>Once more for feeling:</p>\n<ul>\n<li>Q</li>\n<li>E</li>\n<li>D</li>\n</ul>",
"text_content": "Plain list\n\nAlpha\nBeta\n\nAnd Again:\n\nA\nB\nC\n\nOnce more for feeling:\n\nQ\nE\nD\n"
},
{
"name": "ulist_hanging_quoted",
"input": "```quote\nSome text with a hanging list inside quote:\n* one\n* two\n* three\n```",
"expected_output": "<blockquote>\n<p>Some text with a hanging list inside quote:</p>\n<ul>\n<li>one</li>\n<li>two</li>\n<li>three</li>\n</ul>\n</blockquote>",
"text_content": "> Some text with a hanging list inside quote:\n> one\n> two\n> three\n"
},
{
"name": "ulist_nested_ulist_two_space_indent",
"input": "Nested list\n* I am outer list\n * I am inner nested list first item\n * I am inner nested list second item",