Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const defaults: MaizzleConfig = {
},
html: {
decodeEntities: true,
format: true,
},
useTransformers: true,
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ export type { PurgeCssOptions } from './transformers/purgeCss.ts'
export { filters } from './transformers/filters/index.ts'
export { replaceStrings } from './transformers/replaceStrings.ts'
export { format } from './transformers/format.ts'
export type { FormatOptions } from './transformers/format.ts'
export type { FormatConfig } from './transformers/format.ts'
export { minify } from './transformers/minify.ts'
export type { MinifyOptions } from './transformers/minify.ts'
1 change: 0 additions & 1 deletion src/tests/render/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ describe('render', () => {
expect(result.config.css?.inline).toBe(true)
expect(result.config.css?.purge).toBe(true)
expect(result.config.css?.shorthand).toBe(true)
expect(result.config.html?.format).toBe(true)
})
})

Expand Down
4 changes: 2 additions & 2 deletions src/tests/transformers/format.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect } from 'vitest'
import { format, type FormatOptions } from '../../transformers/format.ts'
import { format, type FormatConfig } from '../../transformers/format.ts'

async function run(html: string, option?: boolean | FormatOptions): Promise<string> {
async function run(html: string, option?: boolean | FormatConfig): Promise<string> {
if (option === false) return html
const opts = (option === true || option == null) ? {} : option
return format(html, opts)
Expand Down
10 changes: 5 additions & 5 deletions src/transformers/format.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { format as oxfmt } from 'oxfmt'
import { defu as merge } from 'defu'
import type { FormatOptions } from 'oxfmt'
import type { FormatConfig } from 'oxfmt'

export type { FormatOptions } from 'oxfmt'
export type { FormatConfig } from 'oxfmt'

const DEFAULT_OPTIONS: FormatOptions = {
const DEFAULT_OPTIONS: FormatConfig = {
printWidth: 320,
htmlWhitespaceSensitivity: 'ignore',
embeddedLanguageFormatting: 'off',
Expand All @@ -17,15 +17,15 @@ const DEFAULT_OPTIONS: FormatOptions = {
* you pass.
*
* @param html HTML string to format.
* @param options [oxfmt `FormatOptions`](https://github.com/oxc-project/oxfmt).
* @param options [oxfmt `FormatConfig`](https://github.com/oxc-project/oxfmt).
* @returns The formatted HTML string.
*
* @example
* import { format } from '@maizzle/framework'
*
* const pretty = await format(html, { useTabs: true, tabWidth: 4 })
*/
export async function format(html: string, options: FormatOptions = {}): Promise<string> {
export async function format(html: string, options: FormatConfig = {}): Promise<string> {
const merged = merge(options, DEFAULT_OPTIONS)
const result = await oxfmt('input.html', html, merged)
return result.code
Expand Down
2 changes: 1 addition & 1 deletion src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export interface HtmlConfig {
*
* Set to `true` to enable with defaults, or pass options.
*/
format?: boolean | import('oxfmt').FormatOptions
format?: boolean | import('oxfmt').FormatConfig
/**
* Minify the HTML output.
*
Expand Down
Loading