From 582c7b50f7d1ef19b7fcb445eced8b9075b60054 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 2 Jul 2020 12:00:00 +0200 Subject: [PATCH] Do not parse list in rich_text_snippet --- src/pretix/base/templatetags/rich_text.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/pretix/base/templatetags/rich_text.py b/src/pretix/base/templatetags/rich_text.py index 4e32a1967..08fc16a41 100644 --- a/src/pretix/base/templatetags/rich_text.py +++ b/src/pretix/base/templatetags/rich_text.py @@ -109,15 +109,25 @@ def markdown_compile_email(source): )) +class SnippetExtension(markdown.extensions.Extension): + def extendMarkdown(self, md, *args, **kwargs): + del md.parser.blockprocessors['olist'] + del md.parser.blockprocessors['ulist'] + del md.parser.blockprocessors['quote'] + + def markdown_compile(source, snippet=False): tags = ALLOWED_TAGS_SNIPPET if snippet else ALLOWED_TAGS + exts = [ + 'markdown.extensions.sane_lists', + 'markdown.extensions.nl2br' + ] + if snippet: + exts.append(SnippetExtension()) return bleach.clean( markdown.markdown( source, - extensions=[ - 'markdown.extensions.sane_lists', - 'markdown.extensions.nl2br' - ] + extensions=exts ), strip=snippet, tags=tags,