pyhtml2text 0.2.0__cp310-abi3-win_amd64.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.
@@ -0,0 +1,3 @@
1
+ from ._pyhtml2text import html2text
2
+
3
+ __all__ = ["html2text"]
@@ -0,0 +1,12 @@
1
+ def html2text(
2
+ html: str | bytes,
3
+ width: int = 80,
4
+ *,
5
+ base_url: str | None = None,
6
+ decorate: bool = True,
7
+ link_footnotes: bool = True,
8
+ table_borders: bool = True,
9
+ wrap_links: bool = True,
10
+ max_wrap_width: int | None = None,
11
+ raw: bool = False,
12
+ ) -> str: ...
Binary file
pyhtml2text/py.typed ADDED
File without changes
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyhtml2text
3
+ Version: 0.2.0
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: 3
6
+ Classifier: Topic :: Text Processing :: Markup :: HTML
7
+ License-File: LICENSE
8
+ Summary: Fast HTML to plain text, with relative link resolution (Python bindings to rust-html2text)
9
+ Keywords: html,text,markdown,html2text
10
+ Author-email: Jared Lynskey <jared@lynskey.co.nz>
11
+ License-Expression: MIT
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
14
+ Project-URL: Source, https://github.com/jaredlynskey/pyhtml2text
15
+ Project-URL: Upstream, https://github.com/jugglerchris/rust-html2text
16
+
17
+ # pyhtml2text
18
+
19
+ Fast HTML to plain text for Python, built on
20
+ [rust-html2text](https://github.com/jugglerchris/rust-html2text).
21
+
22
+ It adds one thing the upstream crate doesn't have yet: relative links can be
23
+ resolved against the page's URL, so footnote links are usable on their own.
24
+
25
+ ```python
26
+ from pyhtml2text import html2text
27
+
28
+ html = '<p>Please <a href="/login">sign in</a> first.</p>'
29
+
30
+ print(html2text(html, base_url="https://example.com/docs/page.html"))
31
+ # Please [sign in][1] first.
32
+ #
33
+ # [1]: https://example.com/login
34
+ ```
35
+
36
+ `html` can be a `str` or UTF-8 `bytes` (e.g. `response.content`). Requires
37
+ Python 3.10 or later.
38
+
39
+ ## Options
40
+
41
+ `html2text(html, width=80, *, ...)`
42
+
43
+ | option | default | |
44
+ |---|---|---|
45
+ | `base_url` | `None` | resolve relative `href`s against this URL (RFC 3986). Absolute and `mailto:` etc. links are left alone |
46
+ | `decorate` | `True` | markdown-ish `*em*`, `**strong**`, `` `code` `` |
47
+ | `link_footnotes` | `True` | list link targets as `[1]: ...` footnotes |
48
+ | `table_borders` | `True` | draw table borders |
49
+ | `wrap_links` | `True` | allow long links to wrap |
50
+ | `max_wrap_width` | `None` | wrap paragraphs narrower than `width` |
51
+ | `raw` | `False` | flatten tables so cell text stays together |
52
+
53
+ ## Performance
54
+
55
+ Median time to render a page, on an Apple Silicon Mac:
56
+
57
+ | | Wikipedia article (780 KB) | BBC News front page (370 KB) |
58
+ |---|---|---|
59
+ | [html2text](https://pypi.org/project/html2text/) (pure Python) | 71.5 ms | 14.9 ms |
60
+ | [html2text-rs](https://pypi.org/project/html2text-rs/) | 15.2 ms | 2.5 ms |
61
+ | **pyhtml2text** | **10.9 ms** | **1.6 ms** |
62
+
63
+ - The GIL is released while rendering, so threads scale across cores. On
64
+ free-threaded Python (3.14t) the module runs without re-enabling the GIL.
65
+ - Wheels for Linux (x86_64, aarch64), macOS and Windows x64 are built with
66
+ profile-guided optimisation, which makes them about 25% faster. Other
67
+ platforms get the same code without it.
68
+ - Deeply nested HTML is parsed in linear time, so hostile input can't stall a
69
+ worker: 40,000 nested lists take 0.14 s, against 6 s with stock html5ever.
70
+
71
+ ## Credits
72
+
73
+ The rendering is done by rust-html2text by Chris Emerson (MIT). This package
74
+ uses [a fork](https://github.com/jaredlynskey/rust-html2text/tree/pyhtml2text-perf)
75
+ that adds `base_url` and some performance changes, and a patched copy of
76
+ [html5ever](https://github.com/servo/html5ever) (MIT/Apache-2.0, see
77
+ `vendor/`). It isn't affiliated with or endorsed by either upstream project, so
78
+ please report issues here rather than upstream.
79
+
@@ -0,0 +1,9 @@
1
+ pyhtml2text/__init__.py,sha256=SNSvBk7XadgoTer_FNl-CpVj35EwpSH562UvJnpQl0c,64
2
+ pyhtml2text/__init__.pyi,sha256=TUzQPItlH84t-6PIk44zbUW1sfd9T4Co103pFBWTNEY,308
3
+ pyhtml2text/_pyhtml2text.pyd,sha256=SJnLg5F_WlNNHQZFgelhTNOzaU1_2JqYfbnt2fn17XA,1852416
4
+ pyhtml2text/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ pyhtml2text-0.2.0.dist-info/METADATA,sha256=6nHBs1WRXV6fpsDP6AtDam-DmSly_LwOBiw0emgWNO0,3250
6
+ pyhtml2text-0.2.0.dist-info/WHEEL,sha256=7HL-TGvq44Ofp0yhZL-uRIIFHcJTIqqkRZVQ2wZidzM,96
7
+ pyhtml2text-0.2.0.dist-info/licenses/LICENSE,sha256=dw7sNXB8KgHIYo1ow4R6gT935LhuObKKM__zMT7c_7g,1170
8
+ pyhtml2text-0.2.0.dist-info/sboms/pyhtml2text.cyclonedx.json,sha256=TqvE4naeiNriSVPXfWGq-BPXZMxTBx-dD1KwDquc8Vk,58848
9
+ pyhtml2text-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.15.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-abi3-win_amd64
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jared Lynskey
4
+ Copyright (c) 2016 Chris Emerson (rust-html2text, which this package embeds)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.