Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountered unknown tag 'end' #5493

Closed
liesauer opened this issue Sep 26, 2018 · 3 comments
Closed

Encountered unknown tag 'end' #5493

liesauer opened this issue Sep 26, 2018 · 3 comments

Comments

@liesauer
Copy link

Problem

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/parser.py", line 59, in fail
raise exc(msg, lineno, self.name, self.filename)
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'end'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.

Procedure to reproduce the problem

make gettext

Error logs / results

# Sphinx version: 1.8.1
# Python version: 3.6.0 (CPython)
# Docutils version: 0.14 
# Jinja2 version: 2.10
# Last messages:
#   读取模板……[  4%] /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/alabaster/donate.html
#   
#   读取模板……[  6%] /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/alabaster/layout.html
#   
#   读取模板……[  8%] /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/alabaster/navigation.html
#   
#   读取模板……[ 10%] /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/alabaster/relations.html
#   
#   读取模板……[ 13%] /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/backends/web_backend/all_figures.html
#   
# Loaded extensions:
#   sphinx.ext.mathjax (1.8.1) from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/ext/mathjax.py
#   alabaster (0.7.11) from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/alabaster/__init__.py
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/cmd/build.py", line 304, in build_main
    app.build(args.force_all, filenames)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/application.py", line 341, in build
    self.builder.build_update()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 347, in build_update
    len(to_build))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/builders/gettext.py", line 258, in build
    self._extract_from_template()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sphinx/builders/gettext.py", line 252, in _extract_from_template
    for line, meth, msg in extract_translations(context):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/ext.py", line 214, in _extract
    source = self.environment.parse(source)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/environment.py", line 493, in parse
    self.handle_exception(exc_info, source_hint=source)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "<unknown>", line 31, in template
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/environment.py", line 497, in _parse
    return Parser(self, source, name, encode_filename(filename)).parse()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/parser.py", line 901, in parse
    result = nodes.Template(self.subparse(), lineno=1)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/parser.py", line 883, in subparse
    rv = self.parse_statement()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/parser.py", line 130, in parse_statement
    return getattr(self, 'parse_' + self.stream.current.value)()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/parser.py", line 199, in parse_for
    body = self.parse_statements(('name:endfor', 'name:else'))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/parser.py", line 165, in parse_statements
    result = self.subparse(end_tokens)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/parser.py", line 883, in subparse
    rv = self.parse_statement()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/parser.py", line 144, in parse_statement
    self.fail_unknown_tag(token.value, token.lineno)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/parser.py", line 97, in fail_unknown_tag
    return self._fail_ut_eof(name, self._end_token_stack, lineno)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/parser.py", line 90, in _fail_ut_eof
    self.fail(' '.join(message), lineno)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/parser.py", line 59, in fail
    raise exc(msg, lineno, self.name, self.filename)
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'end'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.

Environment info

  • OS: Mac
  • Python version: 3.6.0 (CPython)
  • Sphinx version: 1.8.1
@tk0miya
Copy link
Member

tk0miya commented Oct 1, 2018

It seems all_figures.html has broken because it uses {% end %}, not {% endfor %}.
https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/web_backend/all_figures.html#L31

@tk0miya tk0miya added this to the 1.8.2 milestone Oct 1, 2018
@tk0miya
Copy link
Member

tk0miya commented Oct 1, 2018

Note: It would be nice if we handle the exception and emit better error message.

tk0miya added a commit to tk0miya/sphinx that referenced this issue Oct 10, 2018
tk0miya added a commit to tk0miya/sphinx that referenced this issue Oct 10, 2018
tk0miya added a commit that referenced this issue Oct 12, 2018
…n_tmpl

Fix #5493: gettext: crashed with broken template
@tk0miya
Copy link
Member

tk0miya commented Oct 12, 2018

Now #5521 is merged. It simply warns about broken templates.
Thank you for reporting.

@tk0miya tk0miya closed this as completed Oct 12, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants