minify_html 0.3.0 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50a50e82c1b1eb818544eafc2b5c3e7814ae5ea409433a2e179e4bc1db9a54eb
4
- data.tar.gz: 0ce046bebc23ff8242bc1b97fe956ae214091325820347163d171f1403dd2eef
3
+ metadata.gz: 48311a521c9d5d989ef54034192b7211c85aa28a5e879b72f565ad4e7e42828d
4
+ data.tar.gz: c5e729f7a2976722fb346e427203d0889f73dadbbf5829042bca6d4f8c1044d6
5
5
  SHA512:
6
- metadata.gz: 4f234cc0fb45b7a55094d4316b3fdea5131c9befe71677438f8286109329aca94dad91ef6e0353b01248c0b4d172ddc800bc546d05f12c8538201fdbcfe5c6d0
7
- data.tar.gz: e6ccbe2f3913d0c94de8a7b7b48af353626fdc9c62dbdb46355263a4a42eef752005b5a61f1e9c71d8ff88641564d066009d37be05422958c64741b78513d929
6
+ metadata.gz: e22e109f8faf9d0640b5254692bd81b224456620227a828e2720edb71be01aaea680bccf3e99f8957eee51d93e9d75d284a6996731c2639c6cb0371379491f2a
7
+ data.tar.gz: f4ccccacdc392d990451a9f110911856e2893e757d36318a6c52353f7c518580859f50a679181790dfb8c43b85acae6a18c3fd3053b684d4dda00456d21a4c58
data/README.md CHANGED
@@ -5,13 +5,13 @@ An HTML minifier meticulously optimised for both speed and effectiveness, availa
5
5
  - Advanced minification strategy beats other minifiers with only one pass.
6
6
  - Uses zero memory allocations, SIMD searching, direct tries, and lookup tables.
7
7
  - Well tested with a large test suite and extensive [fuzzing](./fuzz).
8
- - Natively binds to [esbuild](https://github.com/evanw/esbuild) for super fast JS minification.
8
+ - Natively binds to [esbuild](https://github.com/wilsonzlin/esbuild-rs) for super fast JS minification.
9
9
 
10
10
  ## Performance
11
11
 
12
12
  Comparison with [html-minfier](https://github.com/kangax/html-minifier) and [minimize](https://github.com/Swaagie/minimize), run on the top web pages. [See the breakdown here.](./bench)
13
13
 
14
- <img width="415" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.0/average-speeds.png"> <img width="415" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.0/average-sizes.png">
14
+ <img width="415" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.5/js/average-speeds.png"> <img width="415" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.5/js/average-sizes.png">
15
15
 
16
16
  ## Usage
17
17
 
@@ -21,9 +21,9 @@ Precompiled binaries are available for x86-64 Linux, macOS, and Windows.
21
21
 
22
22
  ##### Get
23
23
 
24
- [Linux](https://wilsonl.in/minify-html/bin/0.3.0-linux-x86_64) |
25
- [macOS](https://wilsonl.in/minify-html/bin/0.3.0-macos-x86_64) |
26
- [Windows](https://wilsonl.in/minify-html/bin/0.3.0-windows-x86_64)
24
+ [Linux](https://wilsonl.in/minify-html/bin/0.3.5-linux-x86_64) |
25
+ [macOS](https://wilsonl.in/minify-html/bin/0.3.5-macos-x86_64) |
26
+ [Windows](https://wilsonl.in/minify-html/bin/0.3.5-windows-x86_64.exe)
27
27
 
28
28
  ##### Use
29
29
 
@@ -42,7 +42,7 @@ minify-html --src /path/to/src.html --out /path/to/output.min.html
42
42
 
43
43
  ```toml
44
44
  [dependencies]
45
- minify-html = { version = "0.3.0", features = ["js-esbuild"] }
45
+ minify-html = { version = "0.3.5", features = ["js-esbuild"] }
46
46
  ```
47
47
 
48
48
  Building with the `js-esbuild` feature requires the Go compiler to be installed as well, to build the [JS minifier](https://github.com/evanw/esbuild).
@@ -52,7 +52,7 @@ If the `js-esbuild` feature is not enabled, `cfg.minify_js` will have no effect.
52
52
  ##### Use
53
53
 
54
54
  ```rust
55
- use minify_html::{Cfg, FriendlyError, in_place, copy, with_friendly_error, truncate};
55
+ use minify_html::{Cfg, Error, FriendlyError, in_place, copy, with_friendly_error, truncate};
56
56
 
57
57
  fn main() {
58
58
  let mut code = b"<p> Hello, world! </p>".to_vec();
@@ -64,21 +64,21 @@ fn main() {
64
64
  // but leaves any original code after the minified code intact.
65
65
  match in_place(&mut code, cfg) {
66
66
  Ok(minified_len) => {}
67
- Err((error_type, error_position)) => {}
67
+ Err(Error { error_type, position }) => {}
68
68
  };
69
69
 
70
70
  // Creates a vector copy containing only minified code
71
71
  // instead of minifying in-place.
72
72
  match copy(&code, cfg) {
73
73
  Ok(minified) => {}
74
- Err((error_type, error_position)) => {}
74
+ Err(Error { error_type, position }) => {}
75
75
  };
76
76
 
77
77
  // Minifies a vector in-place, and then truncates the
78
78
  // vector to the new minified length.
79
79
  match truncate(&mut code, cfg) {
80
80
  Ok(()) => {}
81
- Err((error_type, error_position)) => {}
81
+ Err(Error { error_type, position }) => {}
82
82
  };
83
83
 
84
84
  // Identical to `in_place` except with FriendlyError instead.
@@ -123,7 +123,7 @@ yarn add @minify-html/js
123
123
  ```js
124
124
  const minifyHtml = require("@minify-html/js");
125
125
 
126
- const cfg = { minifyJs: false };
126
+ const cfg = minifyHtml.createConfiguration({ minifyJs: false });
127
127
  const minified = minifyHtml.minify("<p> Hello, world! </p>", cfg);
128
128
 
129
129
  // Alternatively, minify in place to avoid copying.
@@ -138,7 +138,7 @@ minify-html is also available for TypeScript:
138
138
  import * as minifyHtml from "@minify-html/js";
139
139
  import * as fs from "fs";
140
140
 
141
- const cfg = { minifyJs: false };
141
+ const cfg = minifyHtml.createConfiguration({ minifyJs: false });
142
142
  const minified = minifyHtml.minify("<p> Hello, world! </p>", cfg);
143
143
  // Or alternatively:
144
144
  const minified = minifyHtml.minifyInPlace(fs.readFileSync("source.html"), cfg);
@@ -161,7 +161,7 @@ Add as a Maven dependency:
161
161
  <dependency>
162
162
  <groupId>in.wilsonl.minifyhtml</groupId>
163
163
  <artifactId>minify-html</artifactId>
164
- <version>0.3.0</version>
164
+ <version>0.3.5</version>
165
165
  </dependency>
166
166
  ```
167
167
 
@@ -448,7 +448,7 @@ Spaces are removed between attributes if possible.
448
448
 
449
449
  ### Entities
450
450
 
451
- Entities are decoded if valid (see relevant parsing section) and their decoded characters as UTF-8 is shorter or equal in length.
451
+ Entities are decoded if they're valid and shorter or equal in length when decoded.
452
452
 
453
453
  Numeric entities that do not refer to a valid [Unicode Scalar Value](https://www.unicode.org/glossary/#unicode_scalar_value) are replaced with the [replacement character](https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character).
454
454
 
@@ -478,33 +478,10 @@ However, there are some syntax requirements for speed and sanity.
478
478
 
479
479
  ### Tags
480
480
 
481
- Tag names are case sensitive. For example, this means that `P` won't be recognised as a content element, `bR` won't be considered as a void tag, and the contents of `Script` won't be parsed as JavaScript.
482
-
483
- Tags must not be [omitted](https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission). Void tags must not have a separate closing tag e.g. `</input>`.
484
-
485
- ### Entities
486
-
487
- Well-formed entities are decoded, including in attribute values.
488
-
489
- They are interpreted as characters representing their decoded value. This means that `&#9;` is considered a whitespace character and could be minified.
490
-
491
- Malformed entities are interpreted literally as a sequence of characters.
492
-
493
- If a named entity is an invalid reference as per the [specification](https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references), it is considered malformed.
494
-
495
- Numeric character references that do not reference a valid [Unicode Scalar Value](https://www.unicode.org/glossary/#unicode_scalar_value) are considered malformed.
496
-
497
- ### Attributes
498
-
499
- Backticks (`` ` ``) are not valid quote marks and not interpreted as such.
500
- However, backticks are valid attribute value quotes in Internet Explorer.
501
-
502
- Special handling of some attributes require case sensitive names and values. For example, `CLASS` won't be recognised as an attribute to minify, and `type="Text/JavaScript"` on a `<script>` will not be removed.
481
+ Opening tags must not be [omitted](https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission).
503
482
 
504
483
  ### Script and style
505
484
 
506
- `script` and `style` tags must be closed with `</script>` and `</style>` respectively (case sensitive).
507
-
508
485
  minify-html does **not** handle [escaped and double-escaped](./notes/Script%20data.md) script content.
509
486
 
510
487
  ## Issues and contributions
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minify_html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wilson Lin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-24 00:00:00.000000000 Z
11
+ date: 2020-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fiddle