minify_html 0.3.2 → 0.3.7

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: 5a376f571d2d926f3bac082d39b5bc61fa361a75e2f38ac1c91e11f6e917fb6f
4
- data.tar.gz: 5a4d174fe6a246c5711df1ce514df7c4a4f5072059b10a7121ad2b205c70ec5e
3
+ metadata.gz: 0fb2d032ff7df2cda92929239361409352ecf8bb54d624d386f8f5cd29f48487
4
+ data.tar.gz: cafc23354545a412a6cd20eeb823f66432c1a849d8fa45c8892f33e17204f547
5
5
  SHA512:
6
- metadata.gz: 562683934fff79dcbd2136eecf8cda7f56a785ce70a6aed79c1e77467fbe852291bf59715920705bee0f8f8e905010e2ff5861db5c1799195c755c89e0d0e436
7
- data.tar.gz: 63aef7ee0683604390ad15f11e4345d107584e012c04de42e166b3a4a5ed5152a0e4137c496bce61e19cc45f59190304671c093bb2f922a7727acc23e2fea9e6
6
+ metadata.gz: 9cbbd22cfad76f3f9c0649b699facb83a78b264d5f132cb6a445b31831da7f62ad9369de6680df02dcbc3fdf3d0a656e1f5f87c46301072491e96eac17454944
7
+ data.tar.gz: b57f2538fc5a7aebc7d0a972db31b72f1813bc38d4e5f6241b2eaa5e77e2bde36c7be54d23bf7eb2aa680874848e1814b3042bd4389583197593453029ae6aad
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.2/js/average-speeds.png"> <img width="415" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.2/js/average-sizes.png">
14
+ <img width="415" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.7/js/average-speeds.png"> <img width="415" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.7/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.2-linux-x86_64) |
25
- [macOS](https://wilsonl.in/minify-html/bin/0.3.2-macos-x86_64) |
26
- [Windows](https://wilsonl.in/minify-html/bin/0.3.2-windows-x86_64.exe)
24
+ [Linux](https://wilsonl.in/minify-html/bin/0.3.7-linux-x86_64) |
25
+ [macOS](https://wilsonl.in/minify-html/bin/0.3.7-macos-x86_64) |
26
+ [Windows](https://wilsonl.in/minify-html/bin/0.3.7-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.2", features = ["js-esbuild"] }
45
+ minify-html = { version = "0.3.7", 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).
@@ -51,49 +51,7 @@ If the `js-esbuild` feature is not enabled, `cfg.minify_js` will have no effect.
51
51
 
52
52
  ##### Use
53
53
 
54
- ```rust
55
- use minify_html::{Cfg, Error, FriendlyError, in_place, copy, with_friendly_error, truncate};
56
-
57
- fn main() {
58
- let mut code = b"<p> Hello, world! </p>".to_vec();
59
- let cfg = &Cfg {
60
- minify_js: false,
61
- };
62
-
63
- // Minifies a slice in-place and returns the new minified length,
64
- // but leaves any original code after the minified code intact.
65
- match in_place(&mut code, cfg) {
66
- Ok(minified_len) => {}
67
- Err(Error { error_type, position }) => {}
68
- };
69
-
70
- // Creates a vector copy containing only minified code
71
- // instead of minifying in-place.
72
- match copy(&code, cfg) {
73
- Ok(minified) => {}
74
- Err(Error { error_type, position }) => {}
75
- };
76
-
77
- // Minifies a vector in-place, and then truncates the
78
- // vector to the new minified length.
79
- match truncate(&mut code, cfg) {
80
- Ok(()) => {}
81
- Err(Error { error_type, position }) => {}
82
- };
83
-
84
- // Identical to `in_place` except with FriendlyError instead.
85
- // `code_context` is a string of a visual representation of the source,
86
- // with line numbers and position markers to aid in debugging syntax.
87
- match with_friendly_error(&mut code, cfg) {
88
- Ok(minified_len) => {}
89
- Err(FriendlyError { position, message, code_context }) => {
90
- eprintln!("Failed at character {}:", position);
91
- eprintln!("{}", message);
92
- eprintln!("{}", code_context);
93
- }
94
- };
95
- }
96
- ```
54
+ Check out the [docs](https://docs.rs/minify-html) for API and usage examples.
97
55
 
98
56
  </details>
99
57
 
@@ -161,7 +119,7 @@ Add as a Maven dependency:
161
119
  <dependency>
162
120
  <groupId>in.wilsonl.minifyhtml</groupId>
163
121
  <artifactId>minify-html</artifactId>
164
- <version>0.3.2</version>
122
+ <version>0.3.7</version>
165
123
  </dependency>
166
124
  ```
167
125
 
@@ -448,7 +406,7 @@ Spaces are removed between attributes if possible.
448
406
 
449
407
  ### Entities
450
408
 
451
- Entities are decoded if valid (see relevant parsing section) and their decoded characters as UTF-8 is shorter or equal in length.
409
+ Entities are decoded if they're valid and shorter or equal in length when decoded.
452
410
 
453
411
  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
412
 
@@ -468,44 +426,9 @@ Bangs, [processing instructions](https://en.wikipedia.org/wiki/Processing_Instru
468
426
 
469
427
  ## Parsing
470
428
 
471
- Only UTF-8/ASCII-encoded HTML code is supported.
472
-
473
- minify-html does no syntax checking or standards enforcement for performance and code complexity reasons.
474
-
475
- For example, this means that it's not an error to have self-closing tags, declare multiple `<body>` elements, use incorrect attribute names and values, or write something like `<br>alert('');</br>`
476
-
477
- However, there are some syntax requirements for speed and sanity.
478
-
479
- ### Tags
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.
503
-
504
- ### Script and style
505
-
506
- `script` and `style` tags must be closed with `</script>` and `</style>` respectively (case sensitive).
507
-
508
- minify-html does **not** handle [escaped and double-escaped](./notes/Script%20data.md) script content.
429
+ - Input must be UTF-8.
430
+ - Opening tags must not be [omitted](https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission).
431
+ - [Escaped and double-escaped](./notes/Script%20data.md) script content are not supported.
509
432
 
510
433
  ## Issues and contributions
511
434
 
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.2
4
+ version: 0.3.7
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-26 00:00:00.000000000 Z
11
+ date: 2020-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fiddle