JavaScript recognition in script tag where type isn't “text/javascript”

I use MathJax javascript library. When I change MathJax config I have a problem because he is actually javascript code but his type is "text/x-mathjax-config" and Intellij Idea don't recognize him as code.
Can I add extra types to Intellij Idea configuration for javascript support?

7 comments
Comment actions Permalink

This MathJax config: what is its file name and file extension?

Thanks,
Alexander.

0
Comment actions Permalink

Hm, It is html source code (<some>.html) with script tag <script type="text/x-mathjax-config">

For example

<!DOCTYPE html> <html> <head> <title>MathJax Test Page</title> <!-- Copyright (c) 2009-2013 The MathJax Consortium --> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />     <!--type="text/x-mathjax-config"-->     <script type="text/x-mathjax-config">         MathJax.Hub.Config({             extensions: ["mml2jax.js", "tex2jax.js", "modifymenu.js"],             jax: ["input/MathML", "input/TeX","output/HTML-CSS"],             tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]}         });         MathJax.Hub.Register.StartupHook("MathML Jax Ready",function () {             console.log("MathML Jax Ready");             MathJax.InputJax.MathML.postfilterHooks.Add(function (data) {                 console.log(data);             });         });         MathJax.Hub.Register.StartupHook("MathMenu modifymenu Ready",function () {             console.log("MathMenu modifymenu Ready");             MathJax.Menu.menu.addItemAfterByName(                     MathJax.Menu.ITEM.COMMAND(MathJax.Localization._(["Editor","Edit"], "Edit"), function(event) {                         if (!MathJax.Menu.jax) return;                         var jax = MathJax.Menu.jax;                         if (!event) {event = window.event}                         var EVENT = {screenX:event.screenX, screenY:event.screenY};                         console.log(jax);                         console.log(MathJax.ElementJax.mml);                     }, {nativeTouch: true}),                     "Show Math As");         });     </script>

...
</html>
0
Comment actions Permalink

Source highlighter remove some quotes in message above.

0
Comment actions Permalink

It may be done this way:

1. Settings / Language Injections.
2. Add XML tag injection.
3. In its properties:
3.1. Language ID: JavaScript (or any you like).
3.2. XML Tag local name: script.
3.3. XPath condition: @type="text/x-mathjax-config"

BTW, one "script" is predefined there, but it needs correct XML namespace.

Regards,
Alexander.

0
Comment actions Permalink

Thanks, it work!!

0
Comment actions Permalink

Hm, I have a strange bug when I use this method.
When I press enter cursor moves to page start.

0
Comment actions Permalink

You're right. Looks like you've met this problem: http://youtrack.jetbrains.com/issue/IDEA-112306

I have added necessary information into the issue. Hope developers will react.

Thank you,
Alexander.

0

Please sign in to leave a comment.