Man, this is awesome? Are you using an implementation of this anywhere?

Actually, I got curious and implemented the main bits with PHP regexes:

function markless($text){
 $u = "\w\.\:\/\\\\";
 $s = "\s\r\n\*";
 $tld = "com|org|net|co|gov|io";

 $text = preg_replace("`([\r\n]+)([^\r\n]+)[\r\n]+\={5,}([\r\n]+)`","$1<h1>$2</h1>$3",$text);
 $text = preg_replace("`([\r\n]+)([^\r\n]+)[\r\n]+\-{5,}([\r\n]+)`","$1<h2>$2</h2>$3",$text);
 $text = preg_replace("`([\r\n]+)([^\r\n]+)[\r\n]+\.{5,}([\r\n]+)`","$1<h3>$2</h3>$3",$text);

 $text = preg_replace("`[".$u."]+\.(".$tld.")[".$u."]+\.(:?png|gif|jpg|jpeg|bmp|tiff)`","<img src=\"$0\">",$text);
 $text = preg_replace("`[".$u."]+\.(".$tld.")[".$u."]+\.(mp4|mov|ogv|webm)`","<video controls autoload=\"metadata\"><source src=\"$0\" type=\"video/$2\"></video>",$text);
 $text = preg_replace("`[".$u."]+\.(".$tld.")[".$u."]+\.(mp3|wav)`","<video controls autoload=\"metadata\"><source src=\"$0\" type=\"audio/$2\"></video>",$text);
 $text = preg_replace("`([".$s."]+)([".$u."]+\.(com|org|net|co|gov|io)[".$u."]+)([".$s."]+)`","$1<a href=\"$2\">$2</a>$4",$text);
 $text = preg_replace("`[\r\n]{2,}`","</p><p>",$text);
 $text = preg_replace("`[\r\n]`","<br>",$text);
 $text = preg_replace("`\*(.*?)\*`","<strong>$1</strong>", $text);
 $text = preg_replace("`([".$s."]+)[\/\\\\](.+?)[\/\\\\]([".$s."]+)`","$1<em>$2</em>$3",$text);
 return $text;
}


Leave a Reply

Your email address will not be published. Required fields are marked *