Remove trailing spaces and convert spaces to tabs. Props Nazgul. fixes #986

git-svn-id: https://develop.svn.wordpress.org/trunk@4495 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2006-11-19 07:56:05 +00:00
parent 603ec78946
commit e44ea1ff93
99 changed files with 1521 additions and 1521 deletions

View File

@@ -65,18 +65,18 @@ function wpautop($pee, $br = 1) {
$pee = $pee . "\n"; // just to make things a little easier, pad the end
$pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
// Space things out a little
$pee = preg_replace('!(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "\n$1", $pee);
$pee = preg_replace('!(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "\n$1", $pee);
$pee = preg_replace('!(</(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])>)!', "$1\n\n", $pee);
$pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
$pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
$pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
$pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
$pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
$pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
$pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
$pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
$pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
$pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
$pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
$pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "$1", $pee);
$pee = preg_replace('!(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee);
$pee = preg_replace('!(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee);
if ($br) {
$pee = preg_replace('/<(script|style).*?<\/\\1>/se', 'str_replace("\n", "<WPPreserveNewline />", "\\0")', $pee);
$pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
@@ -86,7 +86,7 @@ function wpautop($pee, $br = 1) {
$pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
$pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' ", $pee);
return $pee;
return $pee;
}
@@ -126,35 +126,35 @@ function wp_specialchars( $text, $quotes = 0 ) {
}
function utf8_uri_encode( $utf8_string ) {
$unicode = '';
$values = array();
$num_octets = 1;
for ($i = 0; $i < strlen( $utf8_string ); $i++ ) {
$unicode = '';
$values = array();
$num_octets = 1;
$value = ord( $utf8_string[ $i ] );
if ( $value < 128 ) {
$unicode .= chr($value);
} else {
if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
$values[] = $value;
if ( count( $values ) == $num_octets ) {
for ($i = 0; $i < strlen( $utf8_string ); $i++ ) {
$value = ord( $utf8_string[ $i ] );
if ( $value < 128 ) {
$unicode .= chr($value);
} else {
if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
$values[] = $value;
if ( count( $values ) == $num_octets ) {
if ($num_octets == 3) {
$unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]);
$unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]);
} else {
$unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]);
$unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]);
}
$values = array();
$num_octets = 1;
}
}
}
}
}
}
return $unicode;
return $unicode;
}
function remove_accents($string) {
@@ -339,7 +339,7 @@ function sanitize_title_with_dashes($title) {
return $title;
}
function convert_chars($content, $flag = 'obsolete') {
function convert_chars($content, $flag = 'obsolete') {
// Translation of invalid Unicode references range to valid range
$wp_htmltranswinuni = array(
'&#128;' => '&#8364;', // the Euro sign
@@ -405,22 +405,22 @@ function funky_javascript_fix($text) {
/*
balanceTags
Balances Tags of string using a modified stack.
@param text Text to be balanced
@return Returns balanced text
@author Leonard Lin (leonard@acm.org)
@version v1.1
@date November 4, 2001
@license GPL v2.0
@notes
@changelog
@notes
@changelog
--- Modified by Scott Reilly (coffee2code) 02 Aug 2004
1.2 ***TODO*** Make better - change loop condition to $text
1.1 Fixed handling of append/stack pop order of end text
Added Cleaning Hooks
1.0 First Version
1.2 ***TODO*** Make better - change loop condition to $text
1.1 Fixed handling of append/stack pop order of end text
Added Cleaning Hooks
1.0 First Version
*/
function balanceTags($text, $is_comment = 0, $force = false) {
@@ -446,7 +446,7 @@ function balanceTags($text, $is_comment = 0, $force = false) {
if ($regex[1][0] == "/") { // End Tag
$tag = strtolower(substr($regex[1],1));
// if too many closing tags
if($stacksize <= 0) {
if($stacksize <= 0) {
$tag = '';
//or close to be safe $tag = '/' . $tag;
}
@@ -503,7 +503,7 @@ function balanceTags($text, $is_comment = 0, $force = false) {
}
$newtext .= substr($text,0,$i) . $tag;
$text = substr($text,$i+$l);
}
}
// Clear Tag Queue
$newtext .= $tagqueue;
@@ -552,10 +552,10 @@ function backslashit($string) {
}
function trailingslashit($string) {
if ( '/' != substr($string, -1)) {
$string .= '/';
}
return $string;
if ( '/' != substr($string, -1)) {
$string .= '/';
}
return $string;
}
function addslashes_gpc($gpc) {
@@ -571,11 +571,11 @@ function addslashes_gpc($gpc) {
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
return $value;
}
function antispambot($emailaddy, $mailto=0) {
@@ -731,7 +731,7 @@ function sanitize_email($email) {
return preg_replace('/[^a-z0-9+_.@-]/i', '', $email);
}
function human_time_diff( $from, $to = '' ) {
function human_time_diff( $from, $to = '' ) {
if ( empty($to) )
$to = time();
$diff = (int) abs($to - $from);
@@ -745,7 +745,7 @@ function human_time_diff( $from, $to = '' ) {
$hours = round($diff / 3600);
if ($hours <= 1)
$since = __('1 hour');
else
else
$since = sprintf( __('%s hours'), $hours );
} elseif ($diff >= 86400) {
$days = round($diff / 86400);