最近折腾这个markdown的高亮,忽然想起来以前我们的一个小小作业,和高亮有关,觉得挺好玩的就拿出来折腾折腾.
要求:java的高亮转变成html文件后里面依旧高亮
思路:
- 关键字搜索匹配高亮
- 注释搜索匹配
- html特殊符号处理
- 注释中的关键词处理
效果如下:
java里面:(由于blog用的js代码高亮不是太完美)
package work1;
public class Messageprint {
// 测试的文档test
/**
* ghghghgh
*
* @mtcle the first javawork
*/
public static void main(String[] args) {
System.out.println("Welcome\"<html></html> to Java");// 这里是注释
System.out.println("Welcome to computer Science");// 也是注释
System.out.println("Programming is fun");// 还是注释
}
}
html效果如下:
这里好像是markdown对于大段html的支持不是太完美(个人感觉),段注释在html页面运行正常,放到markdown里就不行了主要是 * 的特殊含义吧 原html格式
**package** work1; </font>**public** **class** Messageprint { </font>
// 测试的文档test
/**
* ghghghgh
*
* @mtcle the first javawork
*/ </font>
**public** **static** **void** main(String[] args) { </font>
System.**out**.println( " Welcome \" <html></html> to Java " );// 这里是注释
System.**out**.println( " Welcome to computer Science " );// 也是注释
System.**out**.println( " Programming is fun " );// 还是注释
} </font>
} </font>
</pre></html> -------