From 8b2a3c539a08a86895b7371983d3a2f93992dec6 Mon Sep 17 00:00:00 2001 From: Shuhei Hayashibara Date: Tue, 25 Jul 2023 05:14:51 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20add=20option=20`--indent?= =?UTF-8?q?-inner-html`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cli.ts | 6 ++++++ src/formatter.ts | 3 +++ src/main.ts | 1 + src/runtimeConfig.ts | 2 ++ 4 files changed, 12 insertions(+) diff --git a/src/cli.ts b/src/cli.ts index 0340d54d..0e2eb4c6 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -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 and sections in html.', + default: false, + }) .option('sort-tailwindcss-classes', { alias: 'sort-classes', type: 'boolean', diff --git a/src/formatter.ts b/src/formatter.ts index 7710d347..2126073b 100644 --- a/src/formatter.ts +++ b/src/formatter.ts @@ -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: { @@ -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'], @@ -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'], }; diff --git a/src/main.ts b/src/main.ts index 51b25b15..b11d3065 100644 --- a/src/main.ts +++ b/src/main.ts @@ -35,6 +35,7 @@ export type FormatterOption = { wrapLineLength?: number; wrapAttributes?: WrapAttributes; wrapAttributesMinAttrs?: number; + indentInnerHtml?: boolean; endWithNewline?: boolean; endOfLine?: EndOfLine; useTabs?: boolean; diff --git a/src/runtimeConfig.ts b/src/runtimeConfig.ts index 1592b29b..34cd747d 100644 --- a/src/runtimeConfig.ts +++ b/src/runtimeConfig.ts @@ -23,6 +23,7 @@ export interface RuntimeConfig { wrapLineLength?: number; wrapAttributes?: WrapAttributes; wrapAttributesMinAttrs?: number; + indentInnerHtml?: boolean; endWithNewline?: boolean; endOfLine?: EndOfLine; useTabs?: boolean; @@ -78,6 +79,7 @@ export async function readRuntimeConfig(filePath: string | null): Promise