Java syntax highlighting with Highlight.js
Asked Answered
T

0

7

I'm using highlight.js to style Java and it's generating markup for strings, keywords and numbers but not for types and literals. I'm using highlight.js/9.11.0.

Suggestions?

See example: https://codepen.io/amandaw/pen/bWMraO

CSS

.hljs-variable {
   color: red
 }

.hljs-type {
   color: orange
}
.hljs-literal {
   color: yellow
}

HTML

<pre><code class="java"> 

import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception {
  Date d1 = new Date();
  Calendar cl = Calendar. getInstance();

    cl.setTime(d1);
    System.out.println("today is "+ d1.toString());

    cl. roll(Calendar.MONTH, 100);
    System.out.println("date after a month will be " + cl.getTime().toString() );

    cl. roll(Calendar.HOUR, 70);
    System.out.println("date after 7 hrs will be "+ cl.getTime().toString() );
   }
}

</code></pre>
Tuesday answered 12/5, 2017 at 22:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.