Skip to content

karpierz/libtidy

Repository files navigation

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-2024 Adam Karpierz
Licensed under the HTML Tidy License
Please refer to the accompanying LICENSE file.

Authors