261012_01_FST: first commit
This commit is contained in:
16
src/components/kri-editor/utils/formatHtml.ts
Normal file
16
src/components/kri-editor/utils/formatHtml.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
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",
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user