chi-teck/text-formatter

A tool for handling the filtering of content.

dev-master 2014-01-10 17:53 UTC

This package is auto-updated.

Last update: 2024-11-29 04:46:37 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.