vue3-realworld-example-app/playwright/utils/formatHTML.ts

9 lines
320 B
TypeScript

import { prettyPrint } from 'html'
export function formatHTML(rawHTMLString: string) {
const removeComments = rawHTMLString.replaceAll(/<!--.*?-->/gs, '')
const pretty = prettyPrint(removeComments, { indent_size: 2 })
const removeEmptyLines = `${pretty}\n`.replaceAll(/\n{2,}/g, '\n')
return removeEmptyLines
}