PHPackages                             akibatech/wysiwygpreprocessor - 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. akibatech/wysiwygpreprocessor

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

akibatech/wysiwygpreprocessor
=============================

A PHP library for processing wysiwyg/textarea output.

0.0.8(9y ago)7454MITPHP

Since Jul 9Pushed 9y ago1 watchersCompare

[ Source](https://github.com/MarceauKa/WYSIWYG-Preprocessor)[ Packagist](https://packagist.org/packages/akibatech/wysiwygpreprocessor)[ RSS](/packages/akibatech-wysiwygpreprocessor/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (9)Used By (0)

WYSIWYG Preprocessor
====================

[](#wysiwyg-preprocessor)

[![Build Status](https://camo.githubusercontent.com/ebcf648a8dad8bbc1ab4ebc115c1a69aa477a278b030f8ff020de1b8e241bb3b/68747470733a2f2f7472617669732d63692e6f72672f4d6172636561754b612f575953495759472d50726570726f636573736f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/MarceauKa/WYSIWYG-Preprocessor)

WYSIWYG Preprocessor is **a PHP library with no dependencies**. It's a sort of **toolbox for processing your HTML textareas**.

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Customizing modifiers](#customizing-modifiers)
- [Modifiers](#modifiers)
    - [BBCode](#bbcode)
    - [Parse Variables](#parse-variables)
    - [Absolute Path](#absolute-path)
    - [Words Filter](#words-filter)
    - [Empty Paragraphs](#empty-paragraphs)
    - [Mail to Link](#mail-to-link)
    - [NlToBr](#nltobr)
    - [StripTags](#striptags)
    - [URL to Link](#url-to-link)
    - [Youtube Link to Iframe](#youtube-link-to-iframe)
- [Your own modifiers](#your-own-modifiers)
- [Unit Tests](#unit-tests)
- [Authors](#authors)

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

[](#installation)

Sources are managed with Composer.

```
composer require akibatech/wysiwygpreprocessor "0.*"
```

Basic usage
-----------

[](#basic-usage)

For the given textarea,

```
$textarea = "Check my website http://website.com. Keep in touch at hello@website.com !";
```

We want to transform the link and the email adress to HTML tags

```
use Akibatech\Wysiwyg\Processor;
use Akibatech\Wysiwyg\Modifier;

$processor = new Processor();

$processor->addModifier(new Modifier\UrlToLink)
          ->addModifier(new Modifier\MailToLink)
          ->process($textarea);

echo $processor->getOutput();
```

Results in :

```
Check my website http://website.com. Keep in touch at hello@website.com !
```

Customizing modifiers
---------------------

[](#customizing-modifiers)

Modifiers are easily customizable.
Imagine you want to target all links to a new page or adding to it a custom class.

```
$textarea = 'Check out my new site: personnal-website.com';

$modifier = new Akibatech\Wysiwyg\Modifier\UrlToLink();

$modifier->setOptions([
    'class' => 'custom-link',
    'target' => '_blank'
])

$processor = new Akibatech\Wysiwyg\Processor();

$processor->addModifier($modifier)
          ->process($textarea);

echo $processor->getOutput();
```

Results in :

```
Check out my new site: personnal-website.com
```

Modifiers
---------

[](#modifiers)

### BBCode

[](#bbcode)

Class: **Akibatech\\Wysiwyg\\Modifier\\BbCode**
Description: Apply a basic BBCode to enhance your content.

Example input: `[b]Hello[/b]`
Example output: `Hello`

Options:
Defaults tags are: b, i, u, left, right, center, quote, link, img, size and color.
Options are wilcard BBCode tag. Key is the wanted BBCode tag and option is the HTML replacement.
If pattern is given as array, it can access Tag option like `[link=http://github.com]my profile[/link]` as `$2`.

```
[
    // New tag called [yellow]text in yellow[/yellow]
    'yellow' => '$1',
    // Disable default "b" tag
    'b' => null
]
```

### Parse Variables

[](#parse-variables)

Class: **Akibatech\\Wysiwyg\\Modifier\\ParseVariables**
Description: Replace a preset of variables.

Example input: `Hello %name%!`
Example output: `Hello John!`

Options:
You can specify the delimiter and the accepted variables.

```
[
    // My custom delimiter. Vars are parsed in this delimiter. Default is "%".
    'in' => '%',
    // Accepted vars
    'accept' => [
        'name' => 'Joe', // %name% => Joe
        'email' => 'email@example.com' // %email% => email@example.com
    ]
]
```

### Absolute Path

[](#absolute-path)

Class: **Akibatech\\Wysiwyg\\Modifier\\AbsolutePath**
Description: Will replace "href" and "src" attributes with absolute values.

Example input: ``
Example output: ``

Options:
You can specify a custom prefix for your paths.

```
[
    // Custom prefix. Default is '/'.
    'prefix' => 'http://site.com/', //
]
```

### Words Filter

[](#words-filter)

Class: **Akibatech\\Wysiwyg\\Modifier\\WordsFilter**
Description: Remove a words list from a text. Act as a censorship system.

Example input: `Cunt!`
Example output: `[censored]!`

Options:
The list and the replacement.

```
[
    // Words list as an array.
    'words' => ['word1', 'word2'], // No defaults words.
    // Replacement
    'replace' => '[censored]' // Wanted replacement, default to [censored]
]
```

### Empty Paragraphs

[](#empty-paragraphs)

Class: **Akibatech\\Wysiwyg\\Modifier\\EmptyParagraphs**
Description: Delete empty paragraphs from your content.

Example input: `Hello&nbsp;`
Example output: `Hello`

Options:
None.

### Mail to Link

[](#mail-to-link)

Class: **Akibatech\\Wysiwyg\\Modifier\\MailToLink**
Description: Transforms emails adresses in clickable link tag.

Example input: `email@company.com`
Example output: `email@company.com`

Options:

```
[
    // Will replace "@" by "", set to false to disable...
    'at' => '',
]
```

### NlToBr

[](#nltobr)

Class: **Akibatech\\Wysiwyg\\Modifier\\NlToBr**
Description: Replace line breaks into HTML line breaks. Similar to php native function nl2br().

Example input: `hello   world`
Example output: `helloworld`

Options:

```
[
    // Linebreak symbol to search. Defaults to "\n"
    'search' => "\n",
    // HTML to replace. Defaults to ""
    'replace' => ''
]
```

### StripTags

[](#striptags)

Class: **Akibatech\\Wysiwyg\\Modifier\\StripTags**
Description: Remove HTML tags from input. Similar to php native function strip\_tags().

Example input: `hello world`
Example output: `hello world`

Options:

```
[
    // Allowed HTML tags (see strip_tags documentation). Defaults, none.
    'allow' => "",
]
```

### URL to Link

[](#url-to-link)

Class: **Akibatech\\Wysiwyg\\Modifier\\UrlToLink**
Description: Transforms web adresses in clickable link tag.

Example input: `https://www.github.com`
Example output: `https://www.github.com`

Options:

```
[
    // Add a custom class to all generated tags. No defaults.
    'class' => 'link',
    // Customize the link target. No defaults.
    'target' => '_blank'
]
```

### Youtube Link to Iframe

[](#youtube-link-to-iframe)

Class: **Akibatech\\Wysiwyg\\Modifier\\YoutubeLinkToIframe**
Description: Transforms youtube links (long and shorts) to a embed video player (iframe).

Example input: `My new video: https://youtu.be/wBqM2ytqHY4`
Example output: `My new video: `

Options:

```
[
    // Custom class added to the player
    'class'  => 'youtube-iframe',
    // Custom width (in px) or null
    'width'  => 560,
    // Custom height (in px) or null
    'height' => 315,
    // Allow fullscreen
    'allow_fullscreen' => true,
    // Enable youtube suggestions when video ends
    'with_suggestions' => false,
    // Display video info
    'with_infos' => true,
    // Display video controls
    'with_controls' => true
]
```

Your own modifiers
------------------

[](#your-own-modifiers)

You can easily extends the preprocessor by adding your own modifiers.
All you need is to create a class implementing **ModifierInterface**. You're also encouraged to extends **AbstractModifier** to access common methods (setOptions, getOptions, ...).

Basically, a modifier receive the input to transform through a public method **handle($input)**.
Options are handled by a public method **defaultOptions()** returning an array of available options. And in your modifier body, you can access these options with the instance attribute **options**.

### Callable modifier

[](#callable-modifier)

You also have the possibility to add a dynamic modifier.
The method "addModifier" also accepts a callback function.

Example :

```
$processor->addModifier(function($input) {
    return str_rot13('hello'); // Will return "uryyb"
});
```

Unit Tests
----------

[](#unit-tests)

WYSIWYG Preprocessor is tested with PHPUnit.
Make sure you have composer dev dependencies installed and type :

```
vendor/bin/phpunit
```

Authors
-------

[](#authors)

Author: [Marceau Casals](https://marceau.casals.fr) and [all contributors](https://github.com/MarceauKa/WYSIWYG-Preprocessor/graphs/contributors)
Licence: [MIT](https://en.wikipedia.org/wiki/MIT_License)

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.3% 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.

###  Release Activity

Cadence

Every ~0 days

Total

8

Last Release

3641d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1665333?v=4)[Marceau Casals](/maintainers/MarceauKa)[@MarceauKa](https://github.com/MarceauKa)

---

Top Contributors

[![MarceauKa](https://avatars.githubusercontent.com/u/1665333?v=4)](https://github.com/MarceauKa "MarceauKa (24 commits)")[![murribu](https://avatars.githubusercontent.com/u/5056153?v=4)](https://github.com/murribu "murribu (2 commits)")

---

Tags

bbcodelinksphpphp-librarywysiwygwysiwyg-preprocessorpluginlinkpathtagswysiwygtextareaprocessorbbcode

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/akibatech-wysiwygpreprocessor/health.svg)

```
[![Health](https://phpackages.com/badges/akibatech-wysiwygpreprocessor/health.svg)](https://phpackages.com/packages/akibatech-wysiwygpreprocessor)
```

###  Alternatives

[ergebnis/composer-normalize

Provides a composer plugin for normalizing composer.json.

1.1k40.0M2.6k](/packages/ergebnis-composer-normalize)[league/uri-components

URI components manipulation library

31937.4M89](/packages/league-uri-components)[matthiasmullie/path-converter

Relative path converter

10231.2M8](/packages/matthiasmullie-path-converter)[cakedc/tiny-mce

TinyMCE Plugin for CakePHP

10790.7k](/packages/cakedc-tiny-mce)[breadlesscode/neos-blog

Ready to use blog package

161.4k](/packages/breadlesscode-neos-blog)

PHPackages © 2026

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