Skip to main content

Python binding for the libtidy C library.

Project description

libtidy

Python binding for the libtidy C library.

Overview

Python libtidy module is a low-level binding for libtidy C library.
It is an effort to allow python programs full access to the API implemented and provided by the well known *libtidy* library.

PyPI record.

Documentation.

libtidy is a lightweight Python package, based on the ctypes library.
It is fully compliant implementation of the original C libtidy API by implementing whole its functionality in a clean Python instead of C.

libtidy API documentation can be found at:

libtidy API Reference

libtidy uses the underlying libtidy C shared library as specified in libtidy.cfg (included libtidy-X.X.* is the default), but there is also ability to specify it programmatically by one of the following ways:

import libtidy
libtidy.config(LIBTIDY="libtidy C shared library absolute path")
# or
libtidy.config(LIBTIDY=None)  # included libtidy-X.X.* will be used

About original libtidy:

Borrowed from the original website:

libtidy Introduction

libtidy is the library version of HTML Tidy. In fact, Tidy is libtidy; the console application is a very simple C application that links against libtidy. It’s what powers Tidy, mod-tidy, and countless other applications that perform tidying.

Design factors

libtidy is Thread Safe and Re-entrant. Because there are many uses for HTML Tidy - from content validation, content scraping, conversion to XHTML - it was important to make libtidy run reasonably well within server applications as well as client side.

Requirements

  • It is a fully independent package.
    All necessary things are installed during the normal installation process.
  • ATTENTION: currently works and tested only for Windows.

Installation

Prerequisites:

To install run:

python -m pip install --upgrade libtidy

Development

Prerequisites:

  • Development is strictly based on tox. To install it run:

    python -m pip install --upgrade tox

Visit Development page.

Installation from sources:

clone the sources:

git clone https://github.com/karpierz/libtidy.git libtidy

and run:

python -m pip install ./libtidy

or on development mode:

python -m pip install --editable ./libtidy

License

Copyright (c) 2024-2025 Adam Karpierz
Licensed under the HTML Tidy License
Please refer to the accompanying LICENSE file.

Authors

Changelog

5.9.14b1 (2025-05-05)

  • Add support for Python 3.14

  • Drop support for Python 3.9 (due to compatibility issues).

  • Update readthedocs’s python to version 3.13

  • Update tox’s base_python to version 3.13

  • Tox configuration is now in native (toml) format.

  • Add support for PyPy 3.11

  • Drop support for PyPy 3.9

  • Removed mixed-cased variants of constants ‘tidyFormatType_*’.

  • Removed mixed-cased constants ‘tidyStrings’.
    ‘TidyStrings’ should be used instead.
  • Removed mixed-cased constants ‘tidyLocaleMapItem’.
    ‘TidyLocaleMapItem’ should be used instead.
  • Added module libtidy.tidy as equivalent of standard tidy.exe.
  • The ‘tidy’ script was also created during the installation
    (on Windows as Scripts/tidy.exe) as a convenience.
  • Added preliminary tests for libtidy.tidy.

  • 100% code linting.

  • Copyright year update.

  • Setup (dependencies) update.

5.9.14a1 (2025-01-01)

  • First release.

0.0.0 (2024-10-10)

  • Initial commit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libtidy-5.9.14b1.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libtidy-5.9.14b1-py3-none-any.whl (614.3 kB view details)

Uploaded Python 3

File details

Details for the file libtidy-5.9.14b1.tar.gz.

File metadata

  • Download URL: libtidy-5.9.14b1.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for libtidy-5.9.14b1.tar.gz
Algorithm Hash digest
SHA256 c022b5411be130a0c74720950facda5f8f9c05bd7abbb2e31b6e2ec2bbd3ba83
MD5 00eb949826edaa3dc327fc3f8710f943
BLAKE2b-256 2629987c3e550608f0fa984512352c3631811d30169070452965afea0c375014

See more details on using hashes here.

File details

Details for the file libtidy-5.9.14b1-py3-none-any.whl.

File metadata

  • Download URL: libtidy-5.9.14b1-py3-none-any.whl
  • Upload date:
  • Size: 614.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for libtidy-5.9.14b1-py3-none-any.whl
Algorithm Hash digest
SHA256 a169ce0db9435d1589078e081392800e0641fc591e07212c0b879c5691e8cddd
MD5 e221599e46f01eb2692fe51eada2044c
BLAKE2b-256 8d8127cf3b6c4db2f10b42cc6bfce45cf4c4de5ebd38321db55744fce2b6836c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page