README.md 0000666 00000001272 13436752453 0006045 0 ustar 00 # Html2Text A PHP library for converting HTML to formatted plain text. [![Build Status](https://travis-ci.org/mtibben/html2text.png?branch=master)](https://travis-ci.org/mtibben/html2text) ## Basic Usage ```php $html = new \Html2Text\Html2Text('Hello, "world"'); echo $html->getText(); // Hello, "WORLD" ``` ## History This library started life on the blog of Jon Abernathy http://www.chuggnutt.com/html2text A number of projects picked up the library and started using it - among those was RoundCube mail. They made a number of updates to it over time to suit their webmail client. Now it has been extracted as a standalone library. Hopefully it can be of use to others. src/Html2Text.php 0000666 00000046461 13436752453 0007732 0 ustar 00 * * This script is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * The GNU General Public License can be found at * http://www.gnu.org/copyleft/gpl.html. * * This script is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ namespace Html2Text; class Html2Text { const ENCODING = 'UTF-8'; /** * Contains the HTML content to convert. * * @type string */ protected $html; /** * Contains the converted, formatted text. * * @type string */ protected $text; /** * List of preg* regular expression patterns to search for, * used in conjunction with $replace. * * @type array * @see $replace */ protected $search = array( "/\r/", // Non-legal carriage return "/[\n\t]+/", // Newlines and tabs '/
]*>.*?<\/head>/i', // '/