使用 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'); 枫茶舍
筱枫的笔记和碎碎念
使用 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');