urubu
urubu copied to clipboard
Jinja2 exceptions in fenced code block
The attached markdown file (bug.zip) results in following error because of "{{{" "}}}" in fenced code blocks:
Traceback (most recent call last):
File "/usr/lib64/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/lib/python2.7/site-packages/urubu/__main__.py", line 20, in <module>
main.main()
File "/usr/lib/python2.7/site-packages/urubu/main.py", line 51, in main
project.build()
File "/usr/lib/python2.7/site-packages/urubu/project.py", line 489, in build
proj.make_site()
File "/usr/lib/python2.7/site-packages/urubu/project.py", line 470, in make_site
self.process_content()
File "/usr/lib/python2.7/site-packages/urubu/project.py", line 476, in process_content
p.process()
File "/usr/lib/python2.7/site-packages/urubu/processors.py", line 104, in process
self.convert()
File "/usr/lib/python2.7/site-packages/urubu/processors.py", line 120, in convert
raise UrubuError(str(exc), msg=msg, fn=fn)
urubu.UrubuError: in releasenotes/bug.md: <class 'jinja2.exceptions.TemplateSyntaxError'>: 'unexpected '}', expected ']''
Makefile:10: recipe for target 'build' failed
make: *** [build] Error 1
I could work around the issue by adding zero-width spaces between the braces
@heeckhau the problem is that Urubu allows templating code in the Markdown files as well. To do this, it needs to call Jinja twice: once before converting markdown to HTML, then again after the conversion. Jinja looks for {{ }}
to substitute with variables so any occurrence of it will cause an error.
You can use {% raw %} ... {% endraw %}
blocks around the code block to keep jinja from trying to process it as template code. See http://jinja.pocoo.org/docs/2.10/templates/#escaping
Probably related to this: http://urubu.jandecaluwe.com/manual/templating-in-pages.html#template-delimiters