/** * Runs the given string through "typography" parser (SmartyPants). * * @param string $source * * @return string */ public function parseTypography($source) { $source = $this->callHook('modifySmartDownTypographyInput', $source); $source = SmartyPants::defaultTransform($source); $source = $this->callHook('modifySmartDownTypographyOutput', $source); return $source; }
function do_format($value) { $value = stripcslashes($value); $value = SmartyPants::defaultTransform($value); $value = html_entity_decode($value); return $value; }
public function smartypantsFilter($content, $options = null) { if (!$options) { $options = $this->config->get('plugins.smartypants.options'); } return \Michelf\SmartyPants::defaultTransform($content, $options); }
protected function generateHtml($source, $template, $refresh) { // Check that the source file is sane if (!file_exists($source)) { throw new \Exception("Unable to open source file: {$source}"); } // Check that our template is sane, or set to the default one if (!$template) { $template = $this->app->defaultTemplate; } $templatePath = join(DIRECTORY_SEPARATOR, array($this->app->templatePath, basename($template))); $templateIndexPath = join(DIRECTORY_SEPARATOR, array($templatePath, 'index.html')); if (!file_exists($templateIndexPath)) { throw new \Exception("Unable to open template file: {$templateIndexPath}"); } $style = $this->generateContent($templatePath, 'css'); $links = $this->generateContent($templatePath, 'links'); $templateContent = file_get_contents($templateIndexPath); $resumeContent = file_get_contents($source); // Process with Markdown, and then use SmartyPants to clean up punctuation. $resumeHtml = MarkdownExtra::defaultTransform($resumeContent); $resumeHtml = SmartyPants::defaultTransform($resumeHtml); // Construct the title for the html document from the h1 and h2 tags $simpleDom = HtmlDomParser::str_get_html($resumeHtml); $title = sprintf('%s | %s', $simpleDom->find('h1', 0)->innertext, $simpleDom->find('h2', 0)->innertext); // Render the Markdown into an html file with Mustache Templates $m = new \Mustache_Engine(); $rendered = $m->render($templateContent, array('title' => $title, 'style' => $style, 'links' => $links, 'resume' => $resumeHtml, 'reload' => (bool) $refresh, 'refresh_rate' => $refresh)); return $rendered; }
public function toHTML($text) { $text = $this->preTransformText($text); $text = MarkdownExtra::defaultTransform($text); $text = SmartyPants::defaultTransform($text); $text = $this->postTransformText($text); return $text; }
/** * Apply smartypants to content */ public function onPageContentProcessed(Event $event) { $page = $event['page']; $config = $this->mergeConfig($page); if ($config->get('process_content')) { $page->setRawContent(\Michelf\SmartyPants::defaultTransform($page->getRawContent(), $config->get('options'))); } }
public function toHtml($mdStr) { $html = $this->preTransformText($mdStr); $html = MarkdownExtra::defaultTransform($html); $html = SmartyPants::defaultTransform($html); $html = $this->postTransformText($html); return $html; }
public function toHTML($text) { $html = new MarkdownExtra(); $html->code_attr_on_pre = true; $text = $this->preTransformText($text); $text = $html->defaultTransform($text); $text = SmartyPants::defaultTransform($text); $text = $this->postTransformText($text); return $text; }
/** * Apply smart quotes and other stylistic enhancements to HTML. * * @param string $html * @return string */ public static function applySmartQuotes($html) { return \Michelf\SmartyPants::defaultTransform($html, 'qbBdDiew'); }
/** * 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; }
/** * Runs $text through a SmartyPants translator, returning the translated text. * * @param string $text The text to translate. * @return string The translated text. * @access public * @static */ public static function smartypants($text) { $result = \Michelf\SmartyPants::defaultTransform($text); 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))); }
# This file passes the content of the Readme.md file in the same directory # through the SmartyPants filter. You can adapt this sample code in any way # you like. ######## # NOTE : This file requires Markdown to be available to parse the readme file. ######## # Install PSR-0-compatible class autoloader spl_autoload_register(function ($class) { require preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')) . '.php'; }); # Get SmartyPants and Markdown classes use Michelf\SmartyPants; use Michelf\MarkdownExtra; # Read file and pass content through the Markdown praser $text = file_get_contents('Readme.md'); $html = MarkdownExtra::defaultTransform($text); $html = SmartyPants::defaultTransform($html); ?> <!DOCTYPE html> <html> <head> <title>PHP Markdown Lib - Readme</title> </head> <body> <?php # Put HTML content in the document echo $html; ?> </body> </html>
/** * Fixes punctuation with SmartyPants * * @param string $content String to be parsed * @return string Parsed string */ public static function fixPunctuation($content) { if (!is_string($content)) { return null; } if (!class_exists('Michelf\\SmartyPants')) { return $content; } return \Michelf\SmartyPants::defaultTransform($content); }
/** * @param $html * @return \Twig_Markup */ public function format($html) { $html = SmartyPants::defaultTransform($html); return TemplateHelper::getRaw($html); }