Skip to content

Commit 5a19731

Browse files
committed
Rename options to match minify_html v0.15.0
1 parent a8c6ac6 commit 5a19731

File tree

4 files changed

+41
-59
lines changed

4 files changed

+41
-59
lines changed

README.md

+10-22
Original file line numberDiff line numberDiff line change
@@ -21,41 +21,29 @@ plugins:
2121
- minify_html
2222
```
2323
24-
## Default options
24+
## Options
2525
26-
The default options aim for the best possible minification while maintaining compliance with the specification.
26+
A description of all options is available in the [minify_html docs](https://docs.rs/minify-html/0.15.0/minify_html/struct.Cfg.html#fields).
27+
28+
The default plugin options are aimed at the best possible minification while maintaining compliance with the specification:
2729
2830
```yaml
2931
plugins:
3032
- search
3133
- minify_html:
32-
# Allow unquoted attribute values in the output to contain characters prohibited by the WHATWG specification (https://html.spec.whatwg.org/multipage/syntax.html#attributes-2). These will still be parsed correctly by almost all browsers.
33-
allow_noncompliant_unquoted_attribute_values: false
34-
# Allow removing_spaces between attributes when possible, which may not be spec compliant. These will still be parsed correctly by almost all browsers.
35-
allow_removing_spaces_between_attributes: false
36-
# Do not omit closing tags when possible.
34+
do_not_minify_doctype: true
35+
ensure_spec_compliant_unquoted_attribute_values: true
3736
keep_closing_tags: false
38-
# Keep all comments.
39-
keep_comments: false
40-
# Do not omit `<html>` and `<head>` opening tags when they don't have attributes.
4137
keep_html_and_head_opening_tags: false
42-
# Keep `type=text` attribute name and value on `<input>` elements.
38+
keep_spaces_between_attributes: true
39+
keep_comments: false
4340
keep_input_type_text_attr: true
44-
# Keep SSI comments.
4541
keep_ssi_comments: false
46-
# Minify CSS in `<style>` tags and `style` attributes using lightningcss (https://github.com/parcel-bundler/lightningcss).
47-
minify_css: true
48-
# Minify DOCTYPEs. Minified DOCTYPEs may not be spec compliant, but will still be parsed correctly by almost all browsers.
49-
minify_doctype: false
50-
# Minify JavaScript in `<script>` tags using minify-js (https://github.com/wilsonzlin/minify-js).
51-
minify_js: true
52-
# When `{{`, `{#`, or `{%` are seen in content, all source code until the subsequent matching closing `}}`, `#}`, or `%}` respectively gets piped through untouched.
5342
preserve_brace_template_syntax: false
54-
# When `<%` is seen in content, all source code until the subsequent matching closing `%>` gets piped through untouched.
5543
preserve_chevron_percent_template_syntax: false
56-
# Remove all bangs.
44+
minify_css: true
45+
minify_js: true
5746
remove_bangs: false
58-
# Remove all processing instructions.
5947
remove_processing_instructions: false
6048
```
6149

python/mkdocs_minify_html_plugin/_minify_html.pyi

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@ def minify(
22
code: str,
33
/,
44
*,
5-
allow_noncompliant_unquoted_attribute_values: bool,
6-
# allow_optimal_entities: bool,
7-
allow_removing_spaces_between_attributes: bool,
5+
do_not_minify_doctype: bool,
6+
ensure_spec_compliant_unquoted_attribute_values: bool,
87
keep_closing_tags: bool,
9-
keep_comments: bool,
108
keep_html_and_head_opening_tags: bool,
9+
keep_spaces_between_attributes: bool,
10+
keep_comments: bool,
1111
keep_input_type_text_attr: bool,
1212
keep_ssi_comments: bool,
13-
minify_css: bool,
14-
minify_doctype: bool,
15-
minify_js: bool,
1613
preserve_brace_template_syntax: bool,
1714
preserve_chevron_percent_template_syntax: bool,
15+
minify_css: bool,
16+
minify_js: bool,
1817
remove_bangs: bool,
1918
remove_processing_instructions: bool,
2019
) -> str: ...

python/mkdocs_minify_html_plugin/plugin.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,18 @@
1414

1515

1616
class MinifyHtmlConfig(Config):
17-
allow_noncompliant_unquoted_attribute_values = c.Type(bool, default=False)
18-
# allow_optimal_entities = c.Type(bool, default=False)
19-
allow_removing_spaces_between_attributes = c.Type(bool, default=False)
17+
do_not_minify_doctype = c.Type(bool, default=True)
18+
ensure_spec_compliant_unquoted_attribute_values = c.Type(bool, default=True)
2019
keep_closing_tags = c.Type(bool, default=False)
21-
keep_comments = c.Type(bool, default=False)
2220
keep_html_and_head_opening_tags = c.Type(bool, default=False)
21+
keep_spaces_between_attributes = c.Type(bool, default=True)
22+
keep_comments = c.Type(bool, default=False)
2323
keep_input_type_text_attr = c.Type(bool, default=True)
2424
keep_ssi_comments = c.Type(bool, default=False)
25-
minify_css = c.Type(bool, default=True)
26-
minify_doctype = c.Type(bool, default=False)
27-
minify_js = c.Type(bool, default=True)
2825
preserve_brace_template_syntax = c.Type(bool, default=False)
2926
preserve_chevron_percent_template_syntax = c.Type(bool, default=False)
27+
minify_css = c.Type(bool, default=True)
28+
minify_js = c.Type(bool, default=True)
3029
remove_bangs = c.Type(bool, default=False)
3130
remove_processing_instructions = c.Type(bool, default=False)
3231

src/lib.rs

+19-23
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,53 @@ use pyo3::prelude::*;
77
code,
88
/,
99
*,
10-
allow_noncompliant_unquoted_attribute_values,
11-
// allow_optimal_entities,
12-
allow_removing_spaces_between_attributes,
10+
do_not_minify_doctype,
11+
ensure_spec_compliant_unquoted_attribute_values,
1312
keep_closing_tags,
14-
keep_comments,
1513
keep_html_and_head_opening_tags,
14+
keep_spaces_between_attributes,
15+
keep_comments,
1616
keep_input_type_text_attr,
1717
keep_ssi_comments,
18-
minify_css,
19-
minify_doctype,
20-
minify_js,
2118
preserve_brace_template_syntax,
2219
preserve_chevron_percent_template_syntax,
20+
minify_css,
21+
minify_js,
2322
remove_bangs,
24-
remove_processing_instructions
23+
remove_processing_instructions,
2524
))]
2625
fn minify(
2726
py: Python,
2827
code: &str,
29-
allow_noncompliant_unquoted_attribute_values: bool,
30-
// allow_optimal_entities: bool,
31-
allow_removing_spaces_between_attributes: bool,
28+
do_not_minify_doctype: bool,
29+
ensure_spec_compliant_unquoted_attribute_values: bool,
3230
keep_closing_tags: bool,
33-
keep_comments: bool,
3431
keep_html_and_head_opening_tags: bool,
32+
keep_spaces_between_attributes: bool,
33+
keep_comments: bool,
3534
keep_input_type_text_attr: bool,
3635
keep_ssi_comments: bool,
37-
minify_css: bool,
38-
minify_doctype: bool,
39-
minify_js: bool,
4036
preserve_brace_template_syntax: bool,
4137
preserve_chevron_percent_template_syntax: bool,
38+
minify_css: bool,
39+
minify_js: bool,
4240
remove_bangs: bool,
4341
remove_processing_instructions: bool,
4442
) -> String {
4543
py.allow_threads(move || {
4644
let cfg = ::minify_html::Cfg {
47-
do_not_minify_doctype: !minify_doctype,
48-
ensure_spec_compliant_unquoted_attribute_values:
49-
!allow_noncompliant_unquoted_attribute_values,
45+
do_not_minify_doctype,
46+
ensure_spec_compliant_unquoted_attribute_values,
5047
keep_closing_tags,
51-
keep_comments,
5248
keep_html_and_head_opening_tags,
49+
keep_spaces_between_attributes,
50+
keep_comments,
5351
keep_input_type_text_attr,
54-
keep_spaces_between_attributes:
55-
!allow_removing_spaces_between_attributes,
5652
keep_ssi_comments,
57-
minify_css,
58-
minify_js,
5953
preserve_brace_template_syntax,
6054
preserve_chevron_percent_template_syntax,
55+
minify_css,
56+
minify_js,
6157
remove_bangs,
6258
remove_processing_instructions,
6359
};

0 commit comments

Comments
 (0)