mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-08 23:58:15 -05:00
helper/template_helper
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
import bleach
|
import bleach
|
||||||
import markdown as md
|
import markdown as md
|
||||||
from bleach_whitelist import markdown_tags, markdown_attrs
|
from bleach_whitelist import markdown_attrs, markdown_tags
|
||||||
from jinja2 import Template, TemplateSyntaxError
|
|
||||||
|
|
||||||
from cookbook.helper.mdx_attributes import MarkdownFormatExtension
|
from cookbook.helper.mdx_attributes import MarkdownFormatExtension
|
||||||
from cookbook.helper.mdx_urlize import UrlizeExtension
|
from cookbook.helper.mdx_urlize import UrlizeExtension
|
||||||
|
from jinja2 import Template, TemplateSyntaxError
|
||||||
|
|
||||||
|
|
||||||
class IngredientObject(object):
|
class IngredientObject(object):
|
||||||
@@ -45,8 +44,16 @@ def render_instructions(step): # TODO deduplicate markdown cleanup code
|
|||||||
except TemplateSyntaxError:
|
except TemplateSyntaxError:
|
||||||
instructions = step.instruction
|
instructions = step.instruction
|
||||||
|
|
||||||
tags = markdown_tags + ['pre', 'table', 'td', 'tr', 'th', 'tbody', 'style', 'thead']
|
tags = markdown_tags + [
|
||||||
parsed_md = md.markdown(instructions, extensions=['markdown.extensions.fenced_code', 'tables', UrlizeExtension(), MarkdownFormatExtension()])
|
'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']
|
markdown_attrs['*'] = markdown_attrs['*'] + ['class']
|
||||||
|
|
||||||
return bleach.clean(parsed_md, tags, markdown_attrs)
|
return bleach.clean(parsed_md, tags, markdown_attrs)
|
||||||
|
|||||||
Reference in New Issue
Block a user