minify_html 0.3.4 → 0.3.9

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: a44a2ef6e047dd840c347c217df9cd5de9da6328bf89a8106d4b48ca4a386903
4
- data.tar.gz: a8851749a6dc8c01123bfdc4a4d1d0ce5bbf8d78bbd84775e94f7de8cadfcaa5
3
+ metadata.gz: 4bd2c89ec4f024b67cea95c499fcf8f0cac743c0b186920ea9ed0400b36d5355
4
+ data.tar.gz: 2fd88803a4097495d32c026999810e36178fbb43c39af5cdf733d3e58575ba5b
5
5
  SHA512:
6
- metadata.gz: 5463c9b94824ef30eb6a900f68620814d86aef0250651778ef9e7837f09f2d3a1379daf8e17d905e76035fb6faf453e1d2944e5fcbdf6b9437c8565408dd32fb
7
- data.tar.gz: 9d11db9dce3787239a1b2d0ef7886440c452fcc3f5f6ecad37121995493ce0d3ea669b6a96151afa45fcc8acb6dc8d4eedf5d7cfdfc6771f520665d0be447bb5
6
+ metadata.gz: ba97f98317f76967eb99d4ef6d4db68eeb900e2924fef550c01cee0744a60540a8b79ecf765075cf016dc16f0cfcd10ea1f4e106c5d4a5de443fb7432b8d59f9
7
+ data.tar.gz: 962ea48bfd7ecdc39b42a60067c415fbadb8d2d3e7160239152052b0c250a79694afc82ccc499dba084c3cf9d497ef974b43608e2663e9f4d078b81bfb126e6a
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # minify-html
2
2
 
3
- An HTML minifier meticulously optimised for both speed and effectiveness, available for Rust, Node.js, Python, Java, and Ruby.
3
+ An HTML minifier meticulously optimised for both speed and effectiveness written in Rust.
4
+ Comes with native bindings to Node.js, Python, Java, and Ruby.
4
5
 
5
6
  - Advanced minification strategy beats other minifiers with only one pass.
6
7
  - Uses zero memory allocations, SIMD searching, direct tries, and lookup tables.
@@ -11,7 +12,7 @@ An HTML minifier meticulously optimised for both speed and effectiveness, availa
11
12
 
12
13
  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
14
 
14
- <img width="415" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.4/js/average-speeds.png"> <img width="415" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.4/js/average-sizes.png">
15
+ <img width="415" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.9/js/average-speeds.png"> <img width="415" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.9/js/average-sizes.png">
15
16
 
16
17
  ## Usage
17
18
 
@@ -21,9 +22,9 @@ Precompiled binaries are available for x86-64 Linux, macOS, and Windows.
21
22
 
22
23
  ##### Get
23
24
 
24
- [Linux](https://wilsonl.in/minify-html/bin/0.3.4-linux-x86_64) |
25
- [macOS](https://wilsonl.in/minify-html/bin/0.3.4-macos-x86_64) |
26
- [Windows](https://wilsonl.in/minify-html/bin/0.3.4-windows-x86_64.exe)
25
+ [Linux](https://wilsonl.in/minify-html/bin/0.3.9-linux-x86_64) |
26
+ [macOS](https://wilsonl.in/minify-html/bin/0.3.9-macos-x86_64) |
27
+ [Windows](https://wilsonl.in/minify-html/bin/0.3.9-windows-x86_64.exe)
27
28
 
28
29
  ##### Use
29
30
 
@@ -42,58 +43,16 @@ minify-html --src /path/to/src.html --out /path/to/output.min.html
42
43
 
43
44
  ```toml
44
45
  [dependencies]
45
- minify-html = { version = "0.3.4", features = ["js-esbuild"] }
46
+ minify-html = { version = "0.3.9", features = ["js-esbuild"] }
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).
49
+ Building with the `js-esbuild` feature requires the Go compiler to be installed as well, to build the [JS minifier](https://github.com/wilsonzlin/esbuild-rs).
49
50
 
50
51
  If the `js-esbuild` feature is not enabled, `cfg.minify_js` will have no effect.
51
52
 
52
53
  ##### Use
53
54
 
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
- ```
55
+ Check out the [docs](https://docs.rs/minify-html) for API and usage examples.
97
56
 
98
57
  </details>
99
58
 
@@ -161,21 +120,24 @@ Add as a Maven dependency:
161
120
  <dependency>
162
121
  <groupId>in.wilsonl.minifyhtml</groupId>
163
122
  <artifactId>minify-html</artifactId>
164
- <version>0.3.4</version>
123
+ <version>0.3.9</version>
165
124
  </dependency>
166
125
  ```
167
126
 
168
127
  ##### Use
169
128
 
170
129
  ```java
130
+ import in.wilsonl.minifyhtml.Configuration;
171
131
  import in.wilsonl.minifyhtml.MinifyHtml;
132
+ import in.wilsonl.minifyhtml.SyntaxException;
172
133
 
173
- MinifyHtml.Configuration cfg = new MinifyHtml.Configuration.Builder()
134
+ Configuration cfg = new Configuration.Builder()
174
135
  .setMinifyJs(false)
175
136
  .build();
137
+
176
138
  try {
177
139
  String minified = MinifyHtml.minify("<p> Hello, world! </p>", cfg);
178
- } catch (MinifyHtml.SyntaxException e) {
140
+ } catch (SyntaxException e) {
179
141
  System.err.println(e.getMessage());
180
142
  }
181
143
 
@@ -448,16 +410,13 @@ Spaces are removed between attributes if possible.
448
410
 
449
411
  ### Entities
450
412
 
451
- Entities are decoded if valid (see relevant parsing section) and their decoded characters as UTF-8 is shorter or equal in length.
452
- Some entities are longer decoded than encoded, so they're left encoded.
413
+ Entities are decoded if they're valid and shorter or equal in length when decoded.
453
414
 
454
415
  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).
455
416
 
456
417
  If an entity is unintentionally formed after decoding, the leading ampersand is encoded, e.g. `&&#97;&#109;&#112;;` becomes `&ampamp;`. This is done as `&amp` is equal to or shorter than all other entity representations of characters part of an entity (`[&#a-zA-Z0-9;]`), and there is no other conflicting entity name that starts with `amp`.
457
418
 
458
- It's possible to get an unintentional entity after removing comments, e.g. `&am<!-- -->p`.
459
-
460
- Left chevrons after any decoding in text are encoded to `&LT` if possible or `&LT;` otherwise.
419
+ Note that it's possible to get an unintentional entity after removing comments, e.g. `&am<!-- -->p`; minify-html will **not** encode the leading ampersand.
461
420
 
462
421
  ### Comments
463
422
 
@@ -469,44 +428,9 @@ Bangs, [processing instructions](https://en.wikipedia.org/wiki/Processing_Instru
469
428
 
470
429
  ## Parsing
471
430
 
472
- Only UTF-8/ASCII-encoded HTML code is supported.
473
-
474
- minify-html does no syntax checking or standards enforcement for performance and code complexity reasons.
475
-
476
- 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>`
477
-
478
- However, there are some syntax requirements for speed and sanity.
479
-
480
- ### Tags
481
-
482
- 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.
483
-
484
- 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>`.
485
-
486
- ### Entities
487
-
488
- Well-formed entities are decoded, including in attribute values.
489
-
490
- They are interpreted as characters representing their decoded value. This means that `&#9;` is considered a whitespace character and could be minified.
491
-
492
- Malformed entities are interpreted literally as a sequence of characters.
493
-
494
- 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.
495
-
496
- Numeric character references that do not reference a valid [Unicode Scalar Value](https://www.unicode.org/glossary/#unicode_scalar_value) are considered malformed.
497
-
498
- ### Attributes
499
-
500
- Backticks (`` ` ``) are not valid quote marks and not interpreted as such.
501
- However, backticks are valid attribute value quotes in Internet Explorer.
502
-
503
- 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.
504
-
505
- ### Script and style
506
-
507
- `script` and `style` tags must be closed with `</script>` and `</style>` respectively (case sensitive).
508
-
509
- minify-html does **not** handle [escaped and double-escaped](./notes/Script%20data.md) script content.
431
+ - Input must be UTF-8.
432
+ - Opening tags must not be [omitted](https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission).
433
+ - [Escaped and double-escaped](./notes/Script%20data.md) script content are not supported.
510
434
 
511
435
  ## Issues and contributions
512
436
 
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.4
4
+ version: 0.3.9
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-29 00:00:00.000000000 Z
11
+ date: 2020-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fiddle