From eb9b2ac6fe59513b882ff17b30dc287999d180f5 Mon Sep 17 00:00:00 2001 From: Tobias Lindenberg Date: Sun, 10 Jan 2021 13:57:51 +0100 Subject: [PATCH] helper/template_helper --- cookbook/helper/template_helper.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cookbook/helper/template_helper.py b/cookbook/helper/template_helper.py index 358e9e81b..48c6aa9f1 100644 --- a/cookbook/helper/template_helper.py +++ b/cookbook/helper/template_helper.py @@ -1,10 +1,9 @@ import bleach import markdown as md -from bleach_whitelist import markdown_tags, markdown_attrs -from jinja2 import Template, TemplateSyntaxError - +from bleach_whitelist import markdown_attrs, markdown_tags from cookbook.helper.mdx_attributes import MarkdownFormatExtension from cookbook.helper.mdx_urlize import UrlizeExtension +from jinja2 import Template, TemplateSyntaxError class IngredientObject(object): @@ -45,8 +44,16 @@ def render_instructions(step): # TODO deduplicate markdown cleanup code except TemplateSyntaxError: instructions = step.instruction - tags = markdown_tags + ['pre', 'table', 'td', 'tr', 'th', 'tbody', 'style', 'thead'] - parsed_md = md.markdown(instructions, extensions=['markdown.extensions.fenced_code', 'tables', UrlizeExtension(), MarkdownFormatExtension()]) + tags = markdown_tags + [ + 'pre', 'table', 'td', 'tr', 'th', 'tbody', 'style', 'thead' + ] + parsed_md = md.markdown( + instructions, + extensions=[ + 'markdown.extensions.fenced_code', 'tables', + UrlizeExtension(), MarkdownFormatExtension() + ] + ) markdown_attrs['*'] = markdown_attrs['*'] + ['class'] return bleach.clean(parsed_md, tags, markdown_attrs)