java中间着色法代码 java中颜色代码
java金褐中颜色代码怎么加
1、首先进入javaAPP。
创新互联专注于德城网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供德城营销型网站建设,德城网站制作、德城网页设计、德城网站官网定制、微信小程序定制开发服务,打造德城网络公司原创品牌,更为您提供德城网站排名全网营销落地服务。
2、其次选择金褐中颜色代码。
3、最后选择想要添加的位置进行添加即可。
给java代码着色源码
是javascript的着色吧。你写错了哦!
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ""
html xmlns="" xml:lang="en" lang="en"
head
meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /
titleSyntaxHighlighter Build Test Page/title
/head
body
h3SyntaxHihglighter Test/h3
pre id="showCode"
var hi = "hi!";
function test()
{
var a = 5;
if(a10)
{
return 10;
}
else
{
return avar b = a;
}
dvar b = a;
}
/pre
script type="text/javascript"
function hightLight(str)
{
var start_var = false;
if(str.substring(0,3) == "var")
{
start_var = true;
}
var keywords_green = "= { }".split(" ");
var keywords_blue = "function new return var typeof instanceof".split(" ");
var keywords_red = "break case catch continue default delete else finally for if switch this throw try void while with ;".split(" ");
//user lite keyword no hightLight with: do in
strstr = str.replace(/};/g,"};\n");//对只有一行的压缩代码,每个方法换一行,方便查阅
for(var i = 0; i keywords_green.length; i++)
{
var oReg = new RegExp(keywords_green[i], "g");
var rp = "span style='color:green'" + keywords_green[i] + "/span";
strstr = str.replace(oReg,rp);
}
//给异常的关键字var加上背景颜色,顺序不能变
var rp3 = "span style='background-color:yellow'$1var/span";
strstr = str.replace(/([^;|{|\t| ])var/g,rp3);
if(start_var)
{
alert(str);
//去掉第一个以var开头的背景颜色
strstr = str.replace(/span style='background-color:yellow'var\/span/,"var");
}
for(var i = 0; i keywords_blue.length; i++)
{
var oReg = new RegExp(keywords_blue[i], "g");
var rp = "span style='color:blue'" + keywords_blue[i] + "/span";
strstr = str.replace(oReg,rp);
}
for(var i = 0; i keywords_red.length; i++)
{
var oReg = new RegExp(keywords_red[i], "g");
var rp = "span style='color:red'" + keywords_red[i] + "/span";
var rp2 = "$1span style='color:red'" + keywords_red[i] + "/span(";
//if for are use more and other code not in keyword are use it
if(keywords_red[i] == "if")
{
strstr = str.replace(/if(\s?)\(/g,rp2);
}
else if(keywords_red[i] == "for")
{
strstr = str.replace(/for(\s?)\(/g,rp2);
}
else
{
strstr = str.replace(oReg,rp);
}
}
strstr = str.replace(/\n/g,"br /");
strstr = str.replace(/\t/g," ");//for ie can't with four space
return str;
}
function init()
{
var obj = document.getElementById("showCode");
var str = obj.innerText || obj.textContent;//innerHTML会吧转义成导致无法加亮分号
obj.innerHTML = hightLight(str);
}
init();
/script
/body
/html
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ""
html xmlns="" xml:lang="en" lang="en"
head
meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /
titleSyntaxHighlighter Build Test Page/title
/head
body
h3SyntaxHihglighter Test/h3
pre id="showCode"
var hi = "hi!";
function test()
{
var a = 5;
if(a10)
{
return 10;
}
else
{
return avar b = a;
}
dvar b = a;
}
/pre
script type="text/javascript"
function hightLight(str)
{
var start_var = false;
if(str.substring(0,3) == "var")
{
start_var = true;
}
var keywords_green = "= { }".split(" ");
var keywords_blue = "function new return var typeof instanceof".split(" ");
var keywords_red = "break case catch continue default delete else finally for if switch this throw try void while with ;".split(" ");
//user lite keyword no hightLight with: do in
str = str.replace(/};/g,"};\n");//对只有一行的压缩代码,每个方法换一行,方便查阅
for(var i = 0; i keywords_green.length; i++)
{
var oReg = new RegExp(keywords_green[i], "g");
var rp = "span style='color:green'" + keywords_green[i] + "/span";
str = str.replace(oReg,rp);
}
//给异常的关键字var加上背景颜色,顺序不能变
var rp3 = "span style='background-color:yellow'$1var/span";
str = str.replace(/([^;|{|\t| ])var/g,rp3);
if(start_var)
{
alert(str);
//去掉第一个以var开头的背景颜色
str = str.replace(/span style='background-color:yellow'var\/span/,"var");
}
for(var i = 0; i keywords_blue.length; i++)
{
var oReg = new RegExp(keywords_blue[i], "g");
var rp = "span style='color:blue'" + keywords_blue[i] + "/span";
str = str.replace(oReg,rp);
}
for(var i = 0; i keywords_red.length; i++)
{
var oReg = new RegExp(keywords_red[i], "g");
var rp = "span style='color:red'" + keywords_red[i] + "/span";
var rp2 = "$1span style='color:red'" + keywords_red[i] + "/span(";
//if for are use more and other code not in keyword are use it
if(keywords_red[i] == "if")
{
str = str.replace(/if(\s?)\(/g,rp2);
}
else if(keywords_red[i] == "for")
{
str = str.replace(/for(\s?)\(/g,rp2);
}
else
{
str = str.replace(oReg,rp);
}
}
str = str.replace(/\n/g,"br /");
str = str.replace(/\t/g," ");//for ie can't with four space
return str;
}
function init()
{
var obj = document.getElementById("showCode");
var str = obj.innerText || obj.textContent;//innerHTML会吧转义成导致无法加亮分号
obj.innerHTML = hightLight(str);
}
init();
/script
/body
/html
运行结果:
SyntaxHihglighter Test
var hi = "hi!";
function test()
{
var a = 5;
if(a10)
{
return 10;
}
else
{
return avar b = a;
}
dvar b = a;
} 发现javaEye的语法着色功能有bug,我原来的str = str.replace(/};/g,"};\n");变成strstr = str.replace(/};/g,"};\n"); 了!给多了个str,重新编辑html代码也给弄乱了,把源代码上传给大家了。
语法着色我自己测试过了,这个其实很简单,就是把关键字替换一下而已,那些关键字替换成什么颜色完全可以自定义,语法着色不是我的目的,我的目的是作为压缩脚本后的语法检查。
因为不规范的写法在脚本压缩成一行和去掉多余空格后经常会报错,例如赋值符后的变量没有以;号结束,else后面没有{}包含起来等,在压缩后的脚本通过语法着色可以比较容易知道在那个地方出错了。
如何在网页中谐,Java.等源代码语法着色
1)用Vim(我的是Windows XP + GVim6.3)打开源代码文件,例如sample.c
2)执行 :source $VIMRUNTIME/syntax/2htmls.vim, 则会在当前目录生成sample.c.html
这个sample.c.html就是我们想要的东西,你在vi里看到什么效果,他出来就怎么样。
UltraEdit 中怎样使java代码语法着色
菜单---高级Advanced---配置Configration---编辑器显示---语法着色-----
字词列表的完整路径---- \UltraEdit\wordfile.txt
找到 wordfile.txt文件修改(刚下在的UltraEdit不全要修改)
可着色的语法:
;pa=showpagepid=40
java语法着色文件:
复制后添加末尾,把原先的java塞了
文章名称:java中间着色法代码 java中颜色代码
标题URL:http://abwzjs.com/article/docgoch.html