Skip to content

Commit

Permalink
feat: 🎸 add option --indent-inner-html
Browse files Browse the repository at this point in the history
  • Loading branch information
shufo committed Jul 24, 2023
1 parent 46374e4 commit 8b2a3c5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ export default async function cli() {
description: `Minimum number of html tag attributes for force wrap attribute options. Wrap the first attribute only if 'force-expand-multiline' is specified in wrap attributes`,
default: '2',
})
.option('indent-inner-html', {
alias: 'I',
type: 'boolean',
description: 'Indent <head> and <body> sections in html.',
default: false,
})
.option('sort-tailwindcss-classes', {
alias: 'sort-classes',
type: 'boolean',
Expand Down
3 changes: 3 additions & 0 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export default class Formatter {
wrap_line_length: util.optional(this.options).wrapLineLength || 120,
wrap_attributes: util.optional(this.options).wrapAttributes || 'auto',
wrap_attributes_min_attrs: util.optional(this.options).wrapAttributesMinAttrs,
indent_inner_html: util.optional(this.options).indentInnerHtml || false,
end_with_newline: util.optional(this.options).endWithNewline || true,
max_preserve_newlines: util.optional(this.options).noMultipleEmptyLines ? 1 : undefined,
css: {
Expand Down Expand Up @@ -1934,6 +1935,7 @@ export default class Formatter {
wrap_line_length: util.optional(this.options).wrapLineLength || 120,
wrap_attributes: util.optional(this.options).wrapAttributes || 'auto',
wrap_attributes_min_attrs: util.optional(this.options).wrapAttributesMinAttrs,
indent_inner_html: util.optional(this.options).indentInnerHtml || false,
indent_with_tabs: useTabs,
end_with_newline: false,
templating: ['php'],
Expand Down Expand Up @@ -2042,6 +2044,7 @@ export default class Formatter {
wrap_line_length: util.optional(this.options).wrapLineLength || 120,
wrap_attributes: util.optional(this.options).wrapAttributes || 'auto',
wrap_attributes_min_attrs: util.optional(this.options).wrapAttributesMinAttrs,
indent_inner_html: util.optional(this.options).indentInnerHtml || false,
end_with_newline: false,
templating: ['php'],
};
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type FormatterOption = {
wrapLineLength?: number;
wrapAttributes?: WrapAttributes;
wrapAttributesMinAttrs?: number;
indentInnerHtml?: boolean;
endWithNewline?: boolean;
endOfLine?: EndOfLine;
useTabs?: boolean;
Expand Down
2 changes: 2 additions & 0 deletions src/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface RuntimeConfig {
wrapLineLength?: number;
wrapAttributes?: WrapAttributes;
wrapAttributesMinAttrs?: number;
indentInnerHtml?: boolean;
endWithNewline?: boolean;
endOfLine?: EndOfLine;
useTabs?: boolean;
Expand Down Expand Up @@ -78,6 +79,7 @@ export async function readRuntimeConfig(filePath: string | null): Promise<Runtim
nullable: true,
},
wrapAttributesMinAttrs: { type: 'integer', nullable: true, default: 2 },
indentInnerHtml: { type: 'boolean', nullable: true },
endWithNewline: { type: 'boolean', nullable: true },
endOfLine: { type: 'string', enum: ['LF', 'CRLF'], nullable: true },
useTabs: { type: 'boolean', nullable: true },
Expand Down

0 comments on commit 8b2a3c5

Please sign in to comment.