WordPress.org

Make WordPress Core

Changeset 13


Ignore:
Timestamp:
05/06/2003 08:06:41 AM (17 years ago)
Author:
saxmatt
Message:

Added wpautop.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/b2-include/b2functions.php

    r12 r13  
    9898    return $output;
    9999    }
     100
     101function wpautop($pee, $br=1) {
     102    $pee = preg_replace("/(\r\n|\n|\r)/", "\n", $pee); // cross-platform newlines
     103    $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
     104    $pee = preg_replace('/\n?(.+?)(\n\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
     105    $pee = preg_replace('/<p>\s*(<(?:table|ol|ul|pre|select|form)>)/', "$1", $pee);
     106    $pee = preg_replace('!(</(?:table|ol|ul|pre|select|form)>)</p>!', "$1", $pee);
     107    if ($br) $pee = preg_replace('|(?<!</p>)\s*\n|', "<br />\n", $pee); // optionally make line breaks
     108    $pee = preg_replace('!(</?(?:table|ul|ol|li|pre|select|form|blockquote)>)<br />!', "$1", $pee);
     109    $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
     110    $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
     111    $pee = str_replace('<p><p>', '<p>', $pee);
     112    $pee = preg_replace('#</p>\s*</p>#', '</p>', $pee);
     113    $pee = preg_replace('/&[^#](?![a-z]*;)/', '&#038;', $pee);
     114    return $pee;
     115}
    100116
    101117function autobrize($content) {
Note: See TracChangeset for help on using the changeset viewer.