diff --git a/types/html-minifier/html-minifier-tests.ts b/types/html-minifier/html-minifier-tests.ts
index 4196a870e6..5cb2ffccf9 100644
--- a/types/html-minifier/html-minifier-tests.ts
+++ b/types/html-minifier/html-minifier-tests.ts
@@ -1,8 +1,7 @@
-
import * as HTMLMinifier from 'html-minifier';
const minify = HTMLMinifier.minify;
-var result = minify('
foo
', {
+const result = minify('
foo
', {
removeAttributeQuotes: true
});
result; // '
foo
'
diff --git a/types/html-minifier/index.d.ts b/types/html-minifier/index.d.ts
index 0bf9e2ae7f..6232cb1193 100644
--- a/types/html-minifier/index.d.ts
+++ b/types/html-minifier/index.d.ts
@@ -1,111 +1,164 @@
-// Type definitions for HTMLMinifier v1.1.1
+// Type definitions for html-minifier 3.5
// Project: https://github.com/kangax/html-minifier
// Definitions by: Tanguy Krotoff
+// Riku
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-///
-
import * as UglifyJS from 'uglify-js';
import * as CleanCSS from 'clean-css';
import * as RelateUrl from 'relateurl';
-declare namespace HTMLMinifier {
- function minify(text: string, options?: Options): string;
+export function minify(text: string, options?: Options): string;
- interface Options {
- // Strip HTML comments
- removeComments?: boolean;
+export interface Options {
+ // Treat attributes in case sensitive manner (useful for custom HTML tags)
+ caseSensitive?: boolean;
- // Strip HTML comments from scripts and styles
- removeCommentsFromCDATA?: boolean;
+ // Omit attribute values from boolean attributes
+ collapseBooleanAttributes?: boolean;
- // Remove CDATA sections from script and style elements
- removeCDATASectionsFromCDATA?: boolean;
+ // Don't leave any spaces between display:inline; elements when collapsing. Must be used in conjunction with collapseWhitespace=true
+ collapseInlineTagWhitespace?: boolean;
- // Collapse white space that contributes to text nodes in a document tree
- collapseWhitespace?: boolean;
+ /**
+ * Collapse white space that contributes to text nodes in a document tree
+ * @see http://perfectionkills.com/experimenting-with-html-minifier/#collapse_whitespace
+ */
+ collapseWhitespace?: boolean;
- // Always collapse to 1 space (never remove it entirely). Must be used in conjunction with collapseWhitespace=true
- conservativeCollapse?: boolean;
+ // Always collapse to 1 space (never remove it entirely). Must be used in conjunction with collapseWhitespace=true
+ conservativeCollapse?: boolean;
- // Don't leave any spaces between display:inline; elements when collapsing. Must be used in conjunction with collapseWhitespace=true
- collapseInlineTagWhitespace?: boolean;
+ // Arrays of regex'es that allow to support custom attribute assign expressions (e.g. '')
+ customAttrAssign?: RegExp[];
- // Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break. Must be used in conjunction with collapseWhitespace=true
- preserveLineBreaks?: boolean;
+ // Regex that specifies custom attribute to strip newlines from (e.g. /ng-class/)
+ customAttrCollapse?: RegExp[];
- // Omit attribute values from boolean attributes
- collapseBooleanAttributes?: boolean;
+ // Arrays of regex'es that allow to support custom attribute surround expressions (e.g. )
+ customAttrSurround?: RegExp[];
- // Remove quotes around attributes when possible
- removeAttributeQuotes?: boolean;
+ // Arrays of regex'es that allow to support custom event attributes for minifyJS (e.g. ng-click)
+ customEventAttributes?: RegExp[];
- // Remove attributes when value matches default
- removeRedundantAttributes?: boolean;
+ // Use direct Unicode characters whenever possible
+ decodeEntities?: boolean;
- // Prevents the escaping of the values of attributes.
- preventAttributesEscaping?: boolean;
+ // Parse input according to HTML5 specifications
+ html5?: boolean;
- // Replaces the doctype with the short (HTML5) doctype
- useShortDoctype?: boolean;
+ // Array of regex'es that allow to ignore certain comments, when matched
+ ignoreCustomComments?: RegExp[];
- // Remove all attributes with whitespace-only values
- removeEmptyAttributes?: boolean;
+ // Array of regex'es that allow to ignore certain fragments, when matched (e.g. , {{ ... }}, etc.)
+ ignoreCustomFragments?: RegExp[];
- // Remove type="text/javascript" from script tags. Other type attribute values are left intact.
- removeScriptTypeAttributes?: boolean;
+ // Insert tags generated by HTML parser
+ includeAutoGeneratedTags?: boolean;
- // Remove type="text/css" from style and link tags. Other type attribute values are left intact.
- removeStyleLinkTypeAttributes?: boolean;
+ // Keep the trailing slash on singleton elements
+ keepClosingSlash?: boolean;
- // Remove unrequired tags
- removeOptionalTags?: boolean;
+ // Specify a maximum line length. Compressed output will be split by newlines at valid HTML split-points
+ maxLineLength?: number;
- // Remove all elements with empty contents
- removeEmptyElements?: boolean;
+ // Minify CSS in style elements and style attributes (uses clean-css or function specified)
+ minifyCSS?: boolean | CleanCSS.Options | ((text: string) => string);
- // Toggle linting
- lint?: boolean;
+ // Minify JavaScript in script elements and event attributes (uses UglifyJS or function specified)
+ minifyJS?: boolean | UglifyJS.MinifyOptions | ((text: string, inline: boolean) => string);
- // Keep the trailing slash on singleton elements
- keepClosingSlash?: boolean;
+ // Minify URLs in various attributes (uses relateurl or function specified)
+ minifyURLs?: boolean | RelateUrl.Options | ((text: string) => string);
- // Treat attributes in case sensitive manner (useful for custom HTML tags.)
- caseSensitive?: boolean;
+ // Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break. Must be used in conjunction with collapseWhitespace=true
+ preserveLineBreaks?: boolean;
- // Minify Javascript in script elements and on* attributes (uses UglifyJS)
- minifyJS?: boolean | UglifyJS.MinifyOptions;
+ // Prevents the escaping of the values of attributes
+ preventAttributesEscaping?: boolean;
- // Minify CSS in style elements and style attributes (uses clean-css)
- minifyCSS?: boolean | CleanCSS.Options;
+ // Process contents of conditional comments through minifier
+ processConditionalComments?: boolean;
- // Minify URLs in various attributes (uses relateurl)
- minifyURLs?: boolean | RelateUrl.Options;
+ // Array of strings corresponding to types of script elements to process through minifier (e.g. text/ng-template, text/x-handlebars-template, etc.)
+ processScripts?: string[];
- // Array of regex'es that allow to ignore certain comments, when matched
- ignoreCustomComments?: Array;
+ // Type of quote to use for attribute values (' or ")
+ quoteCharacter?: string;
- // Array of regex'es that allow to ignore certain fragments, when matched (e.g. , {{ ... }}, etc.)
- ignoreCustomFragments?: Array;
+ /**
+ * Remove quotes around attributes when possible
+ * @see http://perfectionkills.com/experimenting-with-html-minifier/#remove_attribute_quotes
+ */
+ removeAttributeQuotes?: boolean;
- // Array of strings corresponding to types of script elements to process through minifier (e.g. text/ng-template, text/x-handlebars-template, etc.)
- processScripts?: Array;
+ /**
+ * Strip HTML comments
+ * @see http://perfectionkills.com/experimenting-with-html-minifier/#remove_comments
+ */
+ removeComments?: boolean;
- // Specify a maximum line length. Compressed output will be split by newlines at valid HTML split-points
- maxLineLength?: number;
+ /**
+ * Remove all attributes with whitespace-only values
+ * @see http://perfectionkills.com/experimenting-with-html-minifier/#remove_empty_or_blank_attributes
+ */
+ removeEmptyAttributes?: boolean | ((attrName: string, tag: string) => boolean);
- // Arrays of regex'es that allow to support custom attribute assign expressions (e.g. '')
- customAttrAssign?: Array;
+ /**
+ * Remove all elements with empty contents
+ * @see http://perfectionkills.com/experimenting-with-html-minifier/#remove_empty_elements
+ */
+ removeEmptyElements?: boolean;
- // Arrays of regex'es that allow to support custom attribute surround expressions (e.g. )
- customAttrSurround?: Array;
+ /**
+ * Remove optional tags
+ * @see http://perfectionkills.com/experimenting-with-html-minifier/#remove_optional_tags
+ */
+ removeOptionalTags?: boolean;
- // Regex that specifies custom attribute to strip newlines from (e.g. /ng\-class/)
- customAttrCollapse?: RegExp;
+ /**
+ * Remove attributes when value matches default.
+ * @see http://perfectionkills.com/experimenting-with-html-minifier/#remove_redundant_attributes
+ */
+ removeRedundantAttributes?: boolean;
- // Type of quote to use for attribute values (' or ")
- quoteCharacter?: string;
- }
+ // Remove type="text/javascript" from script tags. Other type attribute values are left intact
+ removeScriptTypeAttributes?: boolean;
+
+ // Remove type="text/css" from style and link tags. Other type attribute values are left intact
+ removeStyleLinkTypeAttributes?: boolean;
+
+ // Remove space between attributes whenever possible. Note that this will result in invalid HTML!
+ removeTagWhitespace?: boolean;
+
+ /**
+ * Sort attributes by frequency
+ *
+ * Minifier options like sortAttributes and sortClassName won't impact the plain-text size
+ * of the output. However, they form long repetitive chains of characters that should improve
+ * compression ratio of gzip used in HTTP compression.
+ *
+ * @see https://github.com/kangax/html-minifier#sorting-attributes--style-classes
+ */
+ sortAttributes?: boolean;
+
+ /**
+ * Sort style classes by frequency
+ *
+ * Minifier options like sortAttributes and sortClassName won't impact the plain-text size
+ * of the output. However, they form long repetitive chains of characters that should improve
+ * compression ratio of gzip used in HTTP compression.
+ *
+ * @see https://github.com/kangax/html-minifier#sorting-attributes--style-classes
+ */
+ sortClassName?: boolean;
+
+ // Trim white space around ignoreCustomFragments
+ trimCustomFragments?: boolean;
+
+ /**
+ * Replaces the doctype with the short (HTML5) doctype
+ * @see http://perfectionkills.com/experimenting-with-html-minifier/#use_short_doctype
+ */
+ useShortDoctype?: boolean;
}
-
-export = HTMLMinifier;
diff --git a/types/html-minifier/tslint.json b/types/html-minifier/tslint.json
index a41bf5d19a..f93cf8562a 100644
--- a/types/html-minifier/tslint.json
+++ b/types/html-minifier/tslint.json
@@ -1,79 +1,3 @@
{
- "extends": "dtslint/dt.json",
- "rules": {
- "adjacent-overload-signatures": false,
- "array-type": false,
- "arrow-return-shorthand": false,
- "ban-types": false,
- "callable-types": false,
- "comment-format": false,
- "dt-header": false,
- "eofline": false,
- "export-just-namespace": false,
- "import-spacing": false,
- "interface-name": false,
- "interface-over-type-literal": false,
- "jsdoc-format": false,
- "max-line-length": false,
- "member-access": false,
- "new-parens": false,
- "no-any-union": false,
- "no-boolean-literal-compare": false,
- "no-conditional-assignment": false,
- "no-consecutive-blank-lines": false,
- "no-construct": false,
- "no-declare-current-package": false,
- "no-duplicate-imports": false,
- "no-duplicate-variable": false,
- "no-empty-interface": false,
- "no-for-in-array": false,
- "no-inferrable-types": false,
- "no-internal-module": false,
- "no-irregular-whitespace": false,
- "no-mergeable-namespace": false,
- "no-misused-new": false,
- "no-namespace": false,
- "no-object-literal-type-assertion": false,
- "no-padding": false,
- "no-redundant-jsdoc": false,
- "no-redundant-jsdoc-2": false,
- "no-redundant-undefined": false,
- "no-reference-import": false,
- "no-relative-import-in-test": false,
- "no-self-import": false,
- "no-single-declare-module": false,
- "no-string-throw": false,
- "no-unnecessary-callback-wrapper": false,
- "no-unnecessary-class": false,
- "no-unnecessary-generics": false,
- "no-unnecessary-qualifier": false,
- "no-unnecessary-type-assertion": false,
- "no-useless-files": false,
- "no-var-keyword": false,
- "no-var-requires": false,
- "no-void-expression": false,
- "no-trailing-whitespace": false,
- "object-literal-key-quotes": false,
- "object-literal-shorthand": false,
- "one-line": false,
- "one-variable-per-declaration": false,
- "only-arrow-functions": false,
- "prefer-conditional-expression": false,
- "prefer-const": false,
- "prefer-declare-function": false,
- "prefer-for-of": false,
- "prefer-method-signature": false,
- "prefer-template": false,
- "radix": false,
- "semicolon": false,
- "space-before-function-paren": false,
- "space-within-parens": false,
- "strict-export-declare-modifiers": false,
- "trim-file": false,
- "triple-equals": false,
- "typedef-whitespace": false,
- "unified-signatures": false,
- "void-return": false,
- "whitespace": false
- }
+ "extends": "dtslint/dt.json"
}
diff --git a/types/html-minifier/v1/html-minifier-tests.ts b/types/html-minifier/v1/html-minifier-tests.ts
new file mode 100644
index 0000000000..4196a870e6
--- /dev/null
+++ b/types/html-minifier/v1/html-minifier-tests.ts
@@ -0,0 +1,8 @@
+
+import * as HTMLMinifier from 'html-minifier';
+const minify = HTMLMinifier.minify;
+
+var result = minify('