From b263671c9e083deaef3bf9941effee60426b7a92 Mon Sep 17 00:00:00 2001 From: overide Date: Sun, 31 Mar 2019 22:10:47 +0530 Subject: [PATCH] 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. --- zerver/lib/bugdown/__init__.py | 4 +++- zerver/tests/fixtures/markdown_test_cases.json | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/bugdown/__init__.py index a38c95e9dd..a13c4c04c7 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/bugdown/__init__.py @@ -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 diff --git a/zerver/tests/fixtures/markdown_test_cases.json b/zerver/tests/fixtures/markdown_test_cases.json index 00f6006f3e..dbc27884a7 100644 --- a/zerver/tests/fixtures/markdown_test_cases.json +++ b/zerver/tests/fixtures/markdown_test_cases.json @@ -155,6 +155,12 @@ "expected_output": "

Plain list

\n\n

And Again:

\n\n

Once more for feeling:

\n", "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": "
\n

Some text with a hanging list inside quote:

\n\n
", + "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",