- Html2Text\Html2Text
class Html2Text \ Html2Text
Method Summary
Name | Description |
---|---|
convert($html) | Tries to convert the given HTML into a plain text format - best suited for e-mail display, etc. |
fixNewlines($text) | Unify newlines; in particular, \r\n becomes \n, and then \r becomes \n. This means that all newlines (Unix, Windows, Mac) all become \ns. |
iterateOverNode($node) | |
nextChildName($node) | |
prevChildName($node) |
static function convert($html)
Tries to convert the given HTML into a plain text format - best suited for e-mail display, etc.
In particular, it tries to maintain the following features:
- Links are maintained, with the 'href' copied over
- Information in the <head> is lost
- Parameters:
string
- html the input HTML- Returns:
string the HTML converted, as best as possible, to text- Throws:
Html2TextException - if the HTML could not be loaded as a DOMDocument
static function fixNewlines($text)
Unify newlines; in particular, \r\n becomes \n, and then \r becomes \n. This means that all newlines (Unix, Windows, Mac) all become \ns.
- Parameters:
string
- text text with any number of \r, \r\n and \n combinations- Returns:
string the fixed text