");
+ if (!$full) $str = my_replace($str, "<", ">", '"', "'|'");
+ $str = str_replace('"', """, $str);
+ if (!$full) $str = str_replace("'|'", '"', $str);
return $str;
}
function ParseNewline($str, $paragraphs = false) {
if (!$str) return $str;
- if ($paragraphs) $str = preg_replace('/\s*(\r\n\r\n|\n\r\n\r|\n\n|\r\r)/m', ' ', $str);
- $str = ereg_replace("[ \t]*(\r\n?|\n\r?)", '
', $str);
+ $str = str_replace("\r\n", "\n", $str);
+ if ($paragraphs) $str = preg_replace('/[ ]*\n\n/s', '
', $str);
+ $str = preg_replace('/[ ]*\n/s', '
'."\n", $str);
return $str;
}
@@ -55,46 +85,63 @@
"Scaron" => "©", "#352" => "©",
"scaron" => "¹", "#353" => "¹",
"Ccaron" => "È", "#268" => "È", "#268" => "È",
- "ccaron" => "è", "#232" => "è", "#269" => "è",
+ "ccaron" => "è", "egrave" => "è", "#232" => "è", "#269" => "è",
"Cgrave" => "Æ", "#262" => "Æ", "#" => "Æ",
- "cgrave" => "æ", "#230" => "æ", "#263" => "æ",
- "???" => "Ð", "#272" => "Ð", "#" => "Ð",
- "???" => "ð", "#273" => "ð",
+ "cgrave" => "æ", "aelig" => "æ", "#230" => "æ", "#263" => "æ",
+ ">" => "Ð", "#272" => "Ð", "#" => "Ð",
+ ">" => "ð", "eth" => "ð", "#273" => "ð",
"Zcaron" => "®", "#381" => "®",
"zcaron" => "¾", "#382" => "¾",
);
- $t = intval($str);
# Skip if not a scalar
- if (!is_scalar($str)) return $str;
+ if (!is_string($str)) return $str;
# If a number, don't touch it
- if (strcmp(intval($str), $str) == 0) return $str;
- # Replace "
" with "\n"
- $str = preg_replace("/\
/m", "\n", $str);
- # Replace "<...>\n" with "<...>"
- $str = preg_replace("/(\<[^\/][^\>]*\>)\s*(\r\n?|\n\r?)\s*/m", '$1', $str);
- # Replace "\n" with "\n"
- $str = preg_replace("/\s*(\r\n?|\n\r?)\s*(\<\/[^\>]+\>)/m", '$2$1', $str);
- # Remove "
"/"", and anything in between.
- $str = preg_replace("/\<\s*HEAD[^\>]*\>.*\<\/\s*HEAD\s*\>(\r\n?|\n\r?)*/ims", '', $str);
- # Remove all "", "", "", "", "" and "BR" tags, along with their pairs
- $str = preg_replace("/\<\/?\s*(HTML|HEAD|BODY|FONT|P|BR)[^\>]*\>/im", '', $str);
- # Replace "\n
- " or "
- \n" with "
- "
- $str = preg_replace("/(\s*(\r\n?|\n\r?))*(\<\/\s*LI\s*\>)(\s*(\r\n?|\n\r?))*/m", '$3', $str);
- # Replace "
\n" or "\n" with "" or "", respectively
- $str = preg_replace("/(\<\s*(UL|OL)\s*\>)(\s*(\r\n?|\n\r?))+/m", '$1', $str);
- # Replace "\n
" or "\n
" with "
" or "
", respectively
- $str = preg_replace("/(\s*(\r\n?|\n\r?))+(\<\/\s*(UL|OL)\s*\>)/m", '$3', $str);
- # Replace "``" and "''" with """ (a single double quote)
+ if (strcmp(intval($str)."", $str."") == 0) return $str;
+
+ # Replace "``" and "''" with """ (normal ASCII double quote)
$str = str_replace("“", '"', $str);
$str = str_replace("”", '"', $str);
# Replace "-" with "-"
$str = str_replace("—", '-', $str);
# Replace character references ("&...;" and "...;") with its value
- $str = preg_replace("/\&([^;]+);/em", '$entities["$1"]?$entities["$1"]:"?"', $str);
- # Remove all whitespace at beginning or ending of a line
- $str = preg_replace("/(^\s+|\s+$)/", '', $str);
+ $str = preg_replace('/\&([^;]+);/em', '$entities["$1"]?$entities["$1"]:"?"', $str);
+ # Remove all whitespace from line beginnings and endings
+ $str = preg_replace('/(^[ ]+|[ ]+$)/s', '', $str);
+ # Remove "" with "\n"
+ $str = preg_replace('/\<\s*P[^\>]*\>/im', "", $str);
+ # Replace "
" with "\n"
+ $str = preg_replace('/\<\/\s*P[^\>]*\>/im', "\n", $str);
+ # Replace "