helper/template_helper

This commit is contained in:
Tobias Lindenberg
2021-01-10 13:57:51 +01:00
parent 1ad468e652
commit eb9b2ac6fe

View File

@@ -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)