Node.js 格式化 HTML

使用 html-format package 格式化。

const format = require('html-format');
const formattedHtml = format(dom.serialize(), " ".repeat(4), 200);
// indent = 4 spaces, width = 200 characters (80 default)
fs.writeFileSync(filePath, formattedHtml, 'utf8');

添加新评论


晚上好,今天过得怎么样?