Files
KART-FRONT-NEXT/src/components/kri-editor/utils/formatHtml.ts

17 lines
490 B
TypeScript

export async function formatHtmlSource(html: string): Promise<string> {
if (!html.trim()) return html;
const [{ format }, htmlPlugin] = await Promise.all([
import("prettier/standalone"),
import("prettier/plugins/html"),
]);
return format(html, {
parser: "html",
plugins: [htmlPlugin],
printWidth: 100,
// 인라인 요소(span/a/mark 등) 사이 공백은 실제 렌더링에 영향을 주므로 보존한다.
htmlWhitespaceSensitivity: "css",
});
}