跳转到主要内容

此文仅仅为那些想在blogger用LISP的语法高亮代码发帖的人。
首先,请参考:
让Blogspot支持语法高亮:
http://blog.venj.me/2010/06/blogspot.html
在Blogger中添加代码语法高亮:
http://zjunet.blogspot.com/2013/04/blogger.html。
syntaxhighlighter这个插件很好,可是没有为LISP定制的js.
那么,想用LISP语法也能达到这样的效果,只好自己动手了。
下面是我写的:shBrushLisp.js文件:
shBrushLisp
按照网上的方法,你添加进去就可以了。

[codesyntax lang="javascript"]
dp.sh.Brushes.Lsp = function()
{
var keywords =
'abs acad_colordlg acad_helpdlg acad-pop-dbmod acad-push-dbmod ' +
'acad_strlsort acdimenableupdate acet-layerp-mode acet-layerp-mark acet-laytrans acet-ms-to-ps ' +
'acet-ps-to-ms action_tile add_list ads alert alloc and angle angtof angtos append apply arx ' +
'arxload arxunload ascii assoc atan atof atoi atom atoms-family autoarxload autoload Boole boundp ' +
'caddr cadr car cdr chr client_data_tile close command cond cons cos cvunit defun-q-list-set defun-q-list-ref defun-q ' +
'defun dictadd dictnext dictremove dictrename dictsearch dimx_tile dimy_tile distance ' +
'distof done_dialog end_image end_list entdel entget entlast entmake entmakex entmod entnext entsel ' +
'entupd eq equal error eval exit exp expand expt fill_image findfile fix float foreach function ' +
'gc gcd get_attr get_tile getangle getcfg getcname getcorner getdist getenv getfiled getint getkword ' +
'getorient getpoint getreal getstring getvar graphscr grclear grdraw grread grtext grvecs handent help ' +
'if initdia initget inters itoa lambda last layoutlist length list listp load_dialog load log logand ' +
'logior lsh mapcar max mem member menucmd menugroup min minusp mode_tile namedobjdict nentsel nentselp ' +
'new_dialog not nth null numberp open or osnap polar prin1 princ print progn prompt quit quote read-char read-line read ' +
'redraw regapp rem repeat reverse rtos set set_tile setcfg setenv setfunhelp setq ' +
'setvar setview sin slide_image snvalid sqrt ssadd ssdel ssget ssgetfirst sslength ssmemb ssname ssnamex ' +
'sssetfirst startapp start_dialog start_image start_list strcase strcat strlen subst substr tablet tblnext ' +
'tblobjname tblsearch term_dialog terpri textbox textpage textscr trace trans type unload_dialog untrace ' +
'vector_image ver vlisp-compile vports wcmatch while write-char write-line xdroom xdsize xload xunload zerop '+
'nil t pi';
this.regexList = [
{ regex: /;.*$/gm, css: 'comments' }, // 单行注释
{ regex: /;\|[\S\s]*?\|;/g, css: 'comments' }, // 多行注释
{ regex: dp.sh.RegexLib.DoubleQuotedString, css: 'string' }, // 字符串
{ regex: new RegExp(this.GetKeywords(keywords), 'gmi'), css: 'keyword' }, // 内部函数
{ regex: /\(|\)/gm, css: 'preprocessor' }, // 括号
{ regex: new RegExp('\\#[a-zA-Z0-9]{3,6}', 'g'), css: 'value' },
{ regex: /(vl-)[\w->]+/gmi, css: 'functions' }, // keywords
{ regex: /(vla-)[\w->]+/gmi, css: 'functions' }, // keywords
{ regex: /(vlax-)[\w->]+/gmi, css: 'functions' }, // keywords
{ regex: /(:vlax-)\w+/gmi, css: 'functions' }, // keywords
{ regex: /(:vlr-)\w+/gmi, css: 'functions' }, // keywords
{ regex: /'/gm, css: 'keyword' }, // keywords
{ regex: /(\+|1\+|-|1-|\*|\/|=|\/=|>|<|<=|>=|~)/gmi,css: 'keyword' } // Operators运算符
];

this.CssClass = 'dp-lsp';
this.Style = '.dp-lsp .value { color: red; }' +
'.dp-lsp .keyword { color: blue; font-weight: bold; }' +
'.dp-lsp .string { color: green; }' +
'.dp-lsp .preprocessor { color: magenta; }' +
'.dp-lsp .functions { color: blue; font-weight: bold; }' +
'.dp-lsp .comments { color: grey; }'
;
};

dp.sh.Brushes.Lsp.prototype = new dp.sh.Highlighter();
dp.sh.Brushes.Lsp.Aliases = ['lisp', 'lsp'];
[/codesyntax]

效果如下:

LispSynhighlighter

 

评论