public function render($text = null, $trim = true, $htmlentities = false)
{
if (null === $text) {
$text = $this->renderChildren();
}
if (null === $text) {
return null;
}
$cacheIdentifier = sha1($text);
if (true === $this->cache->has($cacheIdentifier)) {
return $this->cache->get($cacheIdentifier);
}
$this->markdownExecutablePath = CommandUtility::getCommand('markdown');
if (false === is_executable($this->markdownExecutablePath)) {
throw new Exception('Use of Markdown requires the "markdown" shell utility to be installed and accessible; this binary ' . 'could not be found in any of your configured paths available to this script', 1350511561);
}
if (true === (bool) $trim) {
$text = trim($text);
}
if (true === (bool) $htmlentities) {
$text = htmlentities($text);
}
$transformed = $this->transform($text);
$this->cache->set($cacheIdentifier, $transformed);
return $transformed;
}