CSS格式化工具 Emeditor Macros

支付宝内搜索 9155838 即可领现金红包 每天都能领哦

/** * CSS格式化工具 * @FileName CSSFormat.jsee * @Version v1.0 * @WEB http://www.blog.dngz.net */

function CSSformat(n){

if (document.selection.Text=="") document.selection.SelectAll();

if (n==1){ document.selection.Text = document.selection.Text.replace(/\r\n/g,"").replace(/}/g,"}\r\n").replace(/\*\//g,"*/\r\n").replace(/\t/g,"").replace(/\s*(:|;)\s*/g,"$1").replace(/\n{2,}/g,"\n").replace(/ {2,}/g," "); }

if (n==2){ document.selection.Text = document.selection.Text.replace(/\r\n/g,"").replace(/}/g,"}\r\n").replace(/\s*;\s*/g,";").replace(/;/g,";\r\n\t").replace(/{/g,"{\r\n\t").replace(/}/g,"\r\n}").replace(/\*\//g,"*/\r\n").replace(/\t\t/g,"\t"); } }

mainMenu=CreatePopupMenu();

mainMenu.Add("功能:对选中文字或全文CSS格式化",0);

mainMenu.Add("一行",1);

mainMenu.Add("多行",2);

mainMenu.Add("关于",3);

mainMenu.Add( "", 0, eeMenuSeparator );

var witchItem=mainMenu.Track();

switch(witchItem)

{

case 1:

    CSSformat(1);

    break;

case 2:

    CSSformat(2);

    break;

case 3:

    alert("测试,心灵博客,\nhttp://www.blog.dngz.net");break;

default:

break;

}

推荐文章

发表新评论