Debian Codegraph @

PKG-INFO

raw
1 Metadata-Version: 2.1
2 Name: html5rdf
3 Version: 1.2.1
4 Summary: HTML parser based on the WHATWG HTML specification
5 Home-page: https://github.com/RDFLib/html5rdf
6 Author-email: Ashley Sommer <[email protected]>, James Graham <[email protected]>
7 Maintainer: Ashley Sommer
8 Maintainer-email: [email protected]
9 License: Copyright (c) 2006-2013 James Graham and other contributors
10
11 Permission is hereby granted, free of charge, to any person obtaining
12 a copy of this software and associated documentation files (the
13 "Software"), to deal in the Software without restriction, including
14 without limitation the rights to use, copy, modify, merge, publish,
15 distribute, sublicense, and/or sell copies of the Software, and to
16 permit persons to whom the Software is furnished to do so, subject to
17 the following conditions:
18
19 The above copyright notice and this permission notice shall be
20 included in all copies or substantial portions of the Software.
21
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 Classifier: Development Status :: 5 - Production/Stable
31 Classifier: Intended Audience :: Developers
32 Classifier: License :: OSI Approved :: MIT License
33 Classifier: Operating System :: OS Independent
34 Classifier: Programming Language :: Python
35 Classifier: Programming Language :: Python :: 3
36 Classifier: Programming Language :: Python :: 3.8
37 Classifier: Programming Language :: Python :: 3.9
38 Classifier: Programming Language :: Python :: 3.10
39 Classifier: Programming Language :: Python :: 3.11
40 Classifier: Programming Language :: Python :: 3.12
41 Classifier: Programming Language :: Python :: Implementation :: CPython
42 Classifier: Programming Language :: Python :: Implementation :: PyPy
43 Classifier: Topic :: Software Development :: Libraries :: Python Modules
44 Classifier: Topic :: Text Processing :: Markup :: HTML
45 Requires-Python: >=3.8
46 Description-Content-Type: text/x-rst
47 License-File: LICENSE
48 License-File: AUTHORS.rst
49
50 html5rdf
51 ========
52
53 .. image:: https://github.com/html5lib/html5lib-python/actions/workflows/python-tox.yml/badge.svg
54 :target: https://github.com/html5lib/html5lib-python/actions/workflows/python-tox.yml
55
56 html5rdf is a pure-python library for parsing HTML to DOMFragment objects for the use in RDFLib.
57 html5rdf is a fork of html5lib-python. See below for the html5lib README.
58
59 ----
60
61 It is designed to conform to the WHATWG HTML specification, as is implemented by all major
62 web browsers.
63
64 htm5lib-modern is designed as a drop-in replacement for ``html5lib`` that exposes a new
65 ``html5lib`` module without Python 2 support and without the legacy dependencies on
66 ``six``, and ``webencodings``. Note, you should not have the old deprecated ``html5lib``
67 and ``html5lib-modern`` in your dependency tree at the same time, because they alias.
68
69
70 Usage
71 -----
72
73 Simple usage follows this pattern:
74
75 .. code-block:: python
76
77 import html5rdf
78 with open("mydocument.html", "rb") as f:
79 document = html5rdf.parse(f)
80
81 or:
82
83 .. code-block:: python
84
85 import html5rdf
86 document = html5rdf.parse("<p>Hello World!")
87
88 By default, the ``document`` will be an ``xml.etree`` element instance.
89 Whenever possible, html5lib chooses the accelerated ``ElementTree``
90 implementation.
91
92 Two other tree types are supported: ``xml.dom.minidom`` and
93 ``lxml.etree``. To use an alternative format, specify the name of
94 a treebuilder:
95
96 .. code-block:: python
97
98 import html5rdf
99 with open("mydocument.html", "rb") as f:
100 lxml_etree_document = html5rdf.parse(f, treebuilder="lxml")
101
102 When using with ``urllib.request`` (Python 3), the charset from HTTP
103 should be pass into html5rdf as follows:
104
105 .. code-block:: python
106
107 from urllib.request import urlopen
108 import html5rdf
109
110 with urlopen("http://example.com/") as f:
111 document = html5rdf.parse(f, transport_encoding=f.info().get_content_charset())
112
113 To have more control over the parser, create a parser object explicitly.
114 For instance, to make the parser raise exceptions on parse errors, use:
115
116 .. code-block:: python
117
118 import html5rdf
119 with open("mydocument.html", "rb") as f:
120 parser = html5rdf.HTMLParser(strict=True)
121 document = parser.parse(f)
122
123 When you're instantiating parser objects explicitly, pass a treebuilder
124 class as the ``tree`` keyword argument to use an alternative document
125 format:
126
127 .. code-block:: python
128
129 import html5rdf
130 parser = html5rdf.HTMLParser(tree=html5rdf.getTreeBuilder("dom"))
131 minidom_document = parser.parse("<p>Hello World!")
132
133 More documentation is available at https://html5lib.readthedocs.io/.
134
135
136 Installation
137 ------------
138
139 html5rdf works on CPython 3.8+ and PyPy. To install:
140
141 .. code-block:: bash
142
143 $ pip install html5rdf
144
145 The goal is to support a (non-strict) superset of the versions that `pip
146 supports
147 <https://pip.pypa.io/en/stable/installing/#python-and-os-compatibility>`_.
148
149
150 Optional Dependencies
151 ---------------------
152
153 The following third-party libraries may be used for additional
154 functionality:
155
156 - ``lxml`` is supported as a tree format (for both building and
157 walking) under CPython (but *not* PyPy where it is known to cause
158 segfaults);
159
160 - ``genshi`` has a treewalker (but not builder); and
161
162 - ``chardet`` can be used as a fallback when character encoding cannot
163 be determined.
164
165
166 Bugs
167 ----
168
169 Please report any bugs on the `issue tracker
170 <https://github.com/html5lib/html5lib-python/issues>`_.
171
172
173 Tests
174 -----
175
176 Unit tests require the ``pytest`` and ``mock`` libraries and can be
177 run using the ``pytest`` command in the root directory.
178
179 Test data are contained in a separate `html5lib-tests
180 <https://github.com/html5lib/html5lib-tests>`_ repository and included
181 as a submodule, thus for git checkouts they must be initialized::
182
183 $ git submodule init
184 $ git submodule update
185
186 If you have all compatible Python implementations available on your
187 system, you can run tests on all of them using the ``tox`` utility,
188 which can be found on PyPI.
189
190
191 Credits
192 =======
193
194 ``html5lib`` is written and maintained by:
195
196 - James Graham
197 - Sam Sneddon
198 - Łukasz Langa
199 - Will Kahn-Greene
200
201
202 Patches and suggestions
203 -----------------------
204 (In chronological order, by first commit:)
205
206 - Anne van Kesteren
207 - Lachlan Hunt
208 - lantis63
209 - Sam Ruby
210 - Thomas Broyer
211 - Tim Fletcher
212 - Mark Pilgrim
213 - Ryan King
214 - Philip Taylor
215 - Edward Z. Yang
216 - fantasai
217 - Philip Jägenstedt
218 - Ms2ger
219 - Mohammad Taha Jahangir
220 - Andy Wingo
221 - Andreas Madsack
222 - Karim Valiev
223 - Juan Carlos Garcia Segovia
224 - Mike West
225 - Marc DM
226 - Simon Sapin
227 - Michael[tm] Smith
228 - Ritwik Gupta
229 - Marc Abramowitz
230 - Tony Lopes
231 - lilbludevil
232 - Kevin
233 - Drew Hubl
234 - Austin Kumbera
235 - Jim Baker
236 - Jon Dufresne
237 - Donald Stufft
238 - Alex Gaynor
239 - Nik Nyby
240 - Jakub Wilk
241 - Sigmund Cherem
242 - Gabi Davar
243 - Florian Mounier
244 - neumond
245 - Vitalik Verhovodov
246 - Kovid Goyal
247 - Adam Chainz
248 - John Vandenberg
249 - Eric Amorde
250 - Benedikt Morbach
251 - Jonathan Vanasco
252 - Tom Most
253 - Ville Skyttä
254 - Hugo van Kemenade
255 - Mark Vasilkov
256
257
258 HTML5Lib-modern
259 ---------------
260
261 - Ashley Sommer