add Textile markup (implements #94)

This commit is contained in:
oliver 2015-05-12 16:37:03 +02:00
commit e9d2b96571
5 changed files with 4303 additions and 7 deletions

View file

@ -57,14 +57,18 @@
*/
public function t($string)
{
// Remove chars
$string = htmlspecialchars($string, ENT_NOQUOTES);
// Use Textile
\hhu\z\lib\Textile::load();
$textileParser = new \Netcarver\Textile\Parser();
$string = $textileParser->textileThis($string);
// Important text
// TODO Deprecated
$string = str_replace('[strong]', '<strong>', $string);
$string = str_replace('[/strong]', '</strong>', $string);
// Create tables
// TODO Deprecated
$string = preg_replace('/(\[table\])\s+/u', '$1', $string);
$string = preg_replace('/\s*(\[tr\])\s*/u', '$1', $string);
$string = preg_replace('%\s+(\[/table\])%u', '$1', $string);
@ -78,10 +82,6 @@
$string = str_replace('[td]', '<td>', $string);
$string = str_replace('[/td]', '</td>', $string);
// Create links
$string = preg_replace('!(^|\s)"([^"]+)":(https?://[^\s]+)(\s|$)!i', '$1<a href="$3">$2</a>$4', $string);
$string = preg_replace('!(^|\s)(https?://[^\s]+)(\s|$)!i', '$1<a href="$2">$2</a>$3', $string);
// Handle Seminarymedia
$seminarymedia = array();
preg_match_all('/\[seminarymedia:(\d+)\]/iu', $string, $matches); //, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
@ -111,7 +111,8 @@
// Return processed string
return nl2br($string);
//return nl2br($string);
return $string;
}