github-linguist / linguist

Language Savant. If your repository's language is being reported incorrectly, send us a pull request!
MIT License
12.08k stars 4.19k forks source link

Syntax highlighting not working with script tag and type="text/ecmascript-6" #3072

Closed stoewer closed 8 years ago

stoewer commented 8 years ago

If an html <script> tag has the attribute type="text/ecmascript-6" the content is not highlighted as javascript:

<script type="text/ecmascript-6">
    function printFoo(foo) {
        console.lot(foo)
    }
</script>

However, it does work with type="text/javascript":

<script type="text/javascript">
    function printFoo(foo) {
        console.lot(foo)
    }
</script>

Some editors and IDEs (e.g. Jetbrains products) require this attribute to be present in order to treat the content of <script> tags appropriately. This issue arises frequently when one is using Vue.js with *.vue files like this.

The highlighting is also not working if a <script> tag has type="text/babel", which is also commonly used to indicate es6 content in a <script> tag.

pchaigno commented 8 years ago

Linguist only selects the grammar to use for highlighting. For JavaScript, GitHub uses atom/language-javascript. You should open an issue there if there isn't already one.

Alhadis commented 8 years ago

@pchaigno This actually seems to be an issue with the HTML syntax.

Seems Linguist is using the TextMate grammar for highlighting instead of Atom's. Interestingly enough, if Atom's grammar is used for highlighting, it works fine.

I think we should switch...

pchaigno commented 8 years ago

@Alhadis - Ooh, right! @stoewer - textmate/html.tmbundle it is!

I think we should switch...

If they're other issues, I agree. But otherwise, we'd probably better open a pull request ;) That said, I don't think there's a single grammar free of any issue. It's just that difficult to parse context-free grammars with regular expressions :stuck_out_tongue_winking_eye:

Alhadis commented 8 years ago

That said, I don't think there's a single grammar free of any issue.

Nope, of course not. However, Atom's grammars are updated frequently, and would arguably be a better fit for fast-moving technologies like CSS and HTML. Conversely, TextMate's grammar repos aren't updated all that frequently, and don't receive as much input from users as Atom's grammars do.

stoewer commented 8 years ago

@stoewer - textmate/html.tmbundle it is!

Thank's, I'll report it there.

luke-j commented 8 years ago

type="text/babel" should now work in *.vue files as per my pull request here

pchaigno commented 8 years ago

Closing as this needs to be fixed upstream.