/** * Format a string using Markdown syntax. Also purifies the output html. * * @param mixed $Mixed An object, array, or string to be formatted. * @return string */ public static function Markdown($Mixed) { if (!is_string($Mixed)) { return self::To($Mixed, 'Markdown'); } else { $Formatter = Gdn::Factory('HtmlFormatter'); if (is_null($Formatter)) { return Gdn_Format::Display($Mixed); } else { require_once PATH_LIBRARY . DS . 'vendors' . DS . 'markdown' . DS . 'markdown.php'; $Mixed = Markdown($Mixed); $Mixed = Gdn_Format::Links($Mixed); $Mixed = Gdn_Format::Mentions($Mixed); return $Formatter->Format($Mixed); } } }
public static function Wysiwyg($Mixed) { static $CustomFormatter; if (!isset($CustomFormatter)) { $CustomFormatter = C('Garden.Format.WysiwygFunction', FALSE); } if (!is_string($Mixed)) { return self::To($Mixed, 'Wysiwyg'); } elseif (is_callable($CustomFormatter)) { return $CustomFormatter($Mixed); } else { // The text contains html and must be purified. $Formatter = Gdn::Factory('HtmlFormatter'); if (is_null($Formatter)) { // If there is no HtmlFormatter then make sure that script injections won't work. return self::Display($Mixed); } // HTML filter first $Mixed = $Formatter->Format($Mixed); // Links $Mixed = Gdn_Format::Links($Mixed); // Mentions & Hashes $Mixed = Gdn_Format::Mentions($Mixed); $Mixed = Emoji::instance()->translateToHtml($Mixed); return $Mixed; } }