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

Embedded markdown recursion error #144

Open
bcomnes opened this issue Nov 2, 2023 · 4 comments
Open

Embedded markdown recursion error #144

bcomnes opened this issue Nov 2, 2023 · 4 comments

Comments

@bcomnes
Copy link

bcomnes commented Nov 2, 2023

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:

Screenshot 2023-11-02 at 2 02 27 PM
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?

@bcomnes bcomnes changed the title Embedded markdown? Embedded markdown recursion error Nov 2, 2023
@Thom1729
Copy link
Owner

Thom1729 commented Nov 2, 2023

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.

@bcomnes
Copy link
Author

bcomnes commented Nov 2, 2023

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.

@Thom1729
Copy link
Owner

Thom1729 commented Nov 4, 2023

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.

@dndrsn
Copy link

dndrsn commented Oct 23, 2024

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!

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

3 participants