-
Notifications
You must be signed in to change notification settings - Fork 95
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
Syntax for text/jsx inside HTML #119
Comments
@sorbits @infininight - I see you're the top contributors to this repo, what's the process for getting PRs approved nowadays? |
have you resolved the issue? |
@infininight @sorbits Can you help us out with getting the PR merged? |
By the way does it makes sense to add |
I did some digging and couldn't find any references to being able to set a script type to "module/*". I only see it as <script type="module">. Do you know of any instance where you can specify something after module? I don't think I've ever actually used the module type before so I'm pretty unfamiliar with it. |
I don't think "module/*" exists yet. I would like to introduce it to be able to use import inside the js code. <script type="text/jsx">
ReactDOM.render(<h1>Hello</h1>, document.getElementById('app'))
</script> is meant to be converted to a regular script tag <script>
ReactDOM.render(React.createElement('h1', null, 'Hello'), document.getElementById('app')
</script> There is a need for a module version to be able to use import(s). <script type="module/jsx">
import React from "https://cdn.jsdelivr.net/npm/@esm-bundle/react@17.0.2-fix.0/esm/react.production.min.js"
import ReactDOM from "https://cdn.jsdelivr.net/npm/@esm-bundle/react-dom@17.0.2-fix.0/esm/react-dom.production.min.js"
ReactDOM.render(<h1>Hello</h1>, document.getElementById('app'))
</script> That would be converted back to a <script type="module">
import React from "https://cdn.jsdelivr.net/npm/@esm-bundle/react@17.0.2-fix.0/esm/react.production.min.js"
import ReactDOM from "https://cdn.jsdelivr.net/npm/@esm-bundle/react-dom@17.0.2-fix.0/esm/react-dom.production.min.js"
ReactDOM.render(React.createElement('h1', null, 'Hello'), document.getElementById('app'))
</script> "text/jsx" was invented and is ignored by the browser, "module/jsx" would be ignored as well and be the module equivalent of "text/jsx". |
I'm also experiencing this issue. Although |
For sure, I would like to see |
any updates on this? |
why not just use "text/babel"? |
Any Updates on this? |
Related Stack Overflow question: Can't get the correct Language Mode / IntelliSense for a script tag with type="text/jsx" in an HTML file. |
Just to be clear, although there may not be an official In fact JSX is probably one of the most popular UI source formats in use today, coupled with React.js. And the recommended type for inline scripts is People are saying that VS Code already supports JSX in a standalone file. The request here is to support the same syntax highlighting in a It appears that this request was originally filed at microsoft/vscode#145992, but the author was told to file it here. Are there any updates? If it works in standalone JSX files, what is stopping someone to simply turn it on for |
In fact someone said above that this already works with type This truly seems like a one-line change. Tell me where to do it and I'll do it and submit a PR. |
Is there any traction on this? |
From what I can tell, this repo is no longer actively managed by anyone. My guess is that someone will need to clone the repo, make the change, then publish an extension for VSCode. |
Today I found out that changing
But that is what has confused me from the very start. Wouldn't the registration of script types with syntax highlighting rules be somewhere in VS Code itself? Or does this library publish which script types it supports? (If the latter, that seems a bit odd, as new types might come out and we would want to associate existing syntax highlighting with them.) |
I see this in
It seems reasonable that simply adding
I have no idea about that part. I don't know how VS Code uses this codebase, or even if it uses it. Isn't this something built into VS Code? I mean I'm sure it's configured as an extension somehow, but it seems to be a default registration, i.e. it comes with a clean installation of VS Code. How does the extension get built and published? Doesn't there have to be a maintainer in order to tell VS Code our changes are official by getting them included in the official build? I know nothing about the specifics here. I was hoping someone else knew what needs to be done. I'm happy to make the change, but researching how to get them into VS Code seems like a huge time drain. It may be easier to live with |
I also encountered this problem |
I have also suggested defaulting to JavaScript syntax highlighting if the type is unknown, as regardless of the syntax flavour that's what I'd expect a script tag to contain. And it could be a compromise to reduce the amount of "add support for this script type" issues? |
bump |
Changing to <script type="text/babel"> worked just fine for me. |
Setting text/jsx make explicit that the code can use jsx. With text/babel it would require to parse babel config file to know if jsx is enabled in babel plugin. |
Does anyone know the answer to these questions? I don't even need this anymore personally, but I could look into further. Does anyone have any documentation about how all this is connected? |
Can't believe it's been a year and something so important still hasn't been resolved. I just encountered this issue myself. |
This work fine and autocomplete work fine also when adding react jsx code into html code thanks |
Changing "text/jsx" by "text/babel" worked for me |
Changing it to <script type="text/babel"> worked for me! |
NOTE: I originally filed this issue in VSCode's repo, but they requested that I file it here instead.
When editing an HTML file in VSCode, syntax highlighting for
<script type="text/javascript">
is working just fine - even for JSX syntax:But it is not working as soon as I change it to
<script type="text/jsx">
:Also: I noticed that VSCode's "Format Document" command works on the contents of
<script type="text/javascript">
but not when it is changed to<script type="text/jsx">
The text was updated successfully, but these errors were encountered: