Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support jsx/tsx as attribute inside the<script> tag#222

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
deot wants to merge2 commits intovuejs:st4
base:st4
Choose a base branch
Loading
fromdeot:st4
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletionREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,19 @@ Sublime Text Syntax highlighting for single-file [Vue.js](http://vuejs.org) comp

### Enabling JSX Highlighting

The `<script>` block uses the syntax highlighting currently active for you normal `.js` files. To support JSX highlighting inside Vue files:
The `<script>` block uses the syntax highlighting currently active for you normal `.js` files. To support JSX highlighting inside Vue files, include the lang attribute inside the `<script>` tag.

```vue
<script lang="jsx">
export default {
render () {
return <div>{ this.foo }</div>
}
}
</script>
```

If `lang="jsx"` doesn't work, you can try the alternative.

1. Install and set [Babel javascript highlighting package](https://packagecontrol.io/packages/Babel), which supports JSX, as your default JS highlighting.

Expand Down
42 changes: 42 additions & 0 deletionsVue Component.sublime-syntax
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -131,6 +131,48 @@ contexts:
- include: script-lang-decider

script-lang-decider:
- match: (?i)(?=jsx{{unquoted_attribute_break}}|\'jsx\'|"jsx")
set:
- - meta_scope: meta.tag.script.begin.html
- match: '>'
scope: punctuation.definition.tag.end.html
set:
- match: '{{script_content_begin}}'
embed_scope: source.jsx.embedded.html
escape_captures:
1: source.jsx.embedded.html
2: comment.block.html punctuation.definition.comment.end.html
3: source.jsx.embedded.html
4: comment.block.html punctuation.definition.comment.end.html
captures:
1: comment.block.html punctuation.definition.comment.begin.html
pop: 1
embed: scope:source.jsx
escape: '{{script_content_end}}'
- include: script-common
- tag-generic-attribute-meta
- tag-generic-attribute-value
- match: (?i)(?=tsx{{unquoted_attribute_break}}|\'tsx\'|"tsx")
set:
- - meta_scope: meta.tag.script.begin.html
- match: '>'
scope: punctuation.definition.tag.end.html
set:
- match: '{{script_content_begin}}'
embed_scope: source.tsx.embedded.html
escape_captures:
1: source.tsx.embedded.html
2: comment.block.html punctuation.definition.comment.end.html
3: source.tsx.embedded.html
4: comment.block.html punctuation.definition.comment.end.html
captures:
1: comment.block.html punctuation.definition.comment.begin.html
pop: 1
embed: scope:source.tsx
escape: '{{script_content_end}}'
- include: script-common
- tag-generic-attribute-meta
- tag-generic-attribute-value
- match: (?i)(?=coffee{{unquoted_attribute_break}}|\'coffee\'|"coffee")
set:
- - meta_scope: meta.tag.script.begin.html
Expand Down
2 changes: 2 additions & 0 deletionsVue Component.sublime-syntax.yaml-macros
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,6 +132,8 @@ contexts:
- include: script-lang-decider

script-lang-decider:
- !script_language [ jsx, source.jsx ]
- !script_language [ tsx, source.tsx ]
- !script_language [ coffee, source.coffee ]
- !script_language [ livescript, source.livescript ]
- !script_language [ ts, source.ts ]
Expand Down
2 changes: 1 addition & 1 deletionsamples/jsx.vue
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
<!-- See JSX section in README -->

<script>
<script lang="jsx">
export default {
render () {
return <div>{ this.foo }</div>
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp