Overview

Namespaces

  • Html2Text
  • Izberg
    • Exception
    • Resource
      • Category

Classes

  • Html2Text
  • Overview
  • Namespace
  • Class

Class Html2Text

Namespace: Html2Text
Located at Html2Text/Html2Text.php
Methods summary
public
# __construct( string $html = '', array $options = array() )

Parameters

$html
Source HTML
$options
Set configuration options
public
# setHtml( string $html )

Set the source HTML

Set the source HTML

Parameters

$html
HTML source content
public
# set_html( $html, $from_file = false )

Deprecated

public string
# getText( )

Returns the text, converted from HTML.

Returns the text, converted from HTML.

Returns

string
public
# get_text( )

Deprecated

public
# print_text( )

Deprecated

public
# p( )

Deprecated

public
# setBaseUrl( string $baseurl )

Sets a base URL to handle relative links.

Sets a base URL to handle relative links.

Parameters

$baseurl
public
# set_base_url( $baseurl )

Deprecated

protected
# convert( )
protected
# converter( & $text )
protected string
# buildlinkList( string $link, string $display, null $linkOverride = null )

Helper function called by preg_replace() on link replacement.

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

$link
URL of the link
$display
Part of the text to associate number with
$linkOverride

Returns

string
protected
# convertPre( & $text )
protected
# convertBlockquotes( string & $text )

Helper function for BLOCKQUOTE body conversion.

Helper function for BLOCKQUOTE body conversion.

Parameters

$text
HTML content
protected string
# pregCallback( array $matches )

Callback function for preg_replace_callback use.

Callback function for preg_replace_callback use.

Parameters

$matches
PREG matches

Returns

string
protected string
# pregPreCallback( array $matches )

Callback function for preg_replace_callback use in PRE content handler.

Callback function for preg_replace_callback use in PRE content handler.

Parameters

$matches
PREG matches

Returns

string
Constants summary
string ENCODING
# 'UTF-8'
Properties summary
protected $html

Contains the HTML content to convert.

Contains the HTML content to convert.

Type

string
#
protected $text

Contains the converted, formatted text.

Contains the converted, formatted text.

Type

string
#
protected array $search

List of preg* regular expression patterns to search for, used in conjunction with $replace.

List of preg* regular expression patterns to search for, used in conjunction with $replace.

See


Type

array
# array( "/\r/", // Non-legal carriage return "/[\n\t]+/", // Newlines and tabs '/<head[^>]*>.*?<\/head>/i', // <head> '/<script[^>]*>.*?<\/script>/i', // <script>s -- which strip_tags supposedly has problems with '/<style[^>]*>.*?<\/style>/i', // <style>s -- which strip_tags supposedly has problems with '/<p[^>]*>/i', // <P> '/<br[^>]*>/i', // <br> '/<i[^>]*>(.*?)<\/i>/i', // <i> '/<em[^>]*>(.*?)<\/em>/i', // <em> '/(<ul[^>]*>|<\/ul>)/i', // <ul> and </ul> '/(<ol[^>]*>|<\/ol>)/i', // <ol> and </ol> '/(<dl[^>]*>|<\/dl>)/i', // <dl> and </dl> '/<li[^>]*>(.*?)<\/li>/i', // <li> and </li> '/<dd[^>]*>(.*?)<\/dd>/i', // <dd> and </dd> '/<dt[^>]*>(.*?)<\/dt>/i', // <dt> and </dt> '/<li[^>]*>/i', // <li> '/<hr[^>]*>/i', // <hr> '/<div[^>]*>/i', // <div> '/(<table[^>]*>|<\/table>)/i', // <table> and </table> '/(<tr[^>]*>|<\/tr>)/i', // <tr> and </tr> '/<td[^>]*>(.*?)<\/td>/i', // <td> and </td> '/<span class="_html2text_ignore">.+?<\/span>/i', // <span class="_html2text_ignore">...</span> )
protected array $replace

List of pattern replacements corresponding to patterns searched.

List of pattern replacements corresponding to patterns searched.

See


Type

array
# array( '', // Non-legal carriage return ' ', // Newlines and tabs '', // <head> '', // <script>s -- which strip_tags supposedly has problems with '', // <style>s -- which strip_tags supposedly has problems with "\n\n", // <P> "\n", // <br> '_\\1_', // <i> '_\\1_', // <em> "\n\n", // <ul> and </ul> "\n\n", // <ol> and </ol> "\n\n", // <dl> and </dl> "\t* \\1\n", // <li> and </li> " \\1\n", // <dd> and </dd> "\t* \\1", // <dt> and </dt> "\n\t* ", // <li> "\n-------------------------\n", // <hr> "<div>\n", // <div> "\n\n", // <table> and </table> "\n", // <tr> and </tr> "\t\t\\1\n", // <td> and </td> "" // <span class="_html2text_ignore">...</span> )
protected array $entSearch

List of preg* regular expression patterns to search for, used in conjunction with $entReplace.

List of preg* regular expression patterns to search for, used in conjunction with $entReplace.

See


Type

array
# array( '/&#153;/i', // TM symbol in win-1252 '/&#151;/i', // m-dash in win-1252 '/&(amp|#38);/i', // Ampersand: see converter() '/[ ]{2,}/', // Runs of spaces, post-handling )
protected array $entReplace

List of pattern replacements corresponding to patterns searched.

List of pattern replacements corresponding to patterns searched.

See


Type

array
# array( '™', // TM symbol '—', // m-dash '|+|amp|+|', // Ampersand: see converter() ' ', // Runs of spaces, post-handling )
protected array $callbackSearch

List of preg* regular expression patterns to search for and replace using callback function.

List of preg* regular expression patterns to search for and replace using callback function.

Type

array
# array( '/<(h)[123456]( [^>]*)?>(.*?)<\/h[123456]>/i', // h1 - h6 '/<(b)( [^>]*)?>(.*?)<\/b>/i', // <b> '/<(strong)( [^>]*)?>(.*?)<\/strong>/i', // <strong> '/<(th)( [^>]*)?>(.*?)<\/th>/i', // <th> and </th> '/<(a) [^>]*href=("|\')([^"\']+)\2([^>]*)>(.*?)<\/a>/i' // <a href=""> )
protected array $preSearch

List of preg* regular expression patterns to search for in PRE body, used in conjunction with $preReplace.

List of preg* regular expression patterns to search for in PRE body, used in conjunction with $preReplace.

See


Type

array
# array( "/\n/", "/\t/", '/ /', '/<pre[^>]*>/', '/<\/pre>/' )
protected array $preReplace

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

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

See


Type

array
# array( '<br>', '&nbsp;&nbsp;&nbsp;&nbsp;', '&nbsp;', '', '', )
protected string $preContent

Temporary workspace used during PRE processing.

Temporary workspace used during PRE processing.

Type

string
# ''
protected string $baseurl

Contains the base URL that relative links should resolve to.

Contains the base URL that relative links should resolve to.

Type

string
# ''
protected boolean $converted

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

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

See

,

Type

boolean
# false
protected array $linkList

Contains URL addresses from links to be rendered in plain text.

Contains URL addresses from links to be rendered in plain text.

See

Html2Text\Html2Text::buildlinkList()

Type

array
# array()
protected array $options

Various configuration options (able to be set in the constructor)

Various configuration options (able to be set in the constructor)

Type

array
# array( '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. '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. )
API documentation generated by ApiGen