PHPackages                             opencat/filter-html - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. opencat/filter-html

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

opencat/filter-html
===================

HTML file filter for the OpenCAT Framework

00PHP

Since May 9Pushed 1mo agoCompare

[ Source](https://github.com/shaikhammar/opencat-filter-html)[ Packagist](https://packagist.org/packages/opencat/filter-html)[ RSS](/packages/opencat-filter-html/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

catframework/filter-html
========================

[](#catframeworkfilter-html)

HTML file filter for the [CAT Framework](https://github.com/shaikhammar/cat-framework).

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

[](#installation)

```
composer require catframework/filter-html
```

Requires `ext-dom` and `ext-libxml`.

Usage
-----

[](#usage)

```
use CatFramework\FilterHtml\HtmlFilter;

$filter = new HtmlFilter();

// Extract translatable segments
$document = $filter->extract('page.html', 'en', 'fr');

foreach ($document->getSegmentPairs() as $pair) {
    $pair->target = new Segment('seg-t', [$translatedText]);
}

// Write the translated file
$filter->rebuild($document, 'page.fr.html');
```

What gets extracted
-------------------

[](#what-gets-extracted)

The filter uses a **block element** taxonomy to decide segmentation boundaries:

**Block elements** (each becomes at most one segment): ``, ``, ``–``, ``, ``, ``, ``, ``, ``, ``, ``

- A block element with only text / inline children → extracted as one segment.
- A block element that itself contains other block elements → recursed into (not extracted as a whole).

**Inline elements** inside a segment become `InlineCode` pairs so translators see placeholders rather than raw HTML tags: ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``

**Void elements** (``, ``, ``, etc.) become standalone `InlineCode` placeholders.

**Whitespace-only** blocks are silently skipped.

Skeleton format
---------------

[](#skeleton-format)

```
[
    'html'    => string,   // serialized DOMDocument with {{SEG:NNN}} tokens in place of block content
    'seg_map' => [         // segId => token string
        'seg-1' => '{{SEG:001}}',
        // …
    ],
]
```

Limitations
-----------

[](#limitations)

- **Full HTML documents only**: the filter expects a `` element. Fragment-only strings (no wrapping body) will produce no segments.
- **Structural elements outside the body** (``, ``, ``) are not extracted.
- **Unknown non-block elements** are treated as inline and wrapped as `InlineCode` pairs.
- **Invalid nesting** (block element inside an inline context) is silently ignored.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance61

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c6b9044413071860fd6199e56c661a24f449797b77a1b130f0df7e98be8481f4?d=identicon)[shaikhammar](/maintainers/shaikhammar)

---

Top Contributors

[![actions-user](https://avatars.githubusercontent.com/u/65916846?v=4)](https://github.com/actions-user "actions-user (3 commits)")

### Embed Badge

![Health badge](/badges/opencat-filter-html/health.svg)

```
[![Health](https://phpackages.com/badges/opencat-filter-html/health.svg)](https://phpackages.com/packages/opencat-filter-html)
```

###  Alternatives

[s-patompong/laravel-routes-html

View your Laravel routes on the browser.

264.6k](/packages/s-patompong-laravel-routes-html)[vinicius73/seotools

A package containing SEO helpers.

235.2k](/packages/vinicius73-seotools)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
