/** * Converts a markdown string into HTML * * @package Reditype * @subpackage helper * @param string $string * @param rtPage $object * @param bool $summary * @return string */ function markdown_to_html($string, $object = null, $summary = false) { $section = $summary ? 'head' : 'all'; $rt_string = new rtTypeString($string, array('object' => $object, 'section' => $section)); return $rt_string->transform(); }
/** * Replace occurances of markdown snippet includes with the snippet content. * * @param array $matches * @return string */ protected function _markupSnippetInText($matches) { $collection = $matches[2]; $snippet = Doctrine::getTable('rtSnippet')->findOneByCollection($collection); if (!$snippet) { return '<small class="asst-link-error">[snippet:' . $collection . ']?</small>'; } // check for cicular references $o_collection = ''; try { $o_collection = $this->_options['object']->getCollection(); if ($o_collection == $collection) { return 'Circular reference found!'; } } catch (Exception $e) { // do nothing, just pass on. } $text = new rtTypeString($snippet->getContent(), array('object' => $snippet)); return $text->transform(); }
<?php require_once dirname(__FILE__) . '/../bootstrap/unit.php'; require_once dirname(__FILE__) . '/../../plugins/rtCorePlugin/lib/toolkit/rtIndexToolkit.class.php'; $t = new lime_test(11); $s = new rtTypeString('hello'); $t->is($s->transform(), 'hello');