Sublime-JS-Custom
Sublime-JS-Custom copied to clipboard
Embedded markdown recursion error
Sublime Text build number
4152
Example Code
n/a
JS Custom Preferences
{
"defaults": {
"custom_template_tags": false,
"eslint_directives": true,
"jsx": false,
"custom_templates": {
"styled_components": true,
"tags": {
"SQL": "scope:source.sql",
"css": "scope:source.css",
"html": "scope:text.html.basic",
"svg": "scope:text.html.basic",
"this.html": "scope:text.html.basic",
"md": "scope:text.html.markdown"
},
"comments": {
"GraphQL": "scope:source.graphql",
"gql": "scope:source.graphql",
"css": "scope:source.css",
"html": "scope:text.html.basic",
"xml": "scope:text.xml"
}
}
},
"configurations":
{
"Default": {},
"React": {"file_extensions": ["js", "jsx"], "flow_types": true, "jsx": true, "scope": "source.jsx"},
"TypeScript": {"file_extensions": ["ts"], "scope": "source.ts", "typescript": true},
"TypeScript (JSX)": {"file_extensions": ["tsx"], "jsx": true, "scope": "source.tsx", "typescript": true}}
}
Configuration name
Default/React (any of them).
Description
When I add a md tag to the list, and set the scope:text.html.markdown scope, I get the following error:
Error loading syntax file
"Packages/User/JS Custom/ Syntaxes/React.sublime-syntax": Apparent recursion within a with_prototype action:
25000 context sanity limit hit
Maybe I am doing something wrong? Is there a workaround for this error?
This is a known issue — when two syntaxes embed each other, and one injects escaping behavior, it loops when trying to compile them. The custom template code in JS Custom injects escaping behavior, so it would break if you embedded Markdown, which in turn embeds JS.
To avoid this, the default behavior is to also build an extra configuration for embedding that disables custom templates. So your JS Custom syntax would embed Markdown, which would in turn embed the special embed configuration, which doesn't embed Markdown.
I'm not sure exactly what's gone wrong in this case. Is that your exact entire settings file? The error message refers to a React.sublime-syntax, not to a Default syntax.
Sorry, bad copy past. I updated it to the full settings. I understand the suggestion conceptually, but do you have an example of setting up the embed config?
The error message refers to a React.sublime-syntax, not to a Default syntax.
Sorry, the error was throwing on any of them immediately after rebuilding the syntax.
I've been playing around with this without luck. Either it's a cycle between JS Custom and Markdown (and I don't see how that's happening) or it's somehow hitting the context limit without cycling (which seems implausible). I think later today I'll have to play around with a stripped-down Markdown syntax and see if I can isolate it.
FWIW, I ran into this same issue with embedded SCSS. Not exactly clear to me how SCSS is embedding JS? Regardless, any progress on this? If it is possible to workaround this as described above...
To avoid this, the default behavior is to also build an extra configuration for embedding that disables custom templates. So your JS Custom syntax would embed Markdown, which would in turn embed the special embed configuration, which doesn't embed Markdown.
... can you provide an example? Thanks!