我正在使用highlight.js来设置Java的样式,它会为字符串,关键字和数字生成标记,但不会为类型和文字生成标记。我正在使用highlight.js / 9.11.0。
建议?
参见示例: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>