UNPKG

419 BJavaScriptView Raw
1/**
2 * 代码缩进
3 *
4 * @param {string} content 文本内容
5 */
6module.exports = function processor(content) {
7 if (!content) {
8 return content;
9 }
10 var match = content.match(/^[^\n\S]+/);
11 var space;
12 if (match) {
13 space = match[0].length;
14 /*jslint evil: true */
15 var regex = new Function('return (/^[^\\n\\S]{' + space + '}/gm)')();
16 return content.replace(regex, '');
17 }
18 return content;
19};
\No newline at end of file