Source of file MarkdownFormatter.php
Size: 1,156 Bytes - Last Modified: 2021-12-23T10:07:55+00:00
/var/www/docs.ssmods.com/process/src/code/formatters/MarkdownFormatter.php
12345678910111213141516171819202122232425262728293031323334353637383940414243 | <?php /** * A Wiki formatter for Markdown syntax * * @author Marcus Nyeholt <marcus@silverstripe.com.au> * @license BSD License (http://silverstripe.org/BSD-License) */ class MarkdownFormatter extends SimpleWikiFormatter { public function getFormatterName() { return "Markdown"; } /** * Note that we explicity pass the dataobject content here - if we don't, then * the form calls the Content() method of the CONTROLLER that the form is associated with, which means * that it returns the parsed content! * * @param DataObject $wikiPage * @return MarkItUpField */ public function getEditingField(DataObject $wikiPage) { return MarkItUpField::create('Content', '', 'markdown', 30, 20); } public function formatRaw($string) { if (!class_exists('Parsedown')) { include_once SIMPLEWIKI_DIR .'/thirdparty/parsedown-0.9.0/Parsedown.php'; } $parsedown = new Parsedown(); return $parsedown->parse($string); // include_once SIMPLEWIKI_DIR . '/thirdparty/php-markdown-extra-1.2.4/markdown.php'; return Markdown($string); } public function getHelpUrl() { return 'http://parsedown.org/'; } } |