自在幻想的fancyCoder

      生活 2004-3-25 14:56
可以在UBB里加亮显示语法的东东,以后在坛子里贴代码转一下就方便看了。
我另存一份在这里 vip.5d.cn/diyutiantang/
要用的时候方便一点:D

TEST


//检查语法加亮规则定义,并做相应调整,返回是否成功
//lang: 可为0个或多个,分别表示各个需要检查的语言,如果不写则表示检查所有
function FCCheckSyntaxDef(/*lang, ...*/) {
    if (arguments.length > 0) {
        var langList = {};
        for (var i = arguments.length - 1; i >= 0; i--) {
            if (FCSyntaxDef[arguments[i]] != null) langList[arguments[i]] = true;
        }
    } else {
        var langList = FCSyntaxDef;
    }
    for (var lang in langList) {
        var syntax = FCSyntaxDef[lang];
        var delim = syntax.delimiters;
        if (delim == null) {
            syntax.delimiters = "~!@%^&*()-+=|\/{}[]:;\"'<>,.? \t";
        } else if (delim.indexOf(" \t") < 0) {
            syntax.delimiters += " \t";
        }
        if (syntax.comments != null) {
            if (typeof(syntax.comments) == "string") syntax.comments = syntax.comments.split(" ");
            if (syntax.cmtcolor == null) syntax.cmtcolor = "#00ff00";
            if (syntax.cmtstyle == null) syntax.cmtstyle = "";
            else syntax.cmtsytle = syntax.cmtstyle.toLowerCase();
        }
        var blocks = syntax.blocks;
        for (var classid in blocks) {
            var block = blocks[classid];
            if (block.color == null) block.color = "#00ffff";
            if (block.style == null) block.style = "";
            else block.style = block.style.toLowerCase();
        }
        var keywords = syntax.keywords;
        for (var classid in keywords) {
            var group = keywords[classid];
            if (group.color == null) group.color = "#0000ff";
            if (group.style == null) group.style = "";
            else group.style = group.style.toLowerCase();
            group.list = (" " + (group.list instanceof Array ? group.list.join(" ")
                : group.list) + " ").replace(/ +/g, " ");
        }
    }
}
//--------------------------------------------------------------
[/color]
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}
}