You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seems like there is a missing filter in autodoc_default.html , which results in error like: raise TemplateAssertionError(msg, lineno, self.name, self.filename) jinja2.exceptions.TemplateAssertionError: no filter named 'nl2br'
Workaround for this is to add into Flask app:
@app.template_filter()
@evalcontextfilter
def nl2br(eval_ctx, value):
result = u'\n\n'.join(u'<p>%s</p>' % p.replace('\n', '<br>\n') \
for p in _paragraph_re.split(escape(value)))
if eval_ctx.autoescape:
result = Markup(result)
return result
Is this still a valid fix or has this issue been fixed in the autodoc package? I'm seeing this error but I can see this in the autodoc module:
def add_custom_nl2br_filters(self, app):
"""Add a custom filter nl2br to jinja2
Replaces all newline to <BR>
"""
_paragraph_re = re.compile(r'(?:\r\n|\r|\n){3,}')
@app.template_filter()
@evalcontextfilter
def nl2br(eval_ctx, value):
result = '\n\n'.join('%s' % p.replace('\n', '<br>\n')
for p in _paragraph_re.split(value))
return result
But I'm still getting the error. I'm not beyond saying that I've probably just screwed up something with my implementation of autodoc.
Ok, I sorted my issue. If anyone else is suffering from this. it looks like the nl2br function still isn't quite right but if you use the one detailed here - http://jinja.pocoo.org/docs/2.10/api/#custom-filters then it made sure the were not being converted to <br>
Seems like there is a missing filter in autodoc_default.html , which results in error like:
raise TemplateAssertionError(msg, lineno, self.name, self.filename) jinja2.exceptions.TemplateAssertionError: no filter named 'nl2br'
Workaround for this is to add into Flask app:
Python 3.6
pip freeze:
Flask==0.12.2
Jinja2==2.9.6
Flask-Autodoc==0.1.2
The text was updated successfully, but these errors were encountered: