Skip to content

Commit

Permalink
fix: resolve recursion limit issue in Nunjucks syntax (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
alsolovyev committed Dec 30, 2024
1 parent ef3c78d commit 1485921
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 75 deletions.
9 changes: 9 additions & 0 deletions Messages/2.0.3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The Nunjucks package has been successfully updated to version 2.0.3

Fixes:
- resolved recursion limit issue ("Apparent recursion within a with_prototype action: 25000 context sanity limit hit")
- improved compatibility with HTML syntax highlighting


Please report issues here: https://github.com/alsolovyev/Nunjucks/issues
Created by janeRivas <[email protected]>
31 changes: 5 additions & 26 deletions Syntaxes/Nunjucks PHP.sublime-syntax
Original file line number Diff line number Diff line change
@@ -1,34 +1,13 @@
%YAML 1.2
---
name: Nunjucks PHP
version: 2
scope: text.html.njk.php
extends: Packages/PHP/PHP.sublime-syntax


contexts:
main:
- match: ''
push: scope:text.html.njk
with_prototype:
#
# PHP
#
- match: '<\?(?i:php|=)?(?![^?]*\?>)'
scope: punctuation.section.embedded.begin.php
push:
- meta_content_scope: source.php
- include: 'scope:source.php'
with_prototype:
- match: (?=\?>)(\?>)
captures:
0: punctuation.section.embedded.end.php
pop: true
- meta_prepend: false
- include: Nunjucks.sublime-syntax

- match: '<\?(?i:php|=)?'
scope: punctuation.section.embedded.begin.php
push:
- meta_content_scope: source.php.njk
- include: 'scope:source.php'
with_prototype:
- match: (?=\?>)(\?>)
captures:
0: punctuation.section.embedded.end.php
pop: true
95 changes: 47 additions & 48 deletions Syntaxes/Nunjucks.sublime-syntax
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
%YAML 1.2
---
name: Nunjucks
version: 2
scope: text.html.njk
extends: Packages/HTML/HTML.sublime-syntax
file_extensions:
- njk
- nunjucks
scope: text.html.njk


variables:
Expand Down Expand Up @@ -39,53 +41,50 @@ variables:

contexts:
main:
- match: ''
push: scope:text.html.basic
with_prototype:
# Statement Block
- match: '\{%-?'
scope: punctuation.statement.begin.njk
push:
- meta_scope: meta.statement.njk
- match: '-?%\}'
scope: punctuation.statement.end.njk
pop: true
- include: nunjucks-strings
- include: nunjucks-punctuation
- include: nunjucks-parentheses
- include: nunjucks-numeric
- include: nunjucks-operators
- include: nunjucks-keywords
- include: nunjucks-filters
- include: nunjucks-macros
- include: nunjucks-variables

# Expression Block
- match: '\{\{-?'
scope: punctuation.expression.begin.njk
push:
- meta_scope: meta.expression.njk
- match: '-?\}\}'
scope: punctuation.expression.end.njk
pop: true
- include: nunjucks-strings
- include: nunjucks-punctuation
- include: nunjucks-parentheses
- include: nunjucks-numeric
- include: nunjucks-operators
- include: nunjucks-keywords
- include: nunjucks-filters
- include: nunjucks-macros
- include: nunjucks-variables

# Comment Block
- match: '{#-?'
scope: punctuation.definition.comment.begin.njk
push:
- meta_scope: comment.block.njk
- match: '-?#}'
scope: punctuation.definition.comment.end.njk
pop: true
- meta_prepend: true
- match: '\{%-?'
scope: punctuation.statement.begin.njk
push:
- meta_scope: meta.statement.njk
- match: '-?%\}'
scope: punctuation.statement.end.njk
pop: true
- include: nunjucks-strings
- include: nunjucks-punctuation
- include: nunjucks-parentheses
- include: nunjucks-numeric
- include: nunjucks-operators
- include: nunjucks-keywords
- include: nunjucks-filters
- include: nunjucks-macros
- include: nunjucks-variables

# Expression Block
- match: '\{\{-?'
scope: punctuation.expression.begin.njk
push:
- meta_scope: meta.expression.njk
- match: '-?\}\}'
scope: punctuation.expression.end.njk
pop: true
- include: nunjucks-strings
- include: nunjucks-punctuation
- include: nunjucks-parentheses
- include: nunjucks-numeric
- include: nunjucks-operators
- include: nunjucks-keywords
- include: nunjucks-filters
- include: nunjucks-macros
- include: nunjucks-variables

# Comment Block
- match: '{#-?'
scope: punctuation.definition.comment.begin.njk
push:
- meta_scope: comment.block.njk
- match: '-?#}'
scope: punctuation.definition.comment.end.njk
pop: true


# Nunjucks Includes
Expand Down
3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"install": "Messages/install.txt",
"2.0.1": "Messages/2.0.1.txt"
"2.0.1": "Messages/2.0.1.txt",
"2.0.3": "Messages/2.0.3.txt"
}

0 comments on commit 1485921

Please sign in to comment.