smol-html 0.1.5__py3-none-any.whl → 0.1.6__py3-none-any.whl
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.
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: smol-html
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.6
|
4
4
|
Summary: Small, dependable HTML cleaner/minifier with sensible defaults
|
5
5
|
Project-URL: Homepage, https://github.com/NosibleAI/smol-html
|
6
6
|
Project-URL: Repository, https://github.com/NosibleAI/smol-html
|
@@ -125,11 +125,17 @@ out = cleaner.make_smol(raw_html="<p>Hi</p>")
|
|
125
125
|
|
126
126
|
## Compressed Bytes Output
|
127
127
|
|
128
|
-
Produce compressed bytes using Brotli with `make_smol_bytes
|
128
|
+
Produce compressed bytes using Brotli with `make_smol_bytes`.
|
129
129
|
|
130
|
+
- By default, the compressed bytes are URL-safe Base64 encoded (`base64_encode=True`).
|
131
|
+
- If you enable Base64, you must decode before Brotli-decompressing.
|
132
|
+
- You can disable Base64 by passing `base64_encode=False` and decompress directly.
|
133
|
+
|
134
|
+
Default (Base64-encoded) output:
|
130
135
|
|
131
136
|
```python
|
132
137
|
from smol_html import SmolHtmlCleaner
|
138
|
+
import base64
|
133
139
|
import brotli # only needed if you want to decompress here in the example
|
134
140
|
|
135
141
|
html = """
|
@@ -145,15 +151,31 @@ cleaner = SmolHtmlCleaner()
|
|
145
151
|
# Get compressed bytes (quality 11 is strong compression)
|
146
152
|
compressed = cleaner.make_smol_bytes(raw_html=html, compression_level=11)
|
147
153
|
|
148
|
-
#
|
149
|
-
|
154
|
+
# Because Base64 is enabled by default, decode before decompressing
|
155
|
+
decoded = base64.urlsafe_b64decode(compressed)
|
156
|
+
decompressed = brotli.decompress(decoded).decode("utf-8")
|
150
157
|
print(decompressed)
|
151
158
|
|
152
|
-
# Or write compressed output directly to a file
|
153
|
-
with open("page.html.br", "wb") as f:
|
159
|
+
# Or write Base64-encoded compressed output directly to a file
|
160
|
+
with open("page.html.br.b64", "wb") as f:
|
154
161
|
f.write(compressed)
|
155
162
|
```
|
156
163
|
|
164
|
+
Disable Base64 and decompress directly:
|
165
|
+
|
166
|
+
```python
|
167
|
+
from smol_html import SmolHtmlCleaner
|
168
|
+
import brotli
|
169
|
+
|
170
|
+
cleaner = SmolHtmlCleaner()
|
171
|
+
compressed_raw = cleaner.make_smol_bytes(
|
172
|
+
raw_html="<p>Hi</p>",
|
173
|
+
compression_level=11,
|
174
|
+
base64_encode=False,
|
175
|
+
)
|
176
|
+
print(brotli.decompress(compressed_raw).decode("utf-8"))
|
177
|
+
```
|
178
|
+
|
157
179
|
## Parameter Reference
|
158
180
|
|
159
181
|
To improve readability, the reference is split into two tables:
|
@@ -213,3 +235,10 @@ To improve readability, the reference is split into two tables:
|
|
213
235
|
| `remove_unknown_tags` | `bool` | `True` |
|
214
236
|
| `safe_attrs_only` | `bool` | `True` |
|
215
237
|
| `safe_attrs` | `set[str]` | curated set |
|
238
|
+
|
239
|
+
### `make_smol_bytes` Options
|
240
|
+
|
241
|
+
| Parameter | Type | Default |
|
242
|
+
|---|---|---|
|
243
|
+
| `compression_level` | `int` | `4` |
|
244
|
+
| `base64_encode` | `bool` | `True` |
|
@@ -0,0 +1,4 @@
|
|
1
|
+
smol_html-0.1.6.dist-info/METADATA,sha256=UMpbTACIgx8ne9nQNR_Gv3CVpgaGFHHq3DzAA1o-rds,9369
|
2
|
+
smol_html-0.1.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
3
|
+
smol_html-0.1.6.dist-info/licenses/LICENSE,sha256=88yg3BujRGq8MYlWhbrzB2YMNWJaXnBck3c7l23labs,1089
|
4
|
+
smol_html-0.1.6.dist-info/RECORD,,
|
smol_html-0.1.5.dist-info/RECORD
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
smol_html-0.1.5.dist-info/METADATA,sha256=jriTNIRVbdSkr7EXyEa1ssdm_rZmwo4IV_FLVEJTJrE,8539
|
2
|
-
smol_html-0.1.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
3
|
-
smol_html-0.1.5.dist-info/licenses/LICENSE,sha256=88yg3BujRGq8MYlWhbrzB2YMNWJaXnBck3c7l23labs,1089
|
4
|
-
smol_html-0.1.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|