Download the PHP package tekintian/html-cleaner without Composer

On this page you can find all versions of the php package tekintian/html-cleaner. 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 html-cleaner

HTML Cleaner

A powerful PHP tool for cleaning HTML content generated by Typora editor. Removes redundant spaces, useless attributes, and optimizes HTML structure while preserving content integrity.

Features

Installation

Composer Installation

Manual Installation

Download the package and include the autoloader:

Usage

Basic Usage

With Custom Tag Links

Using Individual Processing Methods

Debug Output Control

API Reference

Main Methods

HtmlCleaner::clean(string $html, array|null $tagLinks = null): string

Cleans HTML content and returns the cleaned version.

Parameters:

Returns: Cleaned HTML content

HtmlCleaner::cleanFile(string $inputFile, string|null $outputFile = null, array|null $tagLinks = null): string

Cleans an HTML file and saves the result.

Parameters:

Returns: Cleaned HTML content

Throws: Exception if file operations fail

Individual Processing Methods

HtmlCleaner::unifiedAttributeProcessing(string $html): string

Processes HTML attributes in a unified manner (combining multiple loops).

Parameters:

Returns: HTML content with processed attributes

HtmlCleaner::removeEmptyTags(string $html): string

Removes empty span and div tags from HTML content.

Parameters:

Returns: HTML content with empty tags removed

HtmlCleaner::simplifyTags(string $html): string

Simplifies tag structure by optimizing nested tags.

Parameters:

Returns: Simplified HTML content

HtmlCleaner::cleanAllTagSpaces(string $html): string

Cleans all redundant spaces within HTML tags.

Parameters:

Returns: HTML content with cleaned tag spaces

HtmlCleaner::removeUselessAttributes(string $html): string

Removes useless attributes from HTML content.

Parameters:

Returns: HTML content with useless attributes removed

HtmlCleaner::cleanWhitespace(string $html): string

Cleans whitespace characters and normalizes formatting.

Parameters:

Returns: HTML content with cleaned whitespace

HtmlCleaner::processPreTags(string $html): string

Processes pre tags, preserves language class names and removes br tags.

Parameters:

Returns: HTML content with processed pre tags

Processing Steps

The cleaner performs the following operations in sequence:

  1. Unified Attribute Processing: Combines multiple attribute processing loops
  2. Empty Tag Removal: Removes empty span and div tags
  3. Tag Structure Simplification: Optimizes nested tag structures
  4. Space Cleaning: Removes redundant spaces in tags
  5. Useless Attribute Removal: Eliminates empty and unnecessary attributes
  6. Whitespace Normalization: Cleans up whitespace characters
  7. Pre Tag Processing: Handles code blocks and language classes
  8. External Link Processing: Adds target="_blank" to external links
  9. Tag Link Addition: Automatically adds links to specified keywords

Configuration

Environment Variables

Debug Control Behavior

Setting Debug Output Use Case
APP_DEBUG=true or 1 ✅ Enabled Development and debugging
APP_ENV=dev or testing ✅ Enabled Backward compatibility
APP_DEBUG=false or unset ❌ Disabled Production deployment

Note: APP_DEBUG takes precedence over APP_ENV for debug control.

Customizing External Link Detection

Override the getCurrentHost() method to customize external link detection:

Performance

The tool is optimized for performance:

Examples

Before Cleaning

After Cleaning

File Structure

Testing

Running Tests

The project includes comprehensive unit tests to ensure code quality and functionality. To run the tests:

Test Coverage

The test suite covers:

Test Environment

Tests are configured to run in PHP 7.2+ environments and include:

Continuous Integration

To integrate testing into your development workflow:

Test Examples

See the tests/ directory for complete test implementations, including:

Browser Compatibility

The cleaned HTML is compatible with all modern browsers and maintains semantic structure.

SEO Benefits

License

This project is open source and available under the MIT License.

Support

For issues and feature requests, please visit the GitHub repository.

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for discussion.

Changelog

Version 1.1

Version 1.0


All versions of html-cleaner with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.0
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 tekintian/html-cleaner contains the following files

Loading the files please wait ...