pyhtml2text 0.1.0__cp39-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.
- pyhtml2text/__init__.py +3 -0
- pyhtml2text/__init__.pyi +14 -0
- pyhtml2text/_pyhtml2text.pyd +0 -0
- pyhtml2text/py.typed +0 -0
- pyhtml2text-0.1.0.dist-info/METADATA +56 -0
- pyhtml2text-0.1.0.dist-info/RECORD +9 -0
- pyhtml2text-0.1.0.dist-info/WHEEL +4 -0
- pyhtml2text-0.1.0.dist-info/licenses/LICENSE +22 -0
- pyhtml2text-0.1.0.dist-info/sboms/pyhtml2text.cyclonedx.json +1725 -0
pyhtml2text/__init__.py
ADDED
pyhtml2text/__init__.pyi
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
def html2text(
|
|
4
|
+
html: str,
|
|
5
|
+
width: int = 80,
|
|
6
|
+
*,
|
|
7
|
+
base_url: Optional[str] = None,
|
|
8
|
+
decorate: bool = True,
|
|
9
|
+
link_footnotes: bool = True,
|
|
10
|
+
table_borders: bool = True,
|
|
11
|
+
wrap_links: bool = True,
|
|
12
|
+
max_wrap_width: Optional[int] = None,
|
|
13
|
+
raw: bool = False,
|
|
14
|
+
) -> str: ...
|
|
Binary file
|
pyhtml2text/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyhtml2text
|
|
3
|
+
Version: 0.1.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.9
|
|
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
|
+
## Options
|
|
37
|
+
|
|
38
|
+
`html2text(html, width=80, *, ...)`
|
|
39
|
+
|
|
40
|
+
| option | default | |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| `base_url` | `None` | resolve relative `href`s against this URL (RFC 3986). Absolute and `mailto:` etc. links are left alone |
|
|
43
|
+
| `decorate` | `True` | markdown-ish `*em*`, `**strong**`, `` `code` `` |
|
|
44
|
+
| `link_footnotes` | `True` | list link targets as `[1]: ...` footnotes |
|
|
45
|
+
| `table_borders` | `True` | draw table borders |
|
|
46
|
+
| `wrap_links` | `True` | allow long links to wrap |
|
|
47
|
+
| `max_wrap_width` | `None` | wrap paragraphs narrower than `width` |
|
|
48
|
+
| `raw` | `False` | flatten tables so cell text stays together |
|
|
49
|
+
|
|
50
|
+
## Credits
|
|
51
|
+
|
|
52
|
+
The rendering is done by rust-html2text by Chris Emerson (MIT). This package
|
|
53
|
+
uses [a fork](https://github.com/jaredlynskey/rust-html2text/tree/base-url-resolution)
|
|
54
|
+
that adds `base_url`. It isn't affiliated with or endorsed by the upstream project,
|
|
55
|
+
so please report issues here rather than upstream.
|
|
56
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
pyhtml2text/__init__.py,sha256=SNSvBk7XadgoTer_FNl-CpVj35EwpSH562UvJnpQl0c,64
|
|
2
|
+
pyhtml2text/__init__.pyi,sha256=wl6NChuxMrk5h71j8a1oYUN9rnjDQ29iIiA72j_Vl08,337
|
|
3
|
+
pyhtml2text/_pyhtml2text.pyd,sha256=10vY57E9KeYErCW6gFY1R58_jAWtSSohLXWwoOHxF2g,1296896
|
|
4
|
+
pyhtml2text/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
pyhtml2text-0.1.0.dist-info/METADATA,sha256=GbTBI5VauQVAggrl6UJcqBbUf4b8EGmRCzFAlnVmacA,2139
|
|
6
|
+
pyhtml2text-0.1.0.dist-info/WHEEL,sha256=xe4_tbg8wYdeh4O7nLbnWckzIQtCR4nODDgwke_TKy8,95
|
|
7
|
+
pyhtml2text-0.1.0.dist-info/licenses/LICENSE,sha256=dw7sNXB8KgHIYo1ow4R6gT935LhuObKKM__zMT7c_7g,1170
|
|
8
|
+
pyhtml2text-0.1.0.dist-info/sboms/pyhtml2text.cyclonedx.json,sha256=9xAOGBBK4FFRvbUOrjXUzb5zpFltD-U2A911icXVwf0,53419
|
|
9
|
+
pyhtml2text-0.1.0.dist-info/RECORD,,
|
|
@@ -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.
|