html2text

Extends \rcube_html2text

Converts HTML to formatted plain text

Methods

Constructor.

__construct(string $source = '', boolean $from_file = false, boolean $do_links = true, integer $width = 75, $charset = 'UTF-8') 
inherited

If the HTML source string (or file) is supplied, the class will instantiate with that source propagated, all that has to be done it to call get_text().

Arguments

$source

string

HTML content

$from_file

boolean

Indicates $source is a file to pull content from

$do_links

boolean

Indicate whether a table of link URLs is desired

$width

integer

Maximum width of the formatted text, 0 for no limit

$charset

Loads source HTML into memory, either from $source string or a file.

set_html(string $source, boolean $from_file = false) 
inherited

Arguments

$source

string

HTML content

$from_file

boolean

Indicates $source is a file to pull content from

Returns the text, converted from HTML.

get_text() : string
inherited

Response

string

Plain text

Prints the text, converted from HTML.

print_text() 
inherited

Sets the allowed HTML tags to pass through to the resulting text.

set_allowed_tags($allowed_tags = '') 
inherited

Tags should be in the form "

", with no corresponding closing tag.

Arguments

$allowed_tags

Sets a base URL to handle relative links.

set_base_url($url = '') 
inherited

Arguments

$url

Workhorse function that does actual conversion (calls _converter() method).

_convert() 
inherited

Workhorse function that does actual conversion.

_converter(&$text) 
inherited

First performs custom tag replacement specified by $search and $replace arrays. Then strips any remaining HTML tags, reduces whitespace and newlines to a readable format, and word wraps the text to $width characters.

Arguments

$text

Helper function for PRE body conversion.

_convert_pre(&$text) 
inherited

Arguments

$text

Helper function for BLOCKQUOTE body conversion.

_convert_blockquotes(&$text) 
inherited

Arguments

$text

Callback function to correctly add citation markers for blockquote contents

blockquote_citation_callback($m) 
inherited

Arguments

$m

Callback function for preg_replace_callback use.

tags_preg_callback($matches) : string
inherited

Arguments

$matches

Response

string

Callback function for preg_replace_callback use in PRE content handler.

pre_preg_callback($matches) : string
inherited

Arguments

$matches

Response

string

Strtoupper function with HTML tags and entities handling.

_toupper(string $str) : string
inherited

Arguments

$str

string

Text to convert

Response

string

Converted text

Strtoupper multibyte wrapper function with HTML entities handling.

_strtoupper(string $str) : string
inherited

Arguments

$str

string

Text to convert

Response

string

Converted text

Properties

Contains the HTML content to convert.

html : string
inherited
var

Type(s)

string

Contains the converted, formatted text.

text : string
inherited
var

Type(s)

string

Maximum width of the formatted text, in columns.

width : integer
inherited

Set this value to 0 (or less) to ignore word wrapping and not constrain text to a fixed-width column.

var

Type(s)

integer

Target character encoding for output text

charset : string
inherited
var

Type(s)

string

List of pattern replacements corresponding to patterns searched.

replace : array
inherited
var
see

Type(s)

array

List of pattern replacements corresponding to patterns searched.

ent_replace : array
inherited
var
see

Type(s)

array

List of pattern replacements corresponding to patterns searched for PRE body.

pre_replace : array
inherited
var
see

Type(s)

array

Contains a list of HTML tags to allow in the resulting text.

allowed_tags : string
inherited
var
see

Type(s)

string

Contains the base URL that relative links should resolve to.

url : string
inherited
var

Type(s)

string

Indicates whether content in the $html variable has been converted yet.

_converted : boolean
inherited
var
see

$text

Type(s)

boolean