Html2Text __construct(
[string
$source = ''], [boolean
$from_file = false], [array
$options = array()]
)
|
|
Constructor.
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().
Parameters:
string |
$source: |
HTML content |
boolean |
$from_file: |
Indicates $source is a file to pull content from |
array |
$options: |
Set configuration options |
API Tags:
Returns the text, converted from HTML.
API Tags:
Alias to print_text(), operates identically.
API Tags:
Prints the text, converted from HTML.
API Tags:
void set_allowed_tags(
[string
$allowed_tags = '']
)
|
|
Sets the allowed HTML tags to pass through to the resulting text.
Tags should be in the form "<p>", with no corresponding closing tag.
Parameters:
API Tags:
void set_base_url(
[string
$url = '']
)
|
|
Sets a base URL to handle relative links.
Parameters:
API Tags:
void set_html(
string
$source, [boolean
$from_file = false]
)
|
|
Loads source HTML into memory, either from $source string or a file.
Parameters:
string |
$source: |
HTML content |
boolean |
$from_file: |
Indicates $source is a file to pull content from |
API Tags:
string _build_link_list(
string
$link, string
$display, [null
$link_override = null]
)
|
|
Helper function called by preg_replace() on link replacement.
Maintains an internal list of links to be displayed at the end of the text, with numeric indices to the original point in the text they appeared. Also makes an effort at identifying and handling absolute and relative links.
Parameters:
string |
$link: |
URL of the link |
string |
$display: |
Part of the text to associate number with |
null |
$link_override: |
|
API Tags:
Workhorse function that does actual conversion (calls _converter() method).
API Tags:
void _converter(
&$text, string
$text
)
|
|
Workhorse function that does actual conversion.
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 $this->_options['width'] characters.
Parameters:
string |
$text: |
Reference to HTML content string |
|
&$text: |
|
API Tags:
void _convert_blockquotes(
&$text, string
$text
)
|
|
Helper function for BLOCKQUOTE body conversion.
Parameters:
string |
$text: |
HTML content |
|
&$text: |
|
API Tags:
void _convert_pre(
&$text, string
$text
)
|
|
Helper function for PRE body conversion.
Parameters:
string |
$text: |
HTML content |
|
&$text: |
|
API Tags:
string _preg_callback(
array
$matches
)
|
|
Callback function for preg_replace_callback use.
Parameters:
array |
$matches: |
PREG matches |
API Tags:
string _preg_pre_callback(
array
$matches
)
|
|
Callback function for preg_replace_callback use in PRE content handler.
Parameters:
array |
$matches: |
PREG matches |
API Tags: