phpDocumentor Configuration
[ class tree: Configuration ] [ index: Configuration ] [ all elements ]

Class: Html2Text

Source Location: /core/PHPMailer/extras/class.html2text.php

Class Html2Text

Property Summary
mixed   $allowed_tags   Contains a list of HTML tags to allow in the resulting text.
mixed   $callback_search   List of preg* regular expression patterns to search for and replace using callback function.
mixed   $ent_replace   List of pattern replacements corresponding to patterns searched.
mixed   $ent_search   List of preg* regular expression patterns to search for, used in conjunction with $ent_replace.
mixed   $html   Contains the HTML content to convert.
mixed   $pre_content   Temporary workspace used during PRE processing.
mixed   $pre_replace   List of pattern replacements corresponding to patterns searched for PRE body.
mixed   $pre_search   List of preg* regular expression patterns to search for in PRE body, used in conjunction with $pre_replace.
mixed   $replace   List of pattern replacements corresponding to patterns searched.
mixed   $search   List of preg* regular expression patterns to search for, used in conjunction with $replace.
mixed   $text   Contains the converted, formatted text.
mixed   $url   Contains the base URL that relative links should resolve to.
mixed   $width   Maximum width of the formatted text, in columns.
mixed   $_converted   Indicates whether content in the $html variable has been converted yet.
mixed   $_link_list   Contains URL addresses from links to be rendered in plain text.
mixed   $_options   Various configuration options (able to be set in the constructor)

[ Top ]
Method Summary
Html2Text   __construct()   Constructor.
string   get_text()   Returns the text, converted from HTML.
void   p()   Alias to print_text(), operates identically.
void   print_text()   Prints the text, converted from HTML.
void   set_allowed_tags()   Sets the allowed HTML tags to pass through to the resulting text.
void   set_base_url()   Sets a base URL to handle relative links.
void   set_html()   Loads source HTML into memory, either from $source string or a file.
string   _build_link_list()   Helper function called by preg_replace() on link replacement.
void   _convert()   Workhorse function that does actual conversion (calls _converter() method).
void   _converter()   Workhorse function that does actual conversion.
void   _convert_blockquotes()   Helper function for BLOCKQUOTE body conversion.
void   _convert_pre()   Helper function for PRE body conversion.
string   _preg_callback()   Callback function for preg_replace_callback use.
string   _preg_pre_callback()   Callback function for preg_replace_callback use in PRE content handler.

[ Top ]
Properties
mixed   $allowed_tags = '' [line 221]

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

API Tags:
See:  Html2Text::set_allowed_tags()
Access:  protected


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

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

API Tags:
Access:  protected


[ Top ]
mixed   $ent_replace = array(
' ', // Non-breaking space
'"', // Double quotes
"'", // Single quotes
'>',
'<',
'(c)',
'(tm)',
'(R)',
'--',
'-',
'*',
'£',
'EUR', // Euro sign. € ?
'|+|amp|+|', // Ampersand: see _converter()
' ', // Runs of spaces, post-handling
)
[line 147]

List of pattern replacements corresponding to patterns searched.

API Tags:
See:  Html2Text::$ent_search
Access:  protected


[ Top ]
mixed   $ent_search = array(
'/&(nbsp|#160);/i', // Non-breaking space
'/&(quot|rdquo|ldquo|#8220|#8221|#147|#148);/i',
// Double quotes
'/&(apos|rsquo|lsquo|#8216|#8217);/i', // Single quotes
'/&gt;/i', // Greater-than
'/&lt;/i', // Less-than
'/&(copy|#169);/i', // Copyright
'/&(trade|#8482|#153);/i', // Trademark
'/&(reg|#174);/i', // Registered
'/&(mdash|#151|#8212);/i', // mdash
'/&(ndash|minus|#8211|#8722);/i', // ndash
'/&(bull|#149|#8226);/i', // Bullet
'/&(pound|#163);/i', // Pound sign
'/&(euro|#8364);/i', // Euro sign
'/&(amp|#38);/i', // Ampersand: see _converter()
'/[ ]{2,}/', // Runs of spaces, post-handling
)
[line 122]

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

API Tags:
See:  Html2Text::$ent_replace
Access:  protected


[ Top ]
mixed   $html [line 33]

Contains the HTML content to convert.

API Tags:
Access:  protected


[ Top ]
mixed   $pre_content = '' [line 213]

Temporary workspace used during PRE processing.

API Tags:
Access:  protected


[ Top ]
mixed   $pre_replace = array(
'<br>',
'&nbsp;&nbsp;&nbsp;&nbsp;',
'&nbsp;',
'',
''
)
[line 200]

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

API Tags:
See:  Html2Text::$pre_search
Access:  protected


[ Top ]
mixed   $pre_search = array(
"/\n/",
"/\t/",
'/ /',
'/<pre[^>]*>/',
'/<\/pre>/'
)
[line 186]

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

API Tags:
See:  Html2Text::$pre_replace
Access:  protected


[ Top ]
mixed   $replace = 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>
)
[line 90]

List of pattern replacements corresponding to patterns searched.

API Tags:
See:  Html2Text::$search
Access:  protected


[ Top ]
mixed   $search = 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>
)
[line 59]

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

API Tags:
See:  Html2Text::$replace
Access:  protected


[ Top ]
mixed   $text [line 40]

Contains the converted, formatted text.

API Tags:
Access:  protected


[ Top ]
mixed   $url [line 228]

Contains the base URL that relative links should resolve to.

API Tags:
Access:  protected


[ Top ]
mixed   $width = 70 [line 50]

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 Tags:
Access:  protected


[ Top ]
mixed   $_converted = false [line 236]

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

API Tags:
See:  Html2Text::$html, Html2Text::$text
Access:  protected


[ Top ]
mixed   $_link_list = array() [line 244]

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

API Tags:
See:  Html2Text::_build_link_list()
Access:  protected


[ Top ]
mixed   $_options = array(
// '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.
'do_links' => 'inline',
// 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.
'width' => 70,
)
[line 251]

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

API Tags:
Access:  protected


[ Top ]
Methods
Constructor __construct  [line 274]

  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:
Access:  public


[ Top ]
get_text  [line 307]

  string get_text( )

Returns the text, converted from HTML.


API Tags:
Access:  public


[ Top ]
p  [line 329]

  void p( )

Alias to print_text(), operates identically.


API Tags:
See:  Html2Text::print_text()
Access:  public


[ Top ]
print_text  [line 319]

  void print_text( )

Prints the text, converted from HTML.


API Tags:
Access:  public


[ Top ]
set_allowed_tags  [line 340]

  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:
string   $allowed_tags: 

API Tags:
Access:  public


[ Top ]
set_base_url  [line 352]

  void set_base_url( [string $url = '']  )

Sets a base URL to handle relative links.

Parameters:
string   $url: 

API Tags:
Access:  public


[ Top ]
set_html  [line 291]

  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:
Access:  public


[ Top ]
_build_link_list  [line 464]

  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:
Access:  protected


[ Top ]
_convert  [line 373]

  void _convert( )

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


API Tags:
Access:  protected


[ Top ]
_converter  [line 406]

  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:
Access:  protected


[ Top ]
_convert_blockquotes  [line 544]

  void _convert_blockquotes( &$text, string $text  )

Helper function for BLOCKQUOTE body conversion.

Parameters:
string   $text:  HTML content
   &$text: 

API Tags:
Access:  protected


[ Top ]
_convert_pre  [line 507]

  void _convert_pre( &$text, string $text  )

Helper function for PRE body conversion.

Parameters:
string   $text:  HTML content
   &$text: 

API Tags:
Access:  protected


[ Top ]
_preg_callback  [line 599]

  string _preg_callback( array $matches  )

Callback function for preg_replace_callback use.

Parameters:
array   $matches:  PREG matches

API Tags:
Access:  protected


[ Top ]
_preg_pre_callback  [line 629]

  string _preg_pre_callback( array $matches  )

Callback function for preg_replace_callback use in PRE content handler.

Parameters:
array   $matches:  PREG matches

API Tags:
Access:  protected


[ Top ]

Documentation generated on Thu, 16 Apr 2015 10:26:07 +0000 by phpDocumentor 1.4.4