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

Fix nesting of raw and verbatim tags in Jinja/Twig lexers #1552

Merged
merged 3 commits into from Jul 4, 2020

Conversation

pyrmont
Copy link
Contributor

@pyrmont pyrmont commented Jun 19, 2020

The current Jinja lexer ends a raw or verbatim block when the lexer encounters either endraw or endverbatim. This behaviour is incorrect. The block should only end with a matching tag.

This fixes #1166.

@pyrmont pyrmont added the needs-review The PR needs to be reviewed label Jun 19, 2020
@pyrmont pyrmont self-assigned this Jun 19, 2020
@pyrmont pyrmont closed this Jun 19, 2020
@pyrmont
Copy link
Contributor Author

pyrmont commented Jun 19, 2020

@stof Sorry this took so long! I realise that Twig hasn't supported raw for some time but for backwards compatibility, I've left it in there. How does it look to you?

@pyrmont pyrmont reopened this Jun 19, 2020
@stof
Copy link

stof commented Jun 23, 2020

Looks good to me. Thus, it will still allow highlighting Twig 1.x templates properly (and it should not cause issues for modern Twig templates, as it is very unlikely that projects will create a custom {% raw %} tag with a different behavior)

@pyrmont
Copy link
Contributor Author

pyrmont commented Jul 4, 2020

@stof Great! I'll merge it in now and it'll be part of v3.21.0 of Rouge. That will be released on Tuesday 14 July 🎉

@pyrmont pyrmont merged commit a507bd6 into rouge-ruby:master Jul 4, 2020
@pyrmont pyrmont deleted the bugfix.jinja-nested-verbatim branch July 4, 2020 06:16
@pyrmont pyrmont removed the needs-review The PR needs to be reviewed label Jul 4, 2020
mattt pushed a commit to NSHipster/rouge that referenced this pull request May 19, 2021
…#1552)

The current Jinja lexer ends a `raw` or `verbatim` block when the lexer
encounters either `endraw` or `endverbatim`. This behaviour is
incorrect. The block should only end with a matching tag. This commit
fixes that behaviour.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nesting of raw and verbatim is not handled properly for Jinja/Twig
2 participants