Format

Format the compiled HTML output by indenting lines for better readability.

Usage

Need to send HTML to a human? Enable html.format in your config:

maizzle.config.ts
export default defineConfig({
  html: {
    format: false,
  },
})
OptionDefault
printWidth320
htmlWhitespaceSensitivity'ignore'
embeddedLanguageFormatting'off'

Customization

Options

Pass an object to customize the oxfmt options, it will be merged with the defaults.

maizzle.config.ts
export default defineConfig({
  html: {
    format: {
      printWidth: 200,
    },
  },
})

API

Use format programmatically to pretty-print any HTML string outside the build pipeline:

ts
import { format } from '@maizzle/framework'

// Defaults only
const pretty = await format('<html><body><p>hi</p></body></html>')

// Pass any oxfmt FormatOptions
const tabs = await format(html, {
  useTabs: true,
  tabWidth: 4,
  singleAttributePerLine: true,
})

The first argument is an HTML string. The second is an optional oxfmt FormatOptions object — Maizzle's defaults are merged underneath:

Returns a Promise<string> with the formatted HTML.