Download the PHP package wackowiki/htmlsax3 without Composer

On this page you can find all versions of the php package wackowiki/htmlsax3. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package 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


Installation

Via Composer (recommended)

As a local path repository in WackoWiki

In your WackoWiki composer.json:

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

Manual installation

If you can't use Composer, require the autoloader (or each file in dependency order):


Namespace map

All classes live under HTMLSax3\:

File Namespace
src/HTMLSax3.php HTMLSax3
src/NullHandler.php HTMLSax3
src/helpers.php HTMLSax3 (provides the HTMLSax3\tap() function)
src/States/StateParser.php HTMLSax3\States
src/States/StartingState.php HTMLSax3\States
src/States/ClosingTagState.php HTMLSax3\States
src/States/EscapeState.php HTMLSax3\States
src/States/JaspState.php HTMLSax3\States
src/States/OpeningTagState.php HTMLSax3\States
src/States/PiState.php HTMLSax3\States
src/States/TagState.php HTMLSax3\States
src/Decorators/CaseFolding.php HTMLSax3\Decorators
src/Decorators/Entities_Parsed.php HTMLSax3\Decorators
src/Decorators/Entities_Unparsed.php HTMLSax3\Decorators
src/Decorators/Escape_Stripper.php HTMLSax3\Decorators
src/Decorators/Linefeed.php HTMLSax3\Decorators
src/Decorators/Tab.php HTMLSax3\Decorators
src/Decorators/Trim.php HTMLSax3\Decorators

The parser-state constants (STATE_START, STATE_TAG, STATE_OPENING_TAG, STATE_CLOSING_TAG, STATE_ESCAPE, STATE_JASP, STATE_PI, STATE_STOP) are declared as global constants at the top of src/States/StateParser.php for backward compatibility with code that referenced them directly.


Quick start

Output:


API reference

HTMLSax3 — the user-facing class

__construct()

Instantiates the parser, attaches a NullHandler as the default handler for every callback channel, and pre-creates all state objects.

set_object(object &$object): true

Attaches the user handler object. Stored by reference so that decorators can wrap it in place.

set_option(string $name, int $value = 1): true

Switches parser options on or off. Throws InvalidArgumentException for unknown options.

Option Effect
XML_OPTION_TRIM_DATA_NODES Trim whitespace from element data
XML_OPTION_CASE_FOLDING Convert tag names to uppercase
XML_OPTION_LINEFEED_BREAK Emit a separate data callback for each line
XML_OPTION_TAB_BREAK Emit a separate data callback for each tab
XML_OPTION_ENTITIES_UNPARSED Emit a separate data callback for each entity (raw)
XML_OPTION_ENTITIES_PARSED Emit a separate data callback for each entity (decoded)
XML_OPTION_STRIP_ESCAPES Strip <!-- --> and <![CDATA[]]> markers from escapes

set_data_handler(string $method): void

Sets the name of the data handler method on the attached handler object.

set_element_handler(string $open_method, string $close_method): void

Sets the names of the open and close tag handler methods.

set_pi_handler(string $method): void

Sets the name of the processing-instruction handler method.

set_escape_handler(string $method): void

Sets the name of the XML-escape handler method (comments, CDATA, doctype).

set_jasp_handler(string $method): void

Sets the name of the JSP/ASP <% %> handler method.

get_current_position(): int

Returns the current cursor position inside the parsed document.

get_length(): int

Returns the length of the document being parsed.

parse(string $data): void

Begins parsing $data. All callbacks fire on the attached handler object.


Handler object signature

Each callback should return true. Returning false does not halt parsing (this matches the original HTMLSax3 semantics).


Migration from the original HTMLSax3

The public API is fully preserved. Existing handler code works without modification. The only breaking changes are:

Change Reason
Namespace added: HTMLSax3\ with HTMLSax3\States\ and HTMLSax3\Decorators\ sub-namespaces PSR-4 autoloading
StateParser moved from src/StateParser.php to src/States/StateParser.php (namespace HTMLSax3\States) Co-location with the state classes it coordinates
PEAR::raiseError()InvalidArgumentException PEAR is unmaintained
Inconsistent ScanCharacter() / IgnoreCharacter() unified to lowercase PHP 8 method-name conventions
function DoNothing()function DoNothing(mixed ...$_args): void Variadic handles every SAX callback arity
Strict types enabled PHP 8.5 best practice

If you have a non-Composer installation that referenced HTMLSax3\StateParser at the root, add this to your bootstrap:


Development

Requirements

Setup

Running tests

Directory layout


Related projects


Contributing

Pull requests welcome! Please ensure:

For bug reports and feature requests, open an issue at https://github.com/WackoWiki/htmlsax3/issues.


License

This project is licensed under the BSD 3-Clause "New" or "Revised" License — see the LICENSE file for details.

Historical note: The original HTMLSax3 source carried a PHP License 3.0 header. That license has been retired by the PHP project and superseded by the PHP License 4.0, which is itself the BSD 3-Clause License. As this library is no longer part of the PEAR ecosystem, the BSD-3-Clause terms now govern all use, modification, and distribution. The original copyright holders are preserved in the LICENSE file for historical accuracy.


All versions of htmlsax3 with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wackowiki/htmlsax3 contains the following files

Loading the files please wait ...