/ Published in: PHP
This is a simple textile function that supports most of the textile syntax. It is in it's early stages and is sure to change.
Expand |
Embed | Plain Text
function parse_textile($content, $safe_tags = '<a>, <b>, <i>, <u>, <blockquote>, <code>') { $modifiers = Array('\*\*'=>'b', '\__'=>'i', '\*'=>'strong', '\_'=>'em', '\-'=>'del', '\?\?'=>'cite', '%'=>'span', '\+'=>'ins', '\^'=>'sup', '\~'=>'sub', '@'=>'code'); $content = ereg_replace('([[:space:]])"[[:<:]](.*)[[:>:]]"([[:space:]])', '\1“\2”\3', $content); $content = ereg_replace('(<p>)(fn([[:alnum:]]){1,}. )([[:alnum:][:punct:][:space:]]+)(<\/p>)', '<p id="fn\3">\4</p>', $content); $content = str_replace(Array('--', '...', ' x ', '(TM)', '(R)', '(C)'), Array('—', '…', ' × ', '™', '®', '©'), $content); $content = ereg_replace('([[:space:]])' . $key . '([[:alnum:]\(\)\*_-~\\+\\^!?\.<\\/>]{1,}([[:alnum:][:space:]\(\)\*_-~\\+\\^!?\.<\\/>"]+)?)' . $key, '\1<' . $value . '>\2</' . $value . '>', $content); } $content = ereg_replace('([[:alnum:]]+)(\()+([[:alnum:][:space:]]+)(\))', '<acronym title="\3">\1</acronym>', $content); $content = ereg_replace('([[:space:]])((http://)[[:alnum:][:punct:]]+)([[:space:]])?', '\1<a href="\2" rel="nofollow">\2</a>\4', $content); return $content; } }
Comments
Subscribe to comments
You need to login to post a comment.

Thanks for this.