mkdocs-minify-html-plugin 0.3.14__tar.gz → 0.3.16__tar.gz
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.
- {mkdocs_minify_html_plugin-0.3.14 → mkdocs_minify_html_plugin-0.3.16}/Cargo.lock +1 -1
- {mkdocs_minify_html_plugin-0.3.14 → mkdocs_minify_html_plugin-0.3.16}/Cargo.toml +1 -1
- {mkdocs_minify_html_plugin-0.3.14 → mkdocs_minify_html_plugin-0.3.16}/PKG-INFO +6 -6
- {mkdocs_minify_html_plugin-0.3.14 → mkdocs_minify_html_plugin-0.3.16}/README.md +5 -5
- {mkdocs_minify_html_plugin-0.3.14 → mkdocs_minify_html_plugin-0.3.16}/pyproject.toml +1 -1
- mkdocs_minify_html_plugin-0.3.16/python/mkdocs_minify_html_plugin/_minify_html.pyi +24 -0
- {mkdocs_minify_html_plugin-0.3.14 → mkdocs_minify_html_plugin-0.3.16}/python/mkdocs_minify_html_plugin/plugin.py +10 -3
- mkdocs_minify_html_plugin-0.3.16/src/lib.rs +130 -0
- mkdocs_minify_html_plugin-0.3.14/python/mkdocs_minify_html_plugin/_minify_html.pyi +0 -20
- mkdocs_minify_html_plugin-0.3.14/src/lib.rs +0 -119
- {mkdocs_minify_html_plugin-0.3.14 → mkdocs_minify_html_plugin-0.3.16}/LICENSE +0 -0
- {mkdocs_minify_html_plugin-0.3.14 → mkdocs_minify_html_plugin-0.3.16}/LICENSE-THIRD-PARTY +0 -0
- {mkdocs_minify_html_plugin-0.3.14 → mkdocs_minify_html_plugin-0.3.16}/python/mkdocs_minify_html_plugin/__init__.py +0 -0
- {mkdocs_minify_html_plugin-0.3.14 → mkdocs_minify_html_plugin-0.3.16}/python/mkdocs_minify_html_plugin/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocs-minify-html-plugin
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.16
|
|
4
4
|
Classifier: Framework :: MkDocs
|
|
5
5
|
Classifier: Natural Language :: English
|
|
6
6
|
Classifier: Operating System :: MacOS
|
|
@@ -27,17 +27,19 @@ Requires-Python: >=3.11
|
|
|
27
27
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
28
28
|
Project-URL: repository, https://github.com/monosans/mkdocs-minify-html-plugin
|
|
29
29
|
|
|
30
|
-
# mkdocs-minify-html-plugin
|
|
30
|
+
# <img src="https://raw.githubusercontent.com/monosans/mkdocs-minify-html-plugin/main/assets/logo.svg" alt="" width="40" align="top"> mkdocs-minify-html-plugin
|
|
31
31
|
|
|
32
32
|
[](https://pepy.tech/project/mkdocs-minify-html-plugin)
|
|
33
33
|
|
|
34
|
-
MkDocs plugin
|
|
34
|
+
MkDocs plugin that minifies the built HTML pages, including inline CSS and JS, with [minify-html](https://github.com/wilsonzlin/minify-html).
|
|
35
35
|
|
|
36
36
|
## Usage
|
|
37
37
|
|
|
38
38
|
Install:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
+
uv add --dev mkdocs-minify-html-plugin
|
|
42
|
+
# or
|
|
41
43
|
pip install -U mkdocs-minify-html-plugin
|
|
42
44
|
```
|
|
43
45
|
|
|
@@ -51,9 +53,7 @@ plugins:
|
|
|
51
53
|
|
|
52
54
|
## Options
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
The default plugin options are aimed at the best possible minification while maintaining compliance with the specification:
|
|
56
|
+
The options are the fields of minify-html's [`Cfg`](https://docs.rs/minify-html/latest/minify_html/struct.Cfg.html#fields). The defaults aim for the smallest output that stays spec-compliant:
|
|
57
57
|
|
|
58
58
|
```yaml
|
|
59
59
|
plugins:
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
# mkdocs-minify-html-plugin
|
|
1
|
+
# <img src="https://raw.githubusercontent.com/monosans/mkdocs-minify-html-plugin/main/assets/logo.svg" alt="" width="40" align="top"> mkdocs-minify-html-plugin
|
|
2
2
|
|
|
3
3
|
[](https://pepy.tech/project/mkdocs-minify-html-plugin)
|
|
4
4
|
|
|
5
|
-
MkDocs plugin
|
|
5
|
+
MkDocs plugin that minifies the built HTML pages, including inline CSS and JS, with [minify-html](https://github.com/wilsonzlin/minify-html).
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
9
9
|
Install:
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
+
uv add --dev mkdocs-minify-html-plugin
|
|
13
|
+
# or
|
|
12
14
|
pip install -U mkdocs-minify-html-plugin
|
|
13
15
|
```
|
|
14
16
|
|
|
@@ -22,9 +24,7 @@ plugins:
|
|
|
22
24
|
|
|
23
25
|
## Options
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
The default plugin options are aimed at the best possible minification while maintaining compliance with the specification:
|
|
27
|
+
The options are the fields of minify-html's [`Cfg`](https://docs.rs/minify-html/latest/minify_html/struct.Cfg.html#fields). The defaults aim for the smallest output that stays spec-compliant:
|
|
28
28
|
|
|
29
29
|
```yaml
|
|
30
30
|
plugins:
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from typing import final
|
|
2
|
+
|
|
3
|
+
@final
|
|
4
|
+
class Minifier:
|
|
5
|
+
def __init__(
|
|
6
|
+
self,
|
|
7
|
+
*,
|
|
8
|
+
allow_noncompliant_unquoted_attribute_values: bool,
|
|
9
|
+
allow_optimal_entities: bool,
|
|
10
|
+
allow_removing_spaces_between_attributes: bool,
|
|
11
|
+
keep_closing_tags: bool,
|
|
12
|
+
keep_comments: bool,
|
|
13
|
+
keep_html_and_head_opening_tags: bool,
|
|
14
|
+
keep_input_type_text_attr: bool,
|
|
15
|
+
keep_ssi_comments: bool,
|
|
16
|
+
minify_css: bool,
|
|
17
|
+
minify_doctype: bool,
|
|
18
|
+
minify_js: bool,
|
|
19
|
+
preserve_brace_template_syntax: bool,
|
|
20
|
+
preserve_chevron_percent_template_syntax: bool,
|
|
21
|
+
remove_bangs: bool,
|
|
22
|
+
remove_processing_instructions: bool,
|
|
23
|
+
) -> None: ...
|
|
24
|
+
def minify(self, code: str, /) -> str: ...
|
|
@@ -8,7 +8,7 @@ from mkdocs.config.defaults import MkDocsConfig
|
|
|
8
8
|
from mkdocs.plugins import BasePlugin
|
|
9
9
|
from mkdocs.structure.pages import Page
|
|
10
10
|
|
|
11
|
-
from mkdocs_minify_html_plugin._minify_html import
|
|
11
|
+
from mkdocs_minify_html_plugin._minify_html import Minifier
|
|
12
12
|
|
|
13
13
|
if sys.version_info >= (3, 12):
|
|
14
14
|
from typing import override
|
|
@@ -35,16 +35,23 @@ class MinifyHtmlConfig(Config):
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
class MinifyHtmlPlugin(BasePlugin[MinifyHtmlConfig]):
|
|
38
|
+
_minifier: Minifier
|
|
39
|
+
|
|
40
|
+
@override
|
|
41
|
+
def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
|
|
42
|
+
self._minifier = Minifier(**self.config)
|
|
43
|
+
return config
|
|
44
|
+
|
|
38
45
|
@override
|
|
39
46
|
def on_post_page(
|
|
40
47
|
self, output: str, *, page: Page, config: MkDocsConfig
|
|
41
48
|
) -> str | None:
|
|
42
|
-
return minify(output
|
|
49
|
+
return self._minifier.minify(output)
|
|
43
50
|
|
|
44
51
|
@override
|
|
45
52
|
def on_post_template(
|
|
46
53
|
self, output_content: str, *, template_name: str, config: MkDocsConfig
|
|
47
54
|
) -> str | None:
|
|
48
55
|
if template_name.endswith(".html"):
|
|
49
|
-
return minify(output_content
|
|
56
|
+
return self._minifier.minify(output_content)
|
|
50
57
|
return output_content
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#![deny(
|
|
2
|
+
warnings,
|
|
3
|
+
deprecated_safe,
|
|
4
|
+
future_incompatible,
|
|
5
|
+
keyword_idents,
|
|
6
|
+
let_underscore,
|
|
7
|
+
nonstandard_style,
|
|
8
|
+
refining_impl_trait,
|
|
9
|
+
rust_2018_compatibility,
|
|
10
|
+
rust_2018_idioms,
|
|
11
|
+
rust_2021_compatibility,
|
|
12
|
+
rust_2024_compatibility,
|
|
13
|
+
unused,
|
|
14
|
+
clippy::all,
|
|
15
|
+
clippy::pedantic,
|
|
16
|
+
clippy::restriction,
|
|
17
|
+
clippy::nursery,
|
|
18
|
+
clippy::cargo
|
|
19
|
+
)]
|
|
20
|
+
#![allow(
|
|
21
|
+
clippy::absolute_paths,
|
|
22
|
+
clippy::allow_attributes_without_reason,
|
|
23
|
+
clippy::arbitrary_source_item_ordering,
|
|
24
|
+
clippy::as_conversions,
|
|
25
|
+
clippy::blanket_clippy_restriction_lints,
|
|
26
|
+
clippy::cast_precision_loss,
|
|
27
|
+
clippy::cognitive_complexity,
|
|
28
|
+
clippy::else_if_without_else,
|
|
29
|
+
clippy::float_arithmetic,
|
|
30
|
+
clippy::implicit_return,
|
|
31
|
+
clippy::integer_division_remainder_used,
|
|
32
|
+
clippy::iter_over_hash_type,
|
|
33
|
+
clippy::min_ident_chars,
|
|
34
|
+
clippy::missing_docs_in_private_items,
|
|
35
|
+
clippy::mod_module_files,
|
|
36
|
+
clippy::multiple_crate_versions,
|
|
37
|
+
clippy::pattern_type_mismatch,
|
|
38
|
+
clippy::question_mark_used,
|
|
39
|
+
clippy::separated_literal_suffix,
|
|
40
|
+
clippy::shadow_reuse,
|
|
41
|
+
clippy::shadow_unrelated,
|
|
42
|
+
clippy::single_call_fn,
|
|
43
|
+
clippy::single_char_lifetime_names,
|
|
44
|
+
clippy::std_instead_of_alloc,
|
|
45
|
+
clippy::std_instead_of_core,
|
|
46
|
+
clippy::too_many_lines,
|
|
47
|
+
clippy::unwrap_used
|
|
48
|
+
)]
|
|
49
|
+
|
|
50
|
+
use pyo3::prelude::*;
|
|
51
|
+
|
|
52
|
+
#[pymodule]
|
|
53
|
+
mod _minify_html {
|
|
54
|
+
use pyo3::prelude::*;
|
|
55
|
+
|
|
56
|
+
/// Minifies HTML with options set once, so that each page only passes
|
|
57
|
+
/// its code.
|
|
58
|
+
#[pyclass(frozen, module = "mkdocs_minify_html_plugin._minify_html")]
|
|
59
|
+
struct Minifier(::minify_html::Cfg);
|
|
60
|
+
|
|
61
|
+
#[pymethods]
|
|
62
|
+
impl Minifier {
|
|
63
|
+
#[new]
|
|
64
|
+
#[pyo3(signature = (
|
|
65
|
+
*,
|
|
66
|
+
allow_noncompliant_unquoted_attribute_values,
|
|
67
|
+
allow_optimal_entities,
|
|
68
|
+
allow_removing_spaces_between_attributes,
|
|
69
|
+
keep_closing_tags,
|
|
70
|
+
keep_comments,
|
|
71
|
+
keep_html_and_head_opening_tags,
|
|
72
|
+
keep_input_type_text_attr,
|
|
73
|
+
keep_ssi_comments,
|
|
74
|
+
minify_css,
|
|
75
|
+
minify_doctype,
|
|
76
|
+
minify_js,
|
|
77
|
+
preserve_brace_template_syntax,
|
|
78
|
+
preserve_chevron_percent_template_syntax,
|
|
79
|
+
remove_bangs,
|
|
80
|
+
remove_processing_instructions,
|
|
81
|
+
))]
|
|
82
|
+
#[expect(clippy::fn_params_excessive_bools, clippy::too_many_arguments)]
|
|
83
|
+
const fn new(
|
|
84
|
+
allow_noncompliant_unquoted_attribute_values: bool,
|
|
85
|
+
allow_optimal_entities: bool,
|
|
86
|
+
allow_removing_spaces_between_attributes: bool,
|
|
87
|
+
keep_closing_tags: bool,
|
|
88
|
+
keep_comments: bool,
|
|
89
|
+
keep_html_and_head_opening_tags: bool,
|
|
90
|
+
keep_input_type_text_attr: bool,
|
|
91
|
+
keep_ssi_comments: bool,
|
|
92
|
+
minify_css: bool,
|
|
93
|
+
minify_doctype: bool,
|
|
94
|
+
minify_js: bool,
|
|
95
|
+
preserve_brace_template_syntax: bool,
|
|
96
|
+
preserve_chevron_percent_template_syntax: bool,
|
|
97
|
+
remove_bangs: bool,
|
|
98
|
+
remove_processing_instructions: bool,
|
|
99
|
+
) -> Self {
|
|
100
|
+
Self(::minify_html::Cfg {
|
|
101
|
+
allow_noncompliant_unquoted_attribute_values,
|
|
102
|
+
allow_optimal_entities,
|
|
103
|
+
allow_removing_spaces_between_attributes,
|
|
104
|
+
keep_closing_tags,
|
|
105
|
+
keep_comments,
|
|
106
|
+
keep_html_and_head_opening_tags,
|
|
107
|
+
keep_input_type_text_attr,
|
|
108
|
+
keep_ssi_comments,
|
|
109
|
+
minify_css,
|
|
110
|
+
minify_doctype,
|
|
111
|
+
minify_js,
|
|
112
|
+
preserve_brace_template_syntax,
|
|
113
|
+
preserve_chevron_percent_template_syntax,
|
|
114
|
+
remove_bangs,
|
|
115
|
+
remove_processing_instructions,
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
#[pyo3(signature = (code, /))]
|
|
120
|
+
fn minify<'py>(
|
|
121
|
+
&self,
|
|
122
|
+
py: Python<'py>,
|
|
123
|
+
code: &str,
|
|
124
|
+
) -> PyResult<Bound<'py, pyo3::types::PyString>> {
|
|
125
|
+
let minified =
|
|
126
|
+
py.detach(|| ::minify_html::minify(code.as_bytes(), &self.0));
|
|
127
|
+
pyo3::types::PyString::from_bytes(py, &minified)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
def minify(
|
|
2
|
-
code: str,
|
|
3
|
-
/,
|
|
4
|
-
*,
|
|
5
|
-
allow_noncompliant_unquoted_attribute_values: bool,
|
|
6
|
-
allow_optimal_entities: bool,
|
|
7
|
-
allow_removing_spaces_between_attributes: bool,
|
|
8
|
-
keep_closing_tags: bool,
|
|
9
|
-
keep_comments: bool,
|
|
10
|
-
keep_html_and_head_opening_tags: bool,
|
|
11
|
-
keep_input_type_text_attr: bool,
|
|
12
|
-
keep_ssi_comments: bool,
|
|
13
|
-
minify_css: bool,
|
|
14
|
-
minify_doctype: bool,
|
|
15
|
-
minify_js: bool,
|
|
16
|
-
preserve_brace_template_syntax: bool,
|
|
17
|
-
preserve_chevron_percent_template_syntax: bool,
|
|
18
|
-
remove_bangs: bool,
|
|
19
|
-
remove_processing_instructions: bool,
|
|
20
|
-
) -> str: ...
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
#![deny(
|
|
2
|
-
warnings,
|
|
3
|
-
deprecated_safe,
|
|
4
|
-
future_incompatible,
|
|
5
|
-
keyword_idents,
|
|
6
|
-
let_underscore,
|
|
7
|
-
nonstandard_style,
|
|
8
|
-
refining_impl_trait,
|
|
9
|
-
rust_2018_compatibility,
|
|
10
|
-
rust_2018_idioms,
|
|
11
|
-
rust_2021_compatibility,
|
|
12
|
-
rust_2024_compatibility,
|
|
13
|
-
unused,
|
|
14
|
-
clippy::all,
|
|
15
|
-
clippy::pedantic,
|
|
16
|
-
clippy::restriction,
|
|
17
|
-
clippy::nursery,
|
|
18
|
-
clippy::cargo
|
|
19
|
-
)]
|
|
20
|
-
#![allow(
|
|
21
|
-
clippy::absolute_paths,
|
|
22
|
-
clippy::allow_attributes_without_reason,
|
|
23
|
-
clippy::arbitrary_source_item_ordering,
|
|
24
|
-
clippy::as_conversions,
|
|
25
|
-
clippy::blanket_clippy_restriction_lints,
|
|
26
|
-
clippy::cast_precision_loss,
|
|
27
|
-
clippy::cognitive_complexity,
|
|
28
|
-
clippy::else_if_without_else,
|
|
29
|
-
clippy::float_arithmetic,
|
|
30
|
-
clippy::implicit_return,
|
|
31
|
-
clippy::integer_division_remainder_used,
|
|
32
|
-
clippy::iter_over_hash_type,
|
|
33
|
-
clippy::min_ident_chars,
|
|
34
|
-
clippy::missing_docs_in_private_items,
|
|
35
|
-
clippy::mod_module_files,
|
|
36
|
-
clippy::multiple_crate_versions,
|
|
37
|
-
clippy::pattern_type_mismatch,
|
|
38
|
-
clippy::question_mark_used,
|
|
39
|
-
clippy::separated_literal_suffix,
|
|
40
|
-
clippy::shadow_reuse,
|
|
41
|
-
clippy::shadow_unrelated,
|
|
42
|
-
clippy::single_call_fn,
|
|
43
|
-
clippy::single_char_lifetime_names,
|
|
44
|
-
clippy::std_instead_of_alloc,
|
|
45
|
-
clippy::std_instead_of_core,
|
|
46
|
-
clippy::too_many_lines,
|
|
47
|
-
clippy::unwrap_used
|
|
48
|
-
)]
|
|
49
|
-
|
|
50
|
-
use pyo3::prelude::*;
|
|
51
|
-
|
|
52
|
-
#[pymodule]
|
|
53
|
-
mod _minify_html {
|
|
54
|
-
use pyo3::prelude::*;
|
|
55
|
-
|
|
56
|
-
#[pyfunction]
|
|
57
|
-
#[pyo3(signature = (
|
|
58
|
-
code,
|
|
59
|
-
/,
|
|
60
|
-
*,
|
|
61
|
-
allow_noncompliant_unquoted_attribute_values,
|
|
62
|
-
allow_optimal_entities,
|
|
63
|
-
allow_removing_spaces_between_attributes,
|
|
64
|
-
keep_closing_tags,
|
|
65
|
-
keep_comments,
|
|
66
|
-
keep_html_and_head_opening_tags,
|
|
67
|
-
keep_input_type_text_attr,
|
|
68
|
-
keep_ssi_comments,
|
|
69
|
-
minify_css,
|
|
70
|
-
minify_doctype,
|
|
71
|
-
minify_js,
|
|
72
|
-
preserve_brace_template_syntax,
|
|
73
|
-
preserve_chevron_percent_template_syntax,
|
|
74
|
-
remove_bangs,
|
|
75
|
-
remove_processing_instructions,
|
|
76
|
-
))]
|
|
77
|
-
#[expect(clippy::fn_params_excessive_bools, clippy::too_many_arguments)]
|
|
78
|
-
fn minify<'py>(
|
|
79
|
-
py: Python<'py>,
|
|
80
|
-
code: &str,
|
|
81
|
-
allow_noncompliant_unquoted_attribute_values: bool,
|
|
82
|
-
allow_optimal_entities: bool,
|
|
83
|
-
allow_removing_spaces_between_attributes: bool,
|
|
84
|
-
keep_closing_tags: bool,
|
|
85
|
-
keep_comments: bool,
|
|
86
|
-
keep_html_and_head_opening_tags: bool,
|
|
87
|
-
keep_input_type_text_attr: bool,
|
|
88
|
-
keep_ssi_comments: bool,
|
|
89
|
-
minify_css: bool,
|
|
90
|
-
minify_doctype: bool,
|
|
91
|
-
minify_js: bool,
|
|
92
|
-
preserve_brace_template_syntax: bool,
|
|
93
|
-
preserve_chevron_percent_template_syntax: bool,
|
|
94
|
-
remove_bangs: bool,
|
|
95
|
-
remove_processing_instructions: bool,
|
|
96
|
-
) -> PyResult<Bound<'py, pyo3::types::PyString>> {
|
|
97
|
-
let minified = py.detach(move || {
|
|
98
|
-
let cfg = ::minify_html::Cfg {
|
|
99
|
-
allow_noncompliant_unquoted_attribute_values,
|
|
100
|
-
allow_optimal_entities,
|
|
101
|
-
allow_removing_spaces_between_attributes,
|
|
102
|
-
keep_closing_tags,
|
|
103
|
-
keep_comments,
|
|
104
|
-
keep_html_and_head_opening_tags,
|
|
105
|
-
keep_input_type_text_attr,
|
|
106
|
-
keep_ssi_comments,
|
|
107
|
-
minify_css,
|
|
108
|
-
minify_doctype,
|
|
109
|
-
minify_js,
|
|
110
|
-
preserve_brace_template_syntax,
|
|
111
|
-
preserve_chevron_percent_template_syntax,
|
|
112
|
-
remove_bangs,
|
|
113
|
-
remove_processing_instructions,
|
|
114
|
-
};
|
|
115
|
-
::minify_html::minify(code.as_bytes(), &cfg)
|
|
116
|
-
});
|
|
117
|
-
pyo3::types::PyString::from_bytes(py, &minified)
|
|
118
|
-
}
|
|
119
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|