diff --git a/docs/options.md b/docs/options.md index 250b20f..569d12b 100644 --- a/docs/options.md +++ b/docs/options.md @@ -1968,6 +1968,30 @@ Indentation size/length (Supported by Pretty Diff) } ``` +##### [Indent with tabs](#indent-with-tabs) + +**Namespace**: `js` + +**Key**: `indent_with_tabs` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) + +**Description**: + +Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by Pretty Diff) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "js": { + "indent_with_tabs": false + } +} +``` + ##### [Preserve newlines](#preserve-newlines) **Namespace**: `html` @@ -4052,11 +4076,11 @@ Indentation size/length (Supported by JS Beautify, Pretty Diff) **Type**: `boolean` -**Supported Beautifiers**: [`JS Beautify`](#js-beautify) +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) **Description**: -Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by JS Beautify) +Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by JS Beautify, Pretty Diff) **Example `.jsbeautifyrc` Configuration** @@ -4585,11 +4609,11 @@ Indentation size/length (Supported by JS Beautify, Pretty Diff) **Type**: `boolean` -**Supported Beautifiers**: [`JS Beautify`](#js-beautify) +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) **Description**: -Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by JS Beautify) +Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by JS Beautify, Pretty Diff) **Example `.jsbeautifyrc` Configuration** @@ -5010,6 +5034,30 @@ Indentation size/length (Supported by Pretty Diff) } ``` +##### [Indent with tabs](#indent-with-tabs) + +**Namespace**: `js` + +**Key**: `indent_with_tabs` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) + +**Description**: + +Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by Pretty Diff) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "js": { + "indent_with_tabs": false + } +} +``` + ##### [Preserve newlines](#preserve-newlines) **Namespace**: `js` @@ -9643,6 +9691,30 @@ Indentation size/length (Supported by Pretty Diff) } ``` +##### [Indent with tabs](#indent-with-tabs) + +**Namespace**: `js` + +**Key**: `indent_with_tabs` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) + +**Description**: + +Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by Pretty Diff) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "js": { + "indent_with_tabs": false + } +} +``` + ##### [Preserve newlines](#preserve-newlines) **Namespace**: `html` @@ -12252,11 +12324,11 @@ Initial indentation level (Supported by JS Beautify) **Type**: `boolean` -**Supported Beautifiers**: [`JS Beautify`](#js-beautify) +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) **Description**: -Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by JS Beautify) +Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by JS Beautify, Pretty Diff) **Example `.jsbeautifyrc` Configuration** @@ -13128,6 +13200,30 @@ If in CSS values leading 0s immediately preceeding a decimal should be removed o } ``` +##### [Indent with tabs](#indent-with-tabs) + +**Namespace**: `js` + +**Key**: `indent_with_tabs` + +**Type**: `boolean` + +**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) + +**Description**: + +Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by Pretty Diff) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "js": { + "indent_with_tabs": false + } +} +``` + ##### [Space after anon function](#space-after-anon-function) **Namespace**: `js` diff --git a/package.json b/package.json index 85f74ad..699ff40 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,10 @@ { "name": "Dheepak Krishnamurthy", "url": "https://github.com/kdheepak89" + }, + { + "name": "Ayoub Adib", + "url": "https://github.com/ayoubdev" } ], "engines": { diff --git a/src/beautifiers/prettydiff.coffee b/src/beautifiers/prettydiff.coffee index b020ea6..b58e11c 100644 --- a/src/beautifiers/prettydiff.coffee +++ b/src/beautifiers/prettydiff.coffee @@ -6,8 +6,14 @@ module.exports = class PrettyDiff extends Beautifier options: { # Apply these options first / globally, for all languages _: - inchar: "indent_char" - insize: "indent_size" + inchar: ["indent_with_tabs", "indent_char", (indent_with_tabs, indent_char) -> + if (indent_with_tabs is true) then \ + "\t" else indent_char + ] + insize: ["indent_with_tabs", "indent_size", (indent_with_tabs, indent_size) -> + if (indent_with_tabs is true) then \ + 1 else indent_size + ] objsort: (objsort) -> objsort or false preserve: ['preserve_newlines', (preserve_newlines) ->