function convert_to_html() { $this->value = (string) $this->value; switch ($this->output_mode) { case 'code': return '<pre style="overflow:auto">' . htmlspecialchars($this->value, $this->specialchars_quotes, $this->specialchars_charset) . '</pre>'; case 'pre': return '<pre style="white-space: pre-wrap">' . htmlspecialchars($this->value, $this->specialchars_quotes, $this->specialchars_charset) . '</pre>'; case 'specialchars': return htmlspecialchars($this->value, $this->specialchars_quotes, $this->specialchars_charset); case 'nl2br': return nl2br(htmlentities($this->value, $this->specialchars_quotes, $this->specialchars_charset)); case 'midgard_f': return midcom_helper_misc::format_variable($this->value, 'f'); case 'midgard_F': return midcom_helper_misc::format_variable($this->value, 'F'); case 'markdown': static $markdown = null; if (!$markdown) { midcom::get('componentloader')->load_library('net.nehmer.markdown'); $markdown = new net_nehmer_markdown_markdown(); } if (!$this->purify || !$this->purify_markdown_on_output) { // Return the Markdown straight away return $markdown->render($this->value); } // Run the Markdown-generated HTML through Purifier to ensure consistency. This is expensive, however return $this->purify_string($markdown->render($this->value)); case substr($this->output_mode, 0, 1) == 'x': // Run the contents through a custom formatter registered via mgd_register_filter return midcom_helper_misc::format_variable($this->value, $this->output_mode); default: case 'html': return $this->value; } }
/** * Return a string as formatted by a Midgard formatter * @see http://www.midgard-project.org/documentation/reference-other-mgd_format/ */ function mgd_format($content, $name) { return midcom_helper_misc::format_variable($content, $name); }