2

In my IntelliJIDEA javascript code sytax highlighter is working fine when code is in separate javascript file.

However for Javascript code embeded in HTML page is not getting highlighted.

Any fix available?

EDIT: Added embedded JavaScript code

<html>
<head>
    <!--Load the AJAX API-->
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">

      // Load the Visualization API and the piechart package.
      google.load('visualization', '1.0', {'packages':['corechart']});

      // Set a callback to run when the Google Visualization API is loaded.
      google.setOnLoadCallback(drawChart);

      // Callback that creates and populates a data table,
      // instantiates the   pie chart, passes in the data and
      // draws it.
      function drawChart() {

        // Create the data table.
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Topping');
        data.addColumn('number', 'Slices');
        data.addRows([
          ['Mushrooms', 3],
          ['Onions', 1],
          ['Olives', 1],
          ['Zucchini', 1],
          ['Pepperoni', 2]
        ]);

        // Set chart options
        var options = {'title':'How Much Pizza I Ate Last Night',
                       'width':400,
                       'height':300};

        // Instantiate and draw our chart, passing in some options.
        var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    </script>
</head>

<body>


<!--Div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>
5
  • Works fine for me. Please show us your html with the embedded script and we might be able to help. Commented Jan 2, 2015 at 21:28
  • Added the code in question. Commented Jan 5, 2015 at 10:45
  • Well, you've added some code, yes, but not the code in question as you're missing the extremely important opening tags for the script, the headers, and the page... Commented Jan 5, 2015 at 16:26
  • Ok, it works fine for me in IntelliJ 13 and 14. So, your project directory structure may be messed up. IntelliJ only treats html files as such when they're in a directory marked as a webapp. If you aren't getting the javascript to highlight, try adding the web facet to the directory it's in (highlight the webapp module and hit f4). Commented Jan 6, 2015 at 14:55
  • @vatsalmevada did this ever get figured out? I have the same issue. Commented Jul 6, 2015 at 15:52

1 Answer 1

1

I was using IntelliJ IDEA community edition when I posted this question and as per my findings IntelliJ IDEA Community Edition doesn't support Javascript.

Refer this link: https://www.jetbrains.com/idea/features/editions_comparison_matrix.html

I switched to IntelliJ IDEA Ultimate Edition and Javascript highlighting is working fine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.