You are here

function _simplenews_define_search in Simplenews 5

List of preg* regular expression patterns to search for, used in conjunction with $replace. Based on / modified from html2txt.module

1 call to _simplenews_define_search()
simplenews_html_to_text in ./simplenews.module
Convert html text to plain text.

File

./simplenews.module, line 1529

Code

function _simplenews_define_search() {
  $search = array(
    "/\r/",
    // Non-legal carriage return
    "/[\t]+/",
    // tabs
    '/<script[^>]*>.*?<\\/script>/i',
    // <script>s -- which strip_tags supposedly has problems with
    '!<h[12][^>]*>(.+?)</h[12]>!ie',
    // H1 - H2
    '/<h3[^>]*>(.+?)<\\/h3>/ie',
    // H3
    '/<h[456][^>]*>(.+?)<\\/h[456]>/ie',
    // H4 - H6
    '!<blockquote[^>]*>!i',
    // <blockquote>
    '!</blockquote>!i',
    // </blockquote>
    '!</?p[^>]*>!i',
    // <p>
    "/<br[^>]*>\n?/i",
    // <br>
    '!</?(b|strong)[^>]*>!i',
    // <b> and <strong>
    '!</?(em|i)[^>\\w]*>!i',
    // <em> and <i>
    '/(<ul[^>]*>|<\\/ul>)/i',
    // <ul> and </ul>
    '/(<ol[^>]*>|<\\/ol>)/i',
    // <ol> and </ol>
    '/(<dl[^>]*>|<\\/dl>)/i',
    // <dl> and </dl>
    '!<li[^>]*>!i',
    // <li>
    '!</li>!i',
    // </li>
    '!<dt[^>]*>!i',
    // <dt>
    '!</dt>!i',
    // </dt>
    '!<dd[^>]*>!i',
    // <dd>
    '!</dd>!i',
    // </dd>
    '/<hr[^>]*>/i',
    // <hr>
    '/(<table[^>]*>|<\\/table>)/i',
    // <table> and </table>
    '/(<tr[^>]*>|<\\/tr>)/i',
    // <tr> and </tr>
    '/<td[^>]*>(.+?)<\\/td>/i',
    // <td> and </td>
    '/<th[^>]*>(.+?)<\\/th>/i',
    // <th> and </th>
    '/&nbsp;/i',
    '/&quot;/i',
    '/&gt;/i',
    '/&lt;/i',
    '/&amp;/i',
    '/&copy;/i',
    '/&trade;/i',
    '/&#8220;/',
    '/&#8221;/',
    '/&#8211;/',
    '/&#8217;/',
    '/&#38;/',
    '/&#169;/',
    '/&#8482;/',
    '/&#151;/',
    '/&#147;/',
    '/&#148;/',
    '/&#149;/',
    '/&reg;/i',
    '/&bull;/i',
    '/&[&;]+;/i',
  );
  return $search;
}