当前位置: 首页>>代码示例>>PHP>>正文


PHP ParsedownExtra类代码示例

本文整理汇总了PHP中ParsedownExtra的典型用法代码示例。如果您正苦于以下问题:PHP ParsedownExtra类的具体用法?PHP ParsedownExtra怎么用?PHP ParsedownExtra使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ParsedownExtra类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: markdown

 /**
  * Parse and transform Markdown strings into HTML
  *
  * @param string  $string  text to transform
  * @return string
  */
 public static function markdown($string)
 {
     // start measuring
     $hash = Debug::markStart('parsing', 'markdown');
     // check for parser, create if needed
     if (!isset(self::$parsers['markdown'])) {
         if (strtolower(Config::get('markdown_parser', 'standard')) === "parsedown") {
             $parser = new ParsedownExtra();
             $parser->setUrlsLinked(Config::get('markdown:convert_urls_to_links', true));
         } else {
             $parser = new MarkdownExtra();
             $parser->no_markup = Config::get('markdown:no_markup', false);
             $parser->no_entities = Config::get('markdown:no_entities', false);
             $parser->predef_urls = Config::get('markdown:predefined_urls', array());
             $parser->predef_abbr = Config::get('markdown:predefined_abbreviations', array());
             $parser->code_class_prefix = Config::get('markdown:code_class_prefix', '');
             $parser->code_attr_on_pre = Config::get('markdown:code_attr_on_pre', false);
         }
         self::$parsers['markdown'] = $parser;
     }
     // parse for markdown
     if (strtolower(Config::get('markdown_parser', 'standard')) === "parsedown") {
         $result = self::$parsers['markdown']->text($string);
     } else {
         $result = self::$parsers['markdown']->transform($string);
     }
     // end measuring
     Debug::markEnd($hash);
     Debug::increment('parses', 'markdown');
     return $result;
 }
开发者ID:Bferreira5,项目名称:Theme-Example,代码行数:37,代码来源:parse.php

示例2: render

 public function render($path, $params)
 {
     $view = $this->_view;
     $options = $this->_options;
     $Extra = new \ParsedownExtra();
     echo $Extra->text(file_get_contents($path));
 }
开发者ID:CloudOJ,项目名称:ums,代码行数:7,代码来源:MarkdownAdapter.php

示例3: changelog

 public function changelog()
 {
     $output = '';
     $url = 'https://api.github.com/repos/arastta/arastta/releases';
     $json = $this->utility->getRemoteData($url);
     if (empty($json)) {
         return $output;
     }
     $parsedown = new ParsedownExtra();
     $releases = json_decode($json);
     foreach ($releases as $release) {
         if ($release->tag_name <= VERSION) {
             continue;
         }
         if (empty($release->body)) {
             continue;
         }
         $output .= '<h2><span class="label label-primary">' . $release->tag_name . '</span></h2>';
         // Parse markdown output
         $markdown = str_replace('## Changelog', '', $release->body);
         $output .= $parsedown->text($markdown);
         $output .= '<hr>';
     }
     return $output;
 }
开发者ID:LinuxJedi,项目名称:arastta,代码行数:25,代码来源:update.php

示例4: parse_string

 public function parse_string($template, $data = array(), $return = FALSE, $config = array())
 {
     if (!is_array($config)) {
         $config = array();
     }
     $config = array_merge($this->config, $config);
     $ci = $this->ci;
     $is_mx = false;
     if (!$return) {
         list($ci, $is_mx) = $this->detect_mx();
     }
     switch ($config['markdown_implementation']) {
         case 'parsedown':
             $parser = new ParsedownExtra();
             $template = @$parser->text($template);
             break;
         default:
             if (!empty($config['detect_code_blocks'])) {
                 $template = preg_replace('/`{3,}[a-z]*/i', '~~~', $template);
             }
             $parser = new MarkdownExtra_Parser();
             $template = @$parser->transform($template);
             if (!empty($config['apply_autolink'])) {
                 $this->ci->load->helper('url');
                 $template = auto_link($template);
             }
             break;
     }
     return $this->output($template, $return, $ci, $is_mx);
 }
开发者ID:Qnatz,项目名称:starter-public-edition-4,代码行数:30,代码来源:Parser_markdown.php

示例5: parseMarkdown

 public static function parseMarkdown($value)
 {
     include_once __DIR__ . '/vendor/Parsedown.php';
     include_once __DIR__ . '/vendor/ParsedownExtra.php';
     $parser = new \ParsedownExtra();
     $parser->setUrlsLinked(false);
     return $parser->text($value);
 }
开发者ID:bobbiebenton,项目名称:herbie,代码行数:8,代码来源:markdown.php

示例6: convert

 /**
  * Convert the input data.
  *
  * @param string $input The raw content without Front-matter
  *
  * @return string
  */
 public function convert($input)
 {
     if (is_string($input) === false) {
         throw new \InvalidArgumentException('Expected a string value at Parsedown converter.');
     }
     $converter = new \ParsedownExtra();
     return $converter->text($input);
 }
开发者ID:spress,项目名称:spress,代码行数:15,代码来源:ParsedownConverter.php

示例7: previewpost

 public function previewpost()
 {
     $this->load->library('Parsedown');
     $this->load->library('ParsedownExtra');
     $tulisan = $this->input->post('inilah');
     /*$tulisan = htmlspecialchars($_POST['inilah']);*/
     $Tulis = new ParsedownExtra();
     echo $Tulis->text($tulisan);
 }
开发者ID:dpyudha,项目名称:pinguin,代码行数:9,代码来源:admin.php

示例8: execute

 protected function execute(array $arguments)
 {
     if (isset($arguments[0]) && ($wf_id = (int) $GLOBALS['workflow_id'])) {
         $extra = new \ParsedownExtra();
         WorkflowRepository::component_result($wf_id, 'markdown-view', $extra->text($arguments[0]));
         return '';
     }
     throw new InvalidArgumentException('strings invalid');
 }
开发者ID:sysatom,项目名称:workflow,代码行数:9,代码来源:MarkdowmView.php

示例9: get

 public function get()
 {
     $content = [];
     $count = 1;
     // initial object creation
     foreach (glob(ELSA . '/content/' . $this->folder . '/*.' . $this->extension) as $contentItem) {
         // parse content
         $frontmatter = new FrontMatter($contentItem);
         $parsedown = new ParsedownExtra();
         $meta = [];
         $type = preg_match('/content\\/(.*)\\//', $contentItem, $match);
         $type = $match[1];
         foreach ($frontmatter->fetchMeta() as $key => $value) {
             $meta[$key] = $value;
         }
         // compose
         $content[$count]['id'] = (int) @explode('_', array_pop(explode('/', $contentItem)))[0];
         $content[$count]['slug'] = @explode('.', explode('_', array_pop(explode('/', $contentItem)))[1])[0];
         $content[$count]['content'] = $parsedown->text($frontmatter->fetchContent());
         $content[$count]['content_raw'] = $frontmatter->fetchContent();
         $content[$count]['type'] = $type;
         $content[$count]['meta'] = $meta;
         $count++;
     }
     // order
     usort($content, function ($a, $b) {
         // id desc
         if ($this->orderby === 'id' && $this->order === 'desc') {
             return $b['id'] - $a['id'];
         }
         // id asc
         if ($this->orderby === 'id' && $this->order === 'asc') {
             return $a['id'] - $b['id'];
         }
         // timestamp desc
         if ($this->orderby === 'timestamp' && $this->order === 'desc') {
             return $b['meta']['timestamp'] - $a['meta']['timestamp'];
         }
         // timestamp asc
         if ($this->orderby === 'timestamp' && $this->order === 'asc') {
             return $a['meta']['timestamp'] - $b['meta']['timestamp'];
         }
     });
     // convert to objects
     $content = json_decode(json_encode($content));
     // with slug ...
     if ($this->slug) {
         // find the content we want
         foreach ($content as $contentItem) {
             if ($contentItem->slug === $this->slug) {
                 return $contentItem;
                 break;
             }
         }
     }
     return $content;
 }
开发者ID:askoxyz,项目名称:elsa,代码行数:57,代码来源:Content.php

示例10: getPageContent

 /**
  * Get the content of a file
  * @param  string $path file path
  * @return string markdown formated string
  */
 public function getPageContent($path)
 {
     $extra = new \ParsedownExtra();
     $content = null;
     if (Storage::exists($path) === true) {
         $content = $extra->text(Storage::get($path));
     }
     return $content;
 }
开发者ID:mrjuliuss,项目名称:lecter,代码行数:14,代码来源:Lecter.php

示例11: printPostRSS

function printPostRSS($post)
{
    $parseDown = new ParsedownExtra();
    echo "    <item>\n";
    echo "      <title>" . $post['title'] . "</title>\n";
    echo "      <link>http://fisherevans.com/blog/post/" . $post['title_slug'] . "</link>\n";
    echo "      <guid>http://fisherevans.com/blog/post/" . $post['title_slug'] . "</guid>\n";
    echo "      <pubDate>" . date("D, d M Y H:i:s O", strtotime($post['posted_date'])) . "</pubDate>\n";
    echo "      <content:encoded><![CDATA[" . fixRelativeLinks($parseDown->text($post['content'])) . "]]></content:encoded>\n";
    echo "    </item>\n";
}
开发者ID:amdad,项目名称:FisherEvans.com,代码行数:11,代码来源:rss.php

示例12: markdown

/**
 * Markdown
 *
 * Parse Markdown to HTML
 *
 * @since 2.0.0
 *
 * @param $content (string) Markdown string or file to parse
 */
function markdown($content)
{
    // Check for file
    if (is_readable($content)) {
        $content = file_get_contents($content);
    }
    // Parse Markdown
    $markdown = new ParsedownExtra();
    $result = $markdown->text($content);
    return $result;
}
开发者ID:resknow,项目名称:boilerplate,代码行数:20,代码来源:markdown.php

示例13: index

 /**
  * Index Page for this controller.
  *
  * Maps to the following URL
  *         http://example.com/index.php/welcome
  *    - or -
  *         http://example.com/index.php/welcome/index
  *    - or -
  * Since this controller is set as the default controller in
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see http://codeigniter.com/user_guide/general/urls.html
  */
 public function index()
 {
     $this->load->helper('url');
     $data = array();
     $data['readme'] = null;
     $readme = @file_get_contents(FCPATH . 'README.md');
     if ($readme != '') {
         $parser = new ParsedownExtra();
         $data['readme'] = @$parser->text($readme);
     }
     $this->load->view('welcome_message', $data);
 }
开发者ID:aliraza5pk,项目名称:codeigniter-restserver-test,代码行数:27,代码来源:Welcome.php

示例14: init

 function init()
 {
     parent::init();
     $this->addField('name');
     $this->addField('title');
     $this->addField('data')->caption('Markdown Template');
     $this->addField('rendered')->caption('HTML render cache');
     $this->addHook('afterLoad', function ($m) {
         if (is_null($m['rendered'])) {
             $markdown = $m['data'];
             if (!$m->hook('prepareTemplate', array(&$markdown))) {
                 $markdown = $this->prepareTemplate($markdown);
             }
             $m['rendered'] = \ParsedownExtra::instance()->parse($markdown);
             // $this->prepareTemplate());
         }
         if (is_null($m['title'])) {
             $x = null;
             preg_match('/^# (.*)$/m', $m['data'], $x);
             $m['title'] = $x[1];
             //v
             //$m['rendered'] = \ParsedownExtra::instance()->parse($markdown);
             // $this->prepareTemplate());
         }
     });
 }
开发者ID:romaninsh,项目名称:mdcms,代码行数:26,代码来源:Model.php

示例15: parse

 /**
  * Parse a given path to the documentation for a file. Performs a case 
  * insensitive lookup on the file system. Automatically appends the file 
  * extension to one of the markdown extensions as well so /install/ in a
  * web browser will match /install.md or /INSTALL.md.
  * 
  * Filepath: /var/www/myproject/src/cms/en/folder/subfolder/page.md
  * URL: http://myhost/mywebroot/dev/docs/2.4/cms/en/folder/subfolder/page
  * Webroot: http://myhost/mywebroot/
  * Baselink: dev/docs/2.4/cms/en/
  * Pathparts: folder/subfolder/page
  * 
  * @param DocumentationPage $page
  * @param String $baselink Link relative to webroot, up until the "root" 
  *							of the module. Necessary to rewrite relative 
  *							links
  *
  * @return String
  */
 public static function parse(DocumentationPage $page, $baselink = null)
 {
     if (!$page || !$page instanceof DocumentationPage) {
         return false;
     }
     $md = $page->getMarkdown(true);
     // Pre-processing
     $md = self::rewrite_image_links($md, $page);
     $md = self::rewrite_relative_links($md, $page, $baselink);
     $md = self::rewrite_api_links($md, $page);
     $md = self::rewrite_heading_anchors($md, $page);
     $md = self::rewrite_code_blocks($md);
     $parser = new ParsedownExtra();
     $parser->setBreaksEnabled(false);
     $text = $parser->text($md);
     return $text;
 }
开发者ID:Jellygnite,项目名称:silverstripe-docsviewer,代码行数:36,代码来源:DocumentationParser.php


注:本文中的ParsedownExtra类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。