chi-teck / text-formatter
A tool for handling the filtering of content.
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/chi-teck/text-formatter
Requires
- php: >=5.3.3
This package is auto-updated.
Last update: 2025-09-29 01:26:24 UTC
README
#Text Formatter
A tool for handling the filtering of content.
The code based on Drupal text filters system. Check out the documentation about how Drupal text filters work.
Usage
<?php use ChiTeck\TextFormatter\TextFormatter; use ChiTeck\TextFormatter\Filters\Html; use ChiTeck\TextFormatter\Filters\Autop; use ChiTeck\TextFormatter\Filters\Corrector; $formatter = new TextFormatter([ new Html(['allowedTags' => '<a><ul><li><p><br>']), new Autop(), new Corrector(), ]); $safeText = $formatter->checkMarkup($text);
Supported filters
- Html – Limits allowed HTML tags.
- Autop – Converts line breaks into
<p>
and<br>
in an intelligent fashion. - Corrector – Makes sure that HTML tags are properly closed.
- Escape – Escapes all HTML tags, so they will be visible instead of being effective.
- Nofollow – Adds
rel="nofollow"
to all links.
License
Text Formatter licensed under GPLv2.