public function convert() { require_once AK_VENDOR_DIR . DS . 'TextParsers' . DS . 'html2text.php'; $Converter = new html2text(true, 0, false); $markdown = str_replace('__AK:AMP__', '&', $Converter->load_string(str_replace('&', '__AK:AMP__', $this->source))); require_once AK_VENDOR_DIR . DS . 'TextParsers' . DS . 'smartypants.php'; $Smartypants = new SmartyPantsTypographer_Parser(); $markdown = Ak::html_entity_decode(strip_tags($Smartypants->transform($markdown))); return trim($this->_simplifyMarkdown($markdown)); }
public function defaults() { $defaults = array('url' => false, 'timezone' => 'UTC', 'license' => null, 'rewrite' => true, 'error' => 'error', 'home' => 'home', 'locale' => 'en_US.UTF8', 'routes' => array(), 'headers' => array(), 'languages' => array(), 'roles' => array(), 'cache' => false, 'debug' => 'env', 'ssl' => false, 'cache.driver' => 'file', 'cache.options' => array(), 'cache.ignore' => array(), 'cache.autoupdate' => true, 'date.handler' => 'date', 'tinyurl.enabled' => true, 'tinyurl.folder' => 'x', 'markdown' => true, 'markdown.extra' => false, 'markdown.breaks' => true, 'smartypants' => false, 'smartypants.attr' => 1, 'smartypants.doublequote.open' => '“', 'smartypants.doublequote.close' => '”', 'smartypants.space.emdash' => ' ', 'smartypants.space.endash' => ' ', 'smartypants.space.colon' => ' ', 'smartypants.space.semicolon' => ' ', 'smartypants.space.marks' => ' ', 'smartypants.space.frenchquote' => ' ', 'smartypants.space.thousand' => ' ', 'smartypants.space.unit' => ' ', 'smartypants.skip' => 'pre|code|kbd|script|style|math', 'kirbytext.video.class' => 'video', 'kirbytext.video.width' => false, 'kirbytext.video.height' => false, 'kirbytext.image.figure' => true, 'content.file.extension' => 'txt', 'content.file.ignore' => array(), 'content.file.normalize' => false, 'thumbs.driver' => 'gd', 'thumbs.filename' => '{safeName}-{hash}.{extension}', 'thumbs.destination' => false); // default markdown parser callback $defaults['markdown.parser'] = function ($text) { // initialize the right markdown class $parsedown = kirby::instance()->option('markdown.extra') ? new ParsedownExtra() : new Parsedown(); // set markdown auto-breaks $parsedown->setBreaksEnabled(kirby::instance()->option('markdown.breaks')); // parse it! return $parsedown->text($text); }; // default smartypants parser callback $defaults['smartypants.parser'] = function ($text) { $parser = new SmartyPantsTypographer_Parser(kirby::instance()->option('smartypants.attr', 1)); return $parser->transform($text); }; // css handler $defaults['css.handler'] = function ($url, $media = null) { $kirby = kirby::instance(); if (is_array($url)) { $css = array(); foreach ($url as $u) { $css[] = call($kirby->option('css.handler'), array($u, $media)); } return implode(PHP_EOL, $css) . PHP_EOL; } // auto template css files if ($url == '@auto') { $file = $kirby->site()->page()->template() . '.css'; $root = $kirby->roots()->autocss() . DS . $file; $url = $kirby->urls()->autocss() . '/' . $file; if (!file_exists($root)) { return false; } } return html::tag('link', null, array('rel' => 'stylesheet', 'href' => url($url), 'media' => $media)); }; // js handler $defaults['js.handler'] = function ($src, $async = false) { $kirby = kirby::instance(); if (is_array($src)) { $js = array(); foreach ($src as $s) { $js[] = call($kirby->option('js.handler'), array($s, $async)); } return implode(PHP_EOL, $js) . PHP_EOL; } // auto template css files if ($src == '@auto') { $file = $kirby->site()->page()->template() . '.js'; $root = $kirby->roots()->autojs() . DS . $file; $src = $kirby->urls()->autojs() . '/' . $file; if (!file_exists($root)) { return false; } } return html::tag('script', '', array('src' => url($src), 'async' => $async)); }; return $defaults; }
public function convert() { require_once AK_CONTRIB_DIR . DS . 'TextParsers' . DS . 'smartypants.php'; $Smartypants = new SmartyPantsTypographer_Parser(); return $Smartypants->transform($this->source); }