public function getHtml() { $cacheKey = $this->getHtmlCacheKey(); if (false === ($result = Cache::fetch($cacheKey))) { $result = ''; switch ($this->Renderer) { case 'text': $result = htmlspecialchars($this->Content); break; case 'html': $result = $this->Content; break; case 'markdown': $result = \Michelf\SmartyPantsTypographer::defaultTransform(\Michelf\MarkdownExtra::defaultTransform($this->Content)); break; } Cache::store($cacheKey, $result); } return $result; }
public function renderBody() { return '<div class="content-item content-markdown" data-itemId="' . $this->ID . '">' . \Michelf\SmartyPantsTypographer::defaultTransform(\Michelf\MarkdownExtra::defaultTransform($this->Data)) . '</div>'; }
/** * Translate plain ASCII punctuation characters into "smart" typographic punctuation HTML entities. * * @param string $string text to transform * @return array */ public static function smartypants($string) { // start measuring $hash = Debug::markStart('parsing', 'smartypants'); if (Config::get('enable_smartypants', true) === 'typographer') { $result = SmartyPantsTypographer::defaultTransform($string); } else { $result = SmartyPants::defaultTransform($string); } // end measuring Debug::markEnd($hash); Debug::increment('parses', 'smartypants'); return $result; }
/** * Sets a GLOBAL plaintext body by first transforming the body to HTML, then stripping HTML tags from the body * @see http://board.s9y.org/viewtopic.php?f=11&t=18351 Discussion of this feature in the S9y forum. * * @param array $eventData * @param int $version Markdown Classic or Lib default 2 * @param int $pants SmartyPants option default 0 */ function setPlaintextBody(array $eventData, $version = 2, $pants = 0) { if (isset($GLOBALS['entry'][0]['plaintext_body'])) { $html = $version == 2 ? Markdown::defaultTransform($GLOBALS['entry'][0]['plaintext_body']) : Markdown($GLOBALS['entry'][0]['plaintext_body']); } else { $html = $version == 2 ? Markdown::defaultTransform(html_entity_decode($eventData['body'], ENT_COMPAT, LANG_CHARSET)) : Markdown(html_entity_decode($eventData['body'], ENT_COMPAT, LANG_CHARSET)); } if ($pants > 0) { $html = $pants == 2 ? SmartyPantsTypographer::defaultTransform($html) : SmartyPants::defaultTransform($html); } $GLOBALS['entry'][0]['plaintext_body'] = trim(strip_tags(str_replace('javascript:', '', $html))); }
/** * @param $html * @return \Twig_Markup */ public function typographer($html) { $html = SmartyPantsTypographer::defaultTransform($html); return TemplateHelper::getRaw($html); }