コード例 #1
0
ファイル: Parser.php プロジェクト: kamicrafted/designhub
 /**
  * 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;
 }
コード例 #2
0
 function do_format($value)
 {
     $value = stripcslashes($value);
     $value = SmartyPants::defaultTransform($value);
     $value = html_entity_decode($value);
     return $value;
 }
コード例 #3
0
 public function smartypantsFilter($content, $options = null)
 {
     if (!$options) {
         $options = $this->config->get('plugins.smartypants.options');
     }
     return \Michelf\SmartyPants::defaultTransform($content, $options);
 }
コード例 #4
0
 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;
 }
コード例 #5
0
ファイル: Markdowner.php プロジェクト: Armen2004/laravel_blog
 public function toHTML($text)
 {
     $text = $this->preTransformText($text);
     $text = MarkdownExtra::defaultTransform($text);
     $text = SmartyPants::defaultTransform($text);
     $text = $this->postTransformText($text);
     return $text;
 }
コード例 #6
0
 /**
  * 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')));
     }
 }
コード例 #7
0
ファイル: Markdowner.php プロジェクト: strever/blog
 public function toHtml($mdStr)
 {
     $html = $this->preTransformText($mdStr);
     $html = MarkdownExtra::defaultTransform($html);
     $html = SmartyPants::defaultTransform($html);
     $html = $this->postTransformText($html);
     return $html;
 }
コード例 #8
0
ファイル: Markdowner.php プロジェクト: sloan58/karma-tek
 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;
 }
コード例 #9
0
ファイル: formatter.php プロジェクト: rhymix/rhymix
 /**
  * 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');
 }
コード例 #10
0
ファイル: parse.php プロジェクト: Bferreira5/Theme-Example
 /**
  * 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;
 }
コード例 #11
0
ファイル: BedrockString.php プロジェクト: quentinhill/bedrock
 /**
  * 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;
 }
コード例 #12
0
 /**
  * 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)));
 }
コード例 #13
0
ファイル: Readme.php プロジェクト: edom-huang/myBlog
# 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>
コード例 #14
0
ファイル: Utils.php プロジェクト: ponticlaro/bebop-common
 /**
  * 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);
 }