PHPackages                             wackowiki/htmlsax3 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. wackowiki/htmlsax3

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

wackowiki/htmlsax3
==================

A modernized PHP 8.5-compatible port of the classic HTMLSax3 SAX-style parser for HTML/XML, used by SafeHTML in WackoWiki.

00PHP

Since Jun 13Pushed todayCompare

[ Source](https://github.com/WackoWiki/htmlsax3)[ Packagist](https://packagist.org/packages/wackowiki/htmlsax3)[ RSS](/packages/wackowiki-htmlsax3/feed)WikiDiscussions main Synced today

READMEChangelog (3)DependenciesVersions (1)Used By (0)

HTMLSax3
========

[](#htmlsax3)

A modernized **PHP 8.5-compatible** port of the classic HTMLSax3 SAX-style parser for HTML/XML, maintained by the WackoWiki team. Drop-in compatible with the original API, fully strict-typed, namespace-clean, and free of legacy PEAR dependencies.

> Originally ported from Python to PHP by Alexander Zhukov, then refactored for PEAR by Harry Fuecks, with extensive contributions from the Sitepointforums Advanced PHP community.

---

Features
--------

[](#features)

- **PHP 8.5 ready** — strict types, constructor property promotion, match expressions, `readonly` properties where applicable, no legacy quirks.
- **Zero PEAR dependency** — the original `PEAR::raiseError()` calls have been replaced with native `InvalidArgumentException`.
- **PSR-4 autoloaded** under the `HTMLSax3\` namespace.
- **Fully decorator-driven** options system — trim, case-folding, entity parsing, escape stripping, linefeed/tab breaks.
- **Lightweight** — no external dependencies, runs anywhere PHP 8.5+ runs.
- **Used in production** by [SafeHTML](https://wackowiki.org/doc/Dev/Projects/SafeHTML) and [WackoWiki](https://wackowiki.org).

---

Installation
------------

[](#installation)

### Via Composer (recommended)

[](#via-composer-recommended)

```
composer require wackowiki/htmlsax3
```

### As a local path repository in WackoWiki

[](#as-a-local-path-repository-in-wackowiki)

In your WackoWiki `composer.json`:

```
{
    "require": {
        "wackowiki/htmlsax3": "*"
    },
    "repositories": [
        {
            "type": "path",
            "url": "src/lib/HTMLSax3",
            "options": {
                "symlink": true
            }
        }
    ],
    "minimum-stability": "dev"
}
```

The `symlink: true` option means edits to your local `src/lib/HTMLSax3/` are picked up immediately without re-running `composer update`.

### Manual installation

[](#manual-installation)

If you can't use Composer, download the `src/` directory and require each file manually:

```
require_once 'src/helpers.php';
require_once 'src/HTMLSax3.php';
require_once 'src/StateParser.php';
require_once 'src/NullHandler.php';
require_once 'src/Decorators/CaseFolding.php';
require_once 'src/Decorators/Entities_Parsed.php';
require_once 'src/Decorators/Entities_Unparsed.php';
require_once 'src/Decorators/Escape_Stripper.php';
require_once 'src/Decorators/Linefeed.php';
require_once 'src/Decorators/Tab.php';
require_once 'src/Decorators/Trim.php';
require_once 'src/States/ClosingTagState.php';
require_once 'src/States/EscapeState.php';
require_once 'src/States/JaspState.php';
require_once 'src/States/OpeningTagState.php';
require_once 'src/States/PiState.php';
require_once 'src/States/StartingState.php';
require_once 'src/States/TagState.php';
```

---

Quick start
-----------

[](#quick-start)

```
