diff --git a/README.md b/README.md index e5fa7737..0a0dc710 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,12 @@ You can also format programmatically with the same syntax using the [blade-forma | `Blade Formatter: format Indent Size` | An indent size | 4 | | `Blade Formatter: format Wrap Line Length` | The length of line wrap size | 120 | | `Blade Formatter: format Wrap Attributes` | The way to wrap attributes. `[auto\|force\|force-aligned\|force-expand-multiline\|aligned-multiple\|preserve\|preserve-aligned]` | `auto` | -| `Blade Formatter: format No Multiple Empty Lines` | Collapses multiple blank lines into a single blank line. | false | -| `Blade Formatter: format use Tabs` | Use tab as indentation character | false | | `Blade Formatter: format Sort Tailwind Css Classes` | Sort Tailwind CSS classes automatically | false | | `Blade Formatter: format Sort HTML Attributes` | Sort HTML Attributes in the specified order. [`none` \| `alphabetical` \| [`code-guide`](https://codeguide.co/#attribute-order) \| [`idiomatic`](https://github.com/necolas/idiomatic-html#attribute-order) \| [`vuejs`](https://eslint.vuejs.org/rules/attributes-order.html)] | `none` | +| `Blade Formatter: format Indent Inner Html` | Indent `` and `` sections in html. | false | +| `Blade Formatter: format use Tabs` | Use tab as indentation character | false | | `Blade Formatter: format Custom Html Attributes Order` | Comma separated custom HTML attributes order. e.g. `id, data-.+, class, name`. To enable this you must specify sort html attributes option as `custom`. You can use regex for attribute names. | `none` | +| `Blade Formatter: format No Multiple Empty Lines` | Collapses multiple blank lines into a single blank line. | false | | `Blade Formatter: format No PHP Syntax Check` | Disable PHP Syntax check. Enabling this will suppress syntax error reporing. | "" | | `Blade Formatter: Dont Show New Version Message` | If set to 'true', the new version message won't be shown anymore. | false | diff --git a/package.json b/package.json index 5ba1f05d..fcf2d3c0 100644 --- a/package.json +++ b/package.json @@ -135,6 +135,11 @@ "default": "", "markdownDescription": "Comma separated custom HTML attributes order. e.g. `id, data-.+, class, name`. To enable this you must specify sort html attributes option as `custom`. You can use regex for attribute names." }, + "bladeFormatter.format.indentInnerHtml": { + "type": "boolean", + "default": false, + "markdownDescription": "Indent \\ and \\ tag sections in html" + }, "bladeFormatter.misc.dontShowNewVersionMessage": { "type": "boolean", "default": false, diff --git a/src/extension.ts b/src/extension.ts index 5ae7b06f..68f14f30 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -118,6 +118,7 @@ export function activate(context: ExtensionContext) { extConfig.customHtmlAttributesOrder, noMultipleEmptyLines: extConfig.noMultipleEmptyLines, noPhpSyntaxCheck: extConfig.noPhpSyntaxCheck, + indentInnerHtml: extConfig.indentInnerHtml, ...runtimeConfig, // override all settings by runtime config ...tailwindConfig, }; diff --git a/src/test/fixtures/project/withConfig/indentInnerHtml/.bladeformatterrc.json b/src/test/fixtures/project/withConfig/indentInnerHtml/.bladeformatterrc.json new file mode 100644 index 00000000..626db659 --- /dev/null +++ b/src/test/fixtures/project/withConfig/indentInnerHtml/.bladeformatterrc.json @@ -0,0 +1,3 @@ +{ + "indentInnerHtml": true +} diff --git a/src/test/fixtures/project/withConfig/indentInnerHtml/formatted.index.blade.php b/src/test/fixtures/project/withConfig/indentInnerHtml/formatted.index.blade.php new file mode 100644 index 00000000..c561cfbc --- /dev/null +++ b/src/test/fixtures/project/withConfig/indentInnerHtml/formatted.index.blade.php @@ -0,0 +1,17 @@ + + + + @section('header') + + foo + + @endsection + + + + + + + diff --git a/src/test/fixtures/project/withConfig/indentInnerHtml/index.blade.php b/src/test/fixtures/project/withConfig/indentInnerHtml/index.blade.php new file mode 100644 index 00000000..16e7fffc --- /dev/null +++ b/src/test/fixtures/project/withConfig/indentInnerHtml/index.blade.php @@ -0,0 +1,14 @@ + + +@section('header') + +foo + +@endsection + + + + + \ No newline at end of file diff --git a/src/test/fixtures/project/withoutConfig/indentInnerHtml/formatted.index.blade.php b/src/test/fixtures/project/withoutConfig/indentInnerHtml/formatted.index.blade.php new file mode 100644 index 00000000..c561cfbc --- /dev/null +++ b/src/test/fixtures/project/withoutConfig/indentInnerHtml/formatted.index.blade.php @@ -0,0 +1,17 @@ + + + + @section('header') + + foo + + @endsection + + + + + + + diff --git a/src/test/fixtures/project/withoutConfig/indentInnerHtml/index.blade.php b/src/test/fixtures/project/withoutConfig/indentInnerHtml/index.blade.php new file mode 100644 index 00000000..16e7fffc --- /dev/null +++ b/src/test/fixtures/project/withoutConfig/indentInnerHtml/index.blade.php @@ -0,0 +1,14 @@ + + +@section('header') + +foo + +@endsection + + + + + \ No newline at end of file diff --git a/src/test/suite/extension.test.ts b/src/test/suite/extension.test.ts index 1062991e..4509266d 100644 --- a/src/test/suite/extension.test.ts +++ b/src/test/suite/extension.test.ts @@ -236,6 +236,31 @@ suite("Extension Test Suite", () => { await config.update("customHtmlAttributesOrder", undefined, true); }); + test("Should format file with runtime config / indentInnerHtml", async function (this: any) { + this.timeout(20000); + await formatSameAsBladeFormatter( + "withConfig/indentInnerHtml/index.blade.php", + "withConfig/indentInnerHtml/formatted.index.blade.php", + ); + }); + + test("Should format file without runtime config / indentInnerHtml", async function (this: any) { + this.timeout(20000); + const config = vscode.workspace.getConfiguration( + "bladeFormatter.format", + ); + await config.update( + "indentInnerHtml", + true, + true, + ); + await formatSameAsBladeFormatter( + "withoutConfig/indentInnerHtml/index.blade.php", + "withoutConfig/indentInnerHtml/formatted.index.blade.php", + ); + await config.update("indentInnerHtml", undefined, true); + }); + test("Format command exists in command list", async function () { const commands = await vscode.commands.getCommands(); assert(commands.includes(ExtensionConstants.formatCommandKey));