Skip to content

Commit

Permalink
Fixes for a few fiddly inline url replacement cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kolber committed Sep 14, 2009
1 parent b0ec4d2 commit c4c137c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/stacey.inc.php
Expand Up @@ -350,13 +350,15 @@ static function sort_by_length($a,$b){
function preparse($text) {
$patterns = array(
# replace inline colons
'/(?<=\n)([a-z0-9_-]+?):/',
'/(?<=\n)([a-z0-9_-]+?):(?!\/)/',
'/:/',
'/\\\x01/',
# replace inline dashes
'/(?<=\n)-/',
'/-/',
'/\\\x02/',
# automatically link http:// websites
'/(?<!")http&#58;\/\/([\S]+\.[\S]*\.?[A-Za-z0-9]{2,4})/',
# convert lists
'/\n?-(.+?)(?=\n)/',
'/(<li>.*<\/li>)/',
Expand All @@ -366,8 +368,6 @@ function preparse($text) {
'/: (.+)(?=\n<p>)/',
# automatically link email addresses
'/([A-Za-z0-9.-]+)@([A-Za-z0-9.-]+\.[A-Za-z]{2,4})/',
# automatically link http:// websites
'/http&#58;\/\/([A-Za-z0-9.-]+\.[A-Za-z]{2,4})/',
);
$replacements = array(
# replace inline colons
Expand All @@ -378,6 +378,8 @@ function preparse($text) {
'\\x02',
'&#45;',
'-',
# automatically link http:// websites
'<a href="http&#58;//$1">http&#58;//$1</a>',
# convert lists
'<li>$1</li>',
'<ul>$1</ul>',
Expand All @@ -387,8 +389,6 @@ function preparse($text) {
':<p>$1</p>',
# automatically link email addresses
'<a href="mailto&#58;$1&#64;$2">$1&#64;$2</a>',
# automatically link http:// websites
'<a href="http&#58;//$1">http&#58;//$1</a>',
);
$parsed_text = preg_replace($patterns, $replacements, $text);
return $parsed_text;
Expand Down

0 comments on commit c4c137c

Please sign in to comment.