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

Loading Syntax File Error … or No Error? #5

Open
sunnyAfterSnow opened this issue Jun 15, 2023 · 5 comments
Open

Loading Syntax File Error … or No Error? #5

sunnyAfterSnow opened this issue Jun 15, 2023 · 5 comments

Comments

@sunnyAfterSnow
Copy link

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)

EJS_ERROR

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)

EJS_OK

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

@nwoltman
Copy link
Owner

Hmm this is weird. I'm on 4143 right now and have no problems. Opening up EJS files with the syntax works as expected.

Perhaps they added some sort of check when you install a new package. I'll have to look into it, but I'm not sure if it's possible to remove the recursion from the syntax.

Since you're able to install it with Sublime 3, can you try upgrading from 3 to 4 with the package already installed? That might let you keep it installed and not get the error message.

@nwoltman
Copy link
Owner

I've been reading Sublime's docs and it looks like they've added a lot of helpful features to their syntax definitions. I'm going to try rewriting it using the new features.

@sunnyAfterSnow
Copy link
Author

Hmm this is weird. I'm on 4143 right now and have no problems. Opening up EJS files with the syntax works as expected.

Perhaps they added some sort of check when you install a new package. I'll have to look into it, but I'm not sure if it's possible to remove the recursion from the syntax.

Since you're able to install it with Sublime 3, can you try upgrading from 3 to 4 with the package already installed? That might let you keep it installed and not get the error message.

Very quick answer, thank you very much. I try to upgrade ST3 to ST4, your plugin is very useful!

@sunnyAfterSnow
Copy link
Author

sunnyAfterSnow commented Jun 16, 2023

I've been reading Sublime's docs and it looks like they've added a lot of helpful features to their syntax definitions. I'm going to try rewriting it using the new features.

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 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?

@nwoltman
Copy link
Owner

It will allow ES6 template strings to have the ability to highlight HTML syntax
...
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?

If that's the case, then it may be impossible. HTML can already contain JavaScript, so then if you update it so that JavaScript can contain HTML, that's an infinite loop.

I just updated this package to use a different Sublime Syntax feature to implement EJS. Maybe that will help. If not, you'd probably have to figure something out with the people who created Sublime Text's Syntax Definitions to come up with a solution, since I don't know enough about Sublime's own HTML and JavaScript definitions to figure out a solution on my own.

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

No branches or pull requests

2 participants