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

Throws exception if asked to parse HTML via web-tree-sitter #93

Open
savetheclocktower opened this issue Apr 1, 2023 · 4 comments
Open
Labels
bug Something isn't working

Comments

@savetheclocktower
Copy link

Describe the bug

Reproducible from the playground:

cd tree-sitter-markdown
tree-sitter build-wasm . && tree-sitter playground

Code example

<h1>foo</h1>

Expected behavior
Any sane parsing of the tree would be useful here, but the specs suggest to me that the tree should render with an html_block node.

Actual behavior
Errors in both Chrome and Firefox. Here's the Chrome error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'apply')
    at e.<computed> (tree-sitter.js:1:10370)
    at 0016e4de:0x27a2
    at 0016e4de:0x1824
    at tree-sitter.wasm:0x24b5b
    at Parser.parse (tree-sitter.js:1:38110)
    at handleCodeChange (playground.js:115:28)
    at it (codemirror.min.js:1:17760)
    at jn (codemirror.min.js:1:65062)
    at codemirror.min.js:1:61536
    at codemirror.min.js:1:61545

Appears to happen only when the HTML is the first content on the line. If I start with a blank document, I can type < without an error, but <a is enough to cause the error, which then repeats with each keystroke.

@savetheclocktower savetheclocktower added the bug Something isn't working label Apr 1, 2023
@gushogg-blake
Copy link

This might be to do with tree-sitter/tree-sitter#949 - this grammar must be statically linked to tree-sitter as it uses C/C++ functions that aren't in the main exports.json. More info here - https://edita.vercel.app/blog/tree-sitter-howto/.

@savetheclocktower
Copy link
Author

Yeah, I should try this again in Pulsar now that we've added some code to detect these missing exports.

@savetheclocktower
Copy link
Author

@gushogg-blake, I read your blog post. Regarding this section…

There are two other solutions suggested in the emscripten docs:

  • add EMCC_FORCE_STDLIBS=1 and -s EXPORT_ALL=1 to the emcc command in tree-sitter
  • add missing symbols to exports.json (as described in #949)

but neither of these worked.

…I can at least confirm that Pulsar was able to get the second solution to work; the README here has more information. Maybe you'll find it useful for your editor.

@gushogg-blake
Copy link

@savetheclocktower Nice, thanks - I didn't all have the linkages clear in my head at the time so could have been missing something simple. Might give it a try with the next grammar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants