PHPackages                             opencat/filter-plaintext - 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-plaintext

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

opencat/filter-plaintext
========================

Plain text (.txt) file filter for the OpenCAT Framework

00PHP

Since May 9Pushed 1mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

catframework/filter-plaintext
=============================

[](#catframeworkfilter-plaintext)

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

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

[](#installation)

```
composer require catframework/filter-plaintext
```

Usage
-----

[](#usage)

```
use CatFramework\FilterPlaintext\PlainTextFilter;

$filter = new PlainTextFilter();

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

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

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

How segments are split
----------------------

[](#how-segments-are-split)

The filter splits on **two or more consecutive newlines** (blank-line paragraph breaks). Each non-whitespace block becomes one segment. Single newlines within a block are preserved as-is and are part of the segment text.

```
First paragraph.       → segment 1
                       → (separator, not a segment)
Second paragraph.      → segment 2

Third paragraph.       → segment 3

```

Whitespace-only blocks (e.g. multiple blank lines between paragraphs) are passed through unchanged and do not become segments.

Encoding
--------

[](#encoding)

Input files are auto-detected as UTF-8, ISO-8859-1, or Windows-1252. All output is written in UTF-8. If encoding detection fails, the file is treated as UTF-8.

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

[](#skeleton-format)

```
[
    'parts'   => string[],      // file split by paragraph boundaries, separators included
    'seg_map' => [int => string], // parts array index => segId
]
```

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

[](#limitations)

- No inline markup support — the entire segment is plain text; no `InlineCode` elements are produced.
- No sentence-level segmentation — each paragraph is one segment regardless of length. Use `catframework/segmentation` for sentence splitting.
- Encoding detection relies on `mb_detect_encoding`; unusual encodings (e.g. Shift-JIS) are not supported.

###  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-plaintext/health.svg)

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

PHPackages © 2026

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