由于没有支持数字的高亮,我修改了一下插件使它能够对0-9的数字进行高亮。具体修改方法如下:
修改
plugins\syntaxhighlighter2\filesshBrushCpp.js
(这里以cpp为例,其他依样修改),找到
this.regexList = [
这一行,在这一行上面插入一行
var numbers = '0 1 2 3 4 5 6 7 8 9';
然后找到
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword bold' }
所在行,在本行最后加入一个逗号,另起一行插入
{ regex: new RegExp(this.getKeywords(numbers), 'gm'), css: 'numbers bold' }
尾部无逗号,保存即可。
接下来修改css使代码实现高亮。
打开
plugins\syntaxhighlighter2\shThemeDefault.css
(其他风格依样修改),在文件末位加入
syntaxhighlighter .numbers,
.syntaxhighlighter .numbers a
{
color: #9933CC !important;
}
就可以对数字显示高亮了,修改后的两个文件打包下载请点这里。
Newest