kangax / kangax/html-minifier

Option to enable `collapseInlineTagWhitespace` on a tag-by-tag basis

Open
#691 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5k
Forks
577
PR merge metrics
No merged PRs in 30d

Description

Continued from https://github.com/kangax/html-minifier/issues/273#issuecomment-234398294

I'm currently upgrading from [grunt-angular-templates@0.3.12](https://github.com/ericclemmons/grunt-angular-templates/tree/v0.3.12) (which uses [html-minifier@~0.5.2](https://github.com/kangax/html-minifier/tree/v0.5.6)) to [html-loader@0.4.3](https://github.com/webpack/html-loader/tree/v0.4.3) (which uses [html-minifier@^1.0.0](https://github.com/kangax/html-minifier/tree/v1.5.0)), and facing this issue:

Using `collapseWhitespace: true`, html-minifier@0.5.6 (my desired behaviour) preserves whitespace between `` elements but removes it around `` elements:

``` js
require('html-minifier').minify(
'foo bar two',
{ collapseWhitespace: true }
);
// 'foo bartwo'
```

However, I can't find a way to configure html-minifier@1.5.0 to behave the same way. It can either preserve whitespace between all inline elements:

``` js
require('html-minifier').minify(
'foo bar two',
{ collapseWhitespace: true }
);
// 'foo bar two'
```

or remove all whitespace between inline elements:

``` js
require('html-minifier').minify(
'foo bar two',
{ collapseWhitespace: true, collapseInlineTagWhitespace: true }
);
// 'foobartwo'
```

---

Is there a way to configure html-minifier@1.5.0 (or a later version) to remove whitespace around only certain inline elements? (In my case, only `` elements)

If not, what would be the best option to add to make this configurable? `customCollapseTagWhitespace` as an array of tag names for which to collapse surrounding whitespace? Or `preserveInlineTagWhitespace` as a list of tag names which the `collapseInlineTagWhitespace` rule should ignore?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.