editplus格式化html⽂档,EditPlus格式化HTMLJSCSS //author: smoker//初始化选项
var indent_size = 1;//缩进空格数, 为1时使⽤制表符缩进
var indent_char = ‘ ‘;//缩进字符
var preserve_newlines = false;//是否保留空⾏, 默认不保留//程序开始
var input = "";/*while(!WScript.StdIn.AtEndOfStream)
{
input += WScript.StdIn.ReadAll();
}
if (indent_size == 1) {
indent_char = ‘\t‘;
}
var js_source = place(/^\s+/, ‘‘);
var formated_code=‘‘;
if (js_source && js_source[0] !== ‘
formated_code =js_beautify(js_source, {indent_size: indent_size, indent_char: indent_char,
preserve_newlines:preserve_newlines});
}
if(!formated_code.length==0)
WScript.Echo(formated_code);
else
WScript.Echo(‘Are you sure your input is javascript source file?‘);*/
//注销原读⼊⽅式(ascii码读⼊).通过ADODB.Stream,设置UTF-8编码.
var args =WScript.Arguments;var filepath = args(0);//解决空格问题
if(args!=null&&args.length>1){var fileelments =[];for(var i=0;i
fileelments.push(args(i));
}
filepath= fileelments.join(" ");
}//WScript.Echo(filepath);
if(filepath!=null&&filepath!=""){var stream = new ActiveXObject("ADODB.Stream");
stream.Mode= 3; //常⽤值 1:读,2:写,3:读写
stream.Type = 2; //1:⼆进制,2:⽂本(默认)
stream.Charset = ‘UTF-8‘; //指定编码UTF-8
stream.Open();
stream.LoadFromFile(filepath);
input= stream.ReadText(-1); //读取全部内容
stream.Close();if (indent_size == 1) {
indent_char= ‘\t‘;
}var js_source = place(/^\s+/, ‘‘);var formated_code = ‘‘;if (js_source && js_source[0] !== ‘js arguments
formated_code=js_beautify(js_source, {indent_size: indent_size, indent_char: indent_char,
preserve_newlines:preserve_newlines});
}
formated_code.length?WScript.Echo(formated_code):WScript.Echo(‘Are you sure your input is JS source file?‘); }
.....................
...............省略.................
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论