Sublime Forum

Loading Syntax File Error ... fixed, but not perfect

#1

When I installed the EJS2 package, an error occurred as below. How can I solve it?

Error loading syntax file “Packages/EJS 2/EJS.sublime-syntax”: Apparent recursion within a with_prototype action: 25000 context sanity limit hit

My environment:
SublimeText win-x64 4143 build (latest fourth edition)
EJS 2 package version: 1.4.7 (the latest version)

0 Likes

#2

Then, strangely enough, when I installed the same package in sublimetext 3, everything worked fine. what is going on?

My environment:
SublimeText win-x64 3211 build (latest third version)
EJS 2 package version: 1.4.7 (the latest version)

Conclusion: ST3 and ST4 are not fully compatible, and the same version of the plug-in package will have problems

Problematic plugin package

EJS, EJS2, Handlebars… and so on (the problem mainly occurs with the template engine)

0 Likes

#3

FWIW, there is a new EJS version available: https://packagecontrol.io/packages/EJS%202

0 Likes

#4

I spent a lot of time troubleshooting and finally found the problem: I modified something in the official JavaScript package.

My original intention of modifying the official JavaScript package was to allow ES6 template strings to support HTML syntax highlighting, which is a perfectly normal requirement. So wo made the following changes

JavaScript.sublime_syntax file in the official JavaScript package, around line 8

file_extensions:
    -js
    -cjs
    -mjs
    -htc

Explanation: I added the item -cjs, because the files with the .cjs suffix will be interpreted by Node with the CommonJS specification, and the files with the .mjs suffix will be interpreted by Node with the ES Module specification

The above modifications are just my minor modifications to the project. It will not cause EJS syntax parsing errors, the following content is the key to the problem

JavaScript.sublime_syntax file in the official JavaScript package, around line 1133

literal-string-template-content:
     - meta_include_prototype: false
     - meta_scope: meta.string.js string.quoted.other.js text.html.basic.embedded.js
     - match: \`
       scope: punctuation.definition.string.end.js
       pop: 1
     - include: string-interpolations
     - include: string-content
     - include: scope:text.html.basic

The bold content above is something I added but not officially available. It will allow ES6 template strings to have the ability to highlight HTML syntax, but it will cause syntax parsing errors in EJS2.

So the final question is, how can I get syntax highlighting for ES6 template strings and be compatible with the syntax parsing of EJS2 packages?

0 Likes

#5

FWIW, there is a new EJS version available: https://packagecontrol.io/packages/EJS%202

Thanks for the reminder, after I submitted an issure yesterday, the plugin author immediately updated the version, which surprised me

Because today in 2023, various template engines are no longer popular, and the speed of problem repair should not be so fast. Many people prefer to use React, Vue, Angular ,Svelte, Solid … and so on

0 Likes