diff --git a/README.md b/README.md index e66da7b..80ba8c2 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,37 @@ composer require html2text/html2text ## Basic Usage ```php -$html = new \Html2Text\Html2Text('Hello, "world"'); +$html2text = new \Html2Text\Html2Text('Hello, "world"'); -echo $html->getText(); // Hello, "WORLD" +echo $html2text->getText(); // Hello, "WORLD" +``` + +## Options + +The constructor takes an optional 2nd parameter which is an array of options. +```php +$html2text = new \Html2Text\Html2Text(string $html, array $options = []); +``` + +Options and defaults are: +```php +[ + 'do_links' => 'inline', // 'none' + // 'inline' (show links inline) + // 'nextline' (show links on the next line) + // 'table' (if a table of link URLs should be listed after the text. + // 'bbcode' (show links as bbcode) + + 'width' => 70, // Maximum width of the formatted text, in columns. + // Set this value to 0 (or less) to ignore word wrapping + // and not constrain text to a fixed-width column. + + 'plain_text' => false, // If true then disables various pseudo formatting: + // No converting bold, th or headings to upper case. + // No character conversion to simulate strike through for + // No adding _ around italic text ( and tags) + //
is replaced by "\n\n" rather than "\n-------------------------\n" +]; ``` ## History diff --git a/src/Html2Text.php b/src/Html2Text.php index 16a6572..6ec2a43 100644 --- a/src/Html2Text.php +++ b/src/Html2Text.php @@ -102,6 +102,38 @@ class Html2Text '[\\2]', // with alt tag ); + /** + * List of pattern replacements corresponding to patterns searched. + * Used with 'plain_text' option. + * + * @var array $replace + * @see $search + */ + protected $replace_plain = array( + '', // Non-legal carriage return + ' ', // Newlines and tabs + '', // + '', //