UTIDYLIB(1)
π UTIDYLIB π
okay so first things first: this is the utidylib(1) page from the uTidylib manual β the Tidy wrapper. buckle up bestie, it's giving "small library, big personality" π
πΈ NAME πΈ
utidylib β uTidylib Documentation β¨
The Tidy wrapper. π«
I am the main interface to TidyLib. This package supports processing HTML with Tidy, with all the options that the tidy command line supports. no cap, ALL of them π«Ά
For more information on the tidy options, see the reference. These options can be given as keyword arguments to parse and parseString, by changing dashes (-) to underscores (_). yes literally just swap the dash for an underscore and you're so back π
For example:
>>> import tidy
>>> from __future__ import print_function
>>> print(tidy.parseString(
... '<Html>Hello Tidy!',
... output_xhtml=1, add_xml_decl=1, indent=1, tidy_mark=0,
... doctype='transitional'
... ))
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
Hello Tidy!
</body>
</html>
iconic. look at that markup, it ate π₯
For options like newline and output_encoding, which must be set to one of a fixed number of choices, you can provide either the numeric or string version of the choice; so both tidy.parseString('<HTML>foo</html>', newline=2) and tidy.parseString('<HTML>foo</html>', newline='CR') do the same thing. same vibe, different spelling, both valid π
There are no plans to support other features of TidyLib, such as document-tree traversal, since Python has several quality DOM implementations. (The author uses Twisted's implementation, twisted.web.microdom). so like, respectfully, that's not happening β go use a DOM, bestie π
π¦ THE API π¦
lowkey the whole point of the page. here's the roster π
β tidy.parse
tidy.parse(filename: str, **kwargs: OPTION_TYPE) -> Document
Open and process filename as an HTML file. π
Returning a processed document object.
Parameters
- kwargs β named options to pass to TidyLib for processing the input file.
- filename β the name of a file to process
Returns
a Document object π«
β tidy.parseString
tidy.parseString(text: bytes | str, **kwargs: OPTION_TYPE) -> Document
Use text as an HTML file. no file on disk required, we're doing this in memory π§
Returning a processed document object.
Parameters
- kwargs β named options to pass to TidyLib for processing the input file.
- text β the string to parse
Returns
a Document object π«
π class tidy.Document
class tidy.Document(options: OPTION_DICT_TYPE)
Document object as returned by parseString() or parse(). it's the little guy you get back π
π
get_errors() -> list[ReportItem]
Return list of errors as a list of ReportItem. (yes, plural, a whole list, brace yourself)
π
gettext() -> str
Unicode text for output returned by tidy.
π
getvalue() -> bytes
Raw string as returned by tidy.
π
write(stream: BinaryIO) -> None
Parameters
- stream β Writable file like object.
Writes document to the stream.
πΈ class tidy.ReportItem
class tidy.ReportItem(err: str)
Error report item as returned by tidy.
col:int | Noneβ Column where error was fired (can beNone)err:strβ Whole error message as returned by tidyfull_severity:strβ Full severity stringline:int | Noneβ Line where error was fired (can beNone)message:strβ Error message itselfseverity:strβD,W,EorCindicating severity
π¨ the exceptions (the villains)
exception tidy.TidyLibErrorβ Generic Tidy exception.exception tidy.InvalidOptionErrorβ Exception for invalid option.exception tidy.OptionArgErrorβ Exception for invalid parameter.
π οΈ INSTALL & CONTRIBUTE π οΈ
To use uTidylib, you need to have HTML tidy library installed. Check http://www.html-tidy.org/ for instructions how to obtain it. prerequisites bestie, can't skip them π
Once you have installed the library, install uTidylib:
pip install uTidylib
You are welcome to contribute on GitHub, we use it for source code management, issue tracking and patches submission, see https://github.com/nijel/utidylib. come hang out, we'd love to have you π«Ά
The testsuite can be exececuted using pytest:
pytest tidy
To build the doc, just run:
make -C docs html
This requires that you have Sphinx installed. β¨
The API documentation will be built in the docs/_build/html/ directory.
π LICENSE π
The MIT License
Copyright (c) 2003 Cory Dodt corydodt@twistedmatrix.com
Copyright (c) 2014-2026 Michal ΔihaΕ michal@weblate.org
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
yeah that's the whole thing, don't skip the fine print bestie, it's literally the license π
π¦ CHANGELOG π¦
the glow-up history, in order, we respect the timeline π
π 1.1.0
- Added FreeBSD support for finding the Tidy library.
- Added support for Python 3.15.
π 1.0.0
- Modernized packaging.
- Updated supported Python versions.
- Homebrew compatiblity.
π 0.10
- Dropped support for Python 3.7.
- Added support for Python 3.12.
- Added type hints.
- Improved documentation.
- Always call
CleanAndRepairafter parsing. - Fixed handling
char_encodingargument.
π 0.9
- Dropped support for Python 3.6.
- Added support for Python 3.10 and 3.11.
- Compatibility with html-tidy 5.8.0.
- Added support for specifying library full path using
TIDY_LIBRARY_FULL_PATH. - Added
getTidyVersionto get libtidy version.
π 0.8
- Code cleanups.
- Fixed typo in 0.7 release notes.
π 0.7
- Dropped support for Python 2.
π 0.6
- First official release PyPI.
π 0.5
- Fixed compatibility with Debian patched
libtidy5deb1.
π 0.4
- Compatibility with html-tidy 5.6.0.
- Added support for Python 3.
π 0.3
- Initial release under new maintainer.
- Incorporated Debian patches.
- Various compatiblity fixes (eg. with 64-bit machines).
- Various code cleanups.
- New test suite.
- New documentation.
- Support for new HTML 5 tidy library.
π± ORIGIN STORY π±
This is fork of the original uTidylib with permission with original author. Originally it incorporated patches from Debian and other distributions, now it also brings compatibility with recent html-tidy versions and works with Python 3. main character energy, honestly π
The original source code is still available at https://github.com/xdissent/utidylib/.
- Index <>
- Module Index <>
- Search Page <>
Author
uTidylib contributors
Copyright
uTidylib contributors
ok that's the whole page π go forth and tidy your HTML, you're gonna slay π¦
later bestie!! this was uTidylib version 1.1 β 1.1.0, dated Oct 11, 2026, page UTIDYLIB(1), brought to you by the uTidylib contributors. mwah π
π¦ where this page comes from
- arch rolling: python-utidylib 1.1.0-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms