• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Michelf\MarkdownExtra类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: compile

 /**
  * compile
  *
  * @param \Twig_Compiler $compiler
  *
  * @return  void
  */
 public function compile(\Twig_Compiler $compiler)
 {
     $data = $this->getNode('value')->getAttribute('data');
     $markdown = new MarkdownExtra();
     $data = $markdown->defaultTransform($data);
     $compiler->write('echo ')->string($data)->raw(';');
 }
开发者ID:bgao-ca,项目名称:vaseman,代码行数:14,代码来源:MarkdownNode.php


示例2: develop_public

    /** markdown格式接口 */
    public function develop_public()
    {
        $gData = checkData($_GET);
        $int_opt = $gData['int_opt'];
        if (!$int_opt) {
            ajaxReturn('非法操作[缺少必须参数]', 300);
        }
        //样式
        echo '<style>
            .markdown-here-wrapper h1{ font-size: 20px; font-weight:bold; margin-top: 10px;}
            .markdown-here-wrapper h2{ font-size: 18px; font-weight:bold; margin-top: 10px;}
            .markdown-here-wrapper h3{ font-size: 16px; font-weight:bold; margin-top: 10px;}
            .markdown-here-wrapper table{ border-collapse: collapse; border: 1px solid yellowgreen;}
            .markdown-here-wrapper th { vertical-align: baseline; border: 1px solid yellowgreen; font-weight:bold; font-size: 18px;}
            .markdown-here-wrapper td { vertical-align: middle; border: 1px solid yellowgreen; font-size: 18px;}
            .markdown-here-wrapper tr { border: 1px solid yellowgreen;}

            .markdown-here-wrapper p a{font-size: 16px;}
            </style>';
        $output = $text = file_get_contents(MODULE_PATH . 'develop_info/' . $int_opt . '.md');
        $parser = new MarkdownExtra();
        $my_html = $parser->transform($output);
        $this->s->assign('my_html', $my_html);
        $this->s->display('interface_admin/interface_list.html');
    }
开发者ID:bibyzhang,项目名称:produce_cms,代码行数:26,代码来源:develop_doc.php


示例3: prepareData

 /**
  * prepareData
  *
  * @param \Windwalker\Data\Data $data
  *
  * @return  void
  */
 protected function prepareData($data)
 {
     $markdown = new MarkdownExtra();
     foreach ($data['posts'] as $post) {
         $post->link = Router::buildHtml('front:post_default', ['id' => $post->id, 'alias' => $post->alias]);
         $post->introtext = $markdown->defaultTransform($post->introtext);
         $post->author = Author::getPostAuthor($post->author);
         $post->created = new Date($post->created);
         $post->created = $post->created->format('F j, Y');
     }
     foreach ($data['statics'] as $post) {
         $post->link = Router::buildHtml('front:static_default', ['id' => $post->id, 'alias' => $post->alias]);
     }
     // Title
     if ($data->type == 'home') {
         $title = $data->blog->title;
         $suffix = '';
         $data->bodyClass = 'home posts page-' . $data->page;
     } else {
         $title = '';
         $suffix = $data->blog->title;
         $data->bodyClass = 'home posts page-' . $data->page;
     }
     $data->pageTitle = $title;
     $data->pageTitle .= $data->page > 1 ? ' - Page ' . $data->page : '';
     $data->pageTitle .= $suffix ? '|' . $suffix : '';
     // Meta
     $desc = $data->blog->description;
     $desc = OutputFilter::cleanText($desc);
     $desc = Utf8String::substr($desc, 0, 200);
     $data->meta->desc = $desc;
 }
开发者ID:Trult,项目名称:windspeaker-demo,代码行数:39,代码来源:PostsHtmlView.php


示例4: render

 /**
  * render
  *
  * @return  string
  */
 public function render()
 {
     $md = file_get_contents($this->file->getPathname());
     $md = $this->prepareData($md);
     $markdown = new MarkdownExtra();
     $content = $markdown->defaultTransform($md);
     return $this->output = $this->renderLayout($content);
 }
开发者ID:bgao-ca,项目名称:vaseman,代码行数:13,代码来源:MarkdownProcessor.php


示例5: parse

 public function parse($text)
 {
     $markdown = new MarkdownExtra();
     $text = $this->doShortcodes($text);
     $text = $markdown->transform($text);
     $text = $this->extendTags($text);
     return $text;
 }
开发者ID:Absolute-Software,项目名称:laravel-apidocu,代码行数:8,代码来源:Parser.php


示例6: parse

 /**
  * overload parse with the MarkdownExtra parser
  *
  * @param $data
  *
  * @return string
  */
 public function parse($data)
 {
     $parser = new MarkdownExtra();
     foreach ($this->config as $key => $value) {
         $parser->{$key} = $value;
     }
     return $parser->transform($data);
 }
开发者ID:patrova,项目名称:Phile,代码行数:15,代码来源:Markdown.php


示例7: prepareData

 /**
  * prepareData
  *
  * @param \Windwalker\Data\Data $data
  *
  * @return  void
  */
 protected function prepareData($data)
 {
     $markdown = new MarkdownExtra();
     foreach ($data['posts'] as $post) {
         $post->link = Router::buildHtml('front:post_default', ['id' => $post->id, 'alias' => $post->alias]);
         $post->introtext = $markdown->defaultTransform($post->introtext);
         $post->author = Author::getPostAuthor($post->author);
     }
 }
开发者ID:Trult,项目名称:windspeaker-demo,代码行数:16,代码来源:PostsFeedView.php


示例8: process

 /**
  * Converts markdown into HTML
  *
  * @param string $content
  * @param array $config
  * @return string
  */
 public static function process($content, $config = [])
 {
     if (static::$markdown === null) {
         static::$markdown = new MarkdownExtra();
     }
     foreach ($config as $name => $value) {
         static::$markdown->{$name} = $value;
     }
     return static::$markdown->transform($content);
 }
开发者ID:kangqf,项目名称:yii2-markdown,代码行数:17,代码来源:Markdown.php


示例9: toHTML

 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;
 }
开发者ID:sloan58,项目名称:karma-tek,代码行数:10,代码来源:Markdowner.php


示例10: parseMarkdown

 static function parseMarkdown($text)
 {
     //GitHub Code Parse
     $text = str_replace('```', '~~~', $text);
     $parser = new Michelf\MarkdownExtra();
     $parser->fn_id_prefix = "post22-";
     $parser->code_attr_on_pre = false;
     $parser->tab_width = 4;
     return $parser->transform($text);
 }
开发者ID:sunnycamel,项目名称:swoole.com,代码行数:10,代码来源:Api.php


示例11: test_custom_code

 public function test_custom_code()
 {
     $markdown = new MarkdownExtra();
     $markdown->custom_code_parser = function ($class, $code) {
         return '<' . $class . '>' . $code . '</' . $class . '>';
     };
     $tests = [["```..svg\n123123123\n```", "<svg>123123123\n</svg>\n"], ["#111\n```..svg\n123123123\n```", "<h1>111</h1>\n\n<svg>123123123\n</svg>\n"]];
     foreach ($tests as $v) {
         $ret = $markdown->transform($v[0]);
         $this->assertEquals($v[1], $ret);
     }
 }
开发者ID:snje1987,项目名称:markdown,代码行数:12,代码来源:Codeblock.php


示例12: test_TodoList

 public function test_TodoList()
 {
     $markdown = new MarkdownExtra();
     $markdown->custom_code_parser = function ($class, $code) {
         return '<' . $class . '>' . $code . '</' . $class . '>';
     };
     $tests = [["## aaa\n[] 1111", "<h2>aaa</h2>\n\n<p class=\"todo\"><input type=\"checkbox\" disabled=\"disabled\" />1111</p>"], ["[*] 2222", '<p class="todo"><input type="checkbox" disabled="disabled" checked="checked" />2222</p>'], ['[+]3333', '<p class="todo"><input type="checkbox" disabled="disabled" checked="checked" />3333</p>'], ['[ ]4444[111](https://www.baidu.com)', '<p class="todo"><input type="checkbox" disabled="disabled" />4444<a href="https://www.baidu.com">111</a></p>'], ['[-]55`abc`55', '<p class="todo"><input type="checkbox" disabled="disabled" />55<code>abc</code>55</p>'], ["## aaa\n() 1111", "<h2>aaa</h2>\n\n<p class=\"todo\"><input type=\"radio\" disabled=\"disabled\" />1111</p>"], ["(*) 2222", '<p class="todo"><input type="radio" disabled="disabled" checked="checked" />2222</p>'], ['(+)3333', '<p class="todo"><input type="radio" disabled="disabled" checked="checked" />3333</p>'], ['( )4444[111](https://www.baidu.com)', '<p class="todo"><input type="radio" disabled="disabled" />4444<a href="https://www.baidu.com">111</a></p>'], ['(-)55`abc`55', '<p class="todo"><input type="radio" disabled="disabled" />55<code>abc</code>55</p>']];
     foreach ($tests as $v) {
         $ret = $markdown->transform($v[0]);
         $this->assertEquals($v[1] . "\n", $ret);
     }
 }
开发者ID:snje1987,项目名称:markdown,代码行数:12,代码来源:TodoList.php


示例13: transform

 public function transform($text)
 {
     $parser = new MarkdownExtra();
     $stylesAdded = false;
     if (class_exists('Kadet\\Highlighter\\Language\\Language')) {
         $parser->code_block_content_func = function ($code, $language) use(&$stylesAdded) {
             if (!$stylesAdded) {
                 $this->pageStack->getPageResponse()->addCssFile('@Jarves/keylighter/default.scss');
                 $stylesAdded = true;
             }
             return Highlighter\highlight($code, Language::byName($language));
         };
     }
     return $parser->transform($text);
 }
开发者ID:jarves,项目名称:jarves,代码行数:15,代码来源:Markdowner.php


示例14: __invoke

 /**
  * A very simple markdown parser.
  *
  * @since 150424 Initial release.
  *
  * @param mixed $value Any input value.
  * @param array $args  Any additional behavioral args.
  *
  * @return string|array|object Html markup value(s).
  */
 public function __invoke($value, array $args = [])
 {
     if (is_array($value) || is_object($value)) {
         foreach ($value as $_key => &$_value) {
             $_value = $this->__invoke($_value, $args);
         }
         //unset($_key, $_value);
         return $value;
     }
     if (!($string = (string) $value)) {
         return $string;
         // Nothing to do.
     }
     $default_args = ['flavor' => 'markdown-extra', 'breaks' => true, 'anchorize' => false, 'anchor_rels' => [], 'no_p' => false];
     $args = array_merge($default_args, $args);
     $args = array_intersect_key($args, $default_args);
     $flavor = (string) $args['flavor'];
     $breaks = (bool) $args['breaks'];
     $no_p = (bool) $args['no_p'];
     $anchorize = (bool) $args['anchorize'];
     $anchor_rels = (array) $args['anchor_rels'];
     if ($flavor === 'parsedown-extra') {
         if (is_null($ParsedownExtra =& $this->cacheKey(__FUNCTION__, $flavor))) {
             $ParsedownExtra = new ParsedownExtra();
         }
         $ParsedownExtra->setBreaksEnabled($breaks);
         $string = $ParsedownExtra->text($string);
     } else {
         $flavor = 'markdown-extra';
         // Default flavor.
         if (is_null($MarkdownExtra =& $this->cacheKey(__FUNCTION__, $flavor))) {
             $MarkdownExtra = new MarkdownExtra();
             $MarkdownExtra->code_class_prefix = 'language-';
         }
         $string = $MarkdownExtra->transform($string);
     }
     if ($anchorize) {
         $string = $this->c::htmlAnchorize($string);
     }
     if ($anchor_rels) {
         $string = $this->c::htmlAnchorRels($string, $anchor_rels);
     }
     if ($no_p) {
         // Strip ` ^<p>|</p>$ ` tags?
         $string = preg_replace('/^\\s*(?:\\<p(?:\\s[^>]*)?\\>)+|(?:\\<\\/p\\>)+\\s*$/ui', '', $string);
     }
     return $string;
 }
开发者ID:websharks,项目名称:core,代码行数:58,代码来源:Markdown.php


示例15: generateHtml

 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;
 }
开发者ID:KartikPadmanabhan,项目名称:markdown-resume,代码行数:30,代码来源:HtmlCommand.php


示例16: render

 public function render($content)
 {
     $html = $this->getLayoutHead();
     $html .= MarkdownExtra::defaultTransform($content);
     $html .= $this->getLayoutFooter();
     return $html;
 }
开发者ID:mimiz,项目名称:silex-documentation-provider,代码行数:7,代码来源:Markdown.php


示例17: markdown

 public function markdown($value = '')
 {
     $text = $value;
     $html = MarkdownExtra::defaultTransform($text);
     $html = preg_replace('/<img src="images\\/([^\\"]*)"/i', '<img src="/posts/images/$1"', $html);
     return $html;
 }
开发者ID:hotli,项目名称:JustWriting,代码行数:7,代码来源:blog_lib.php


示例18: 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 MichelfMarkdown converter.');
     }
     return MarkdownExtra::defaultTransform($input);
 }
开发者ID:jjk-jacky,项目名称:Spress,代码行数:14,代码来源:MichelfMarkdownConverter.php


示例19: convert

 /**
  * Convert the input data
  * 
  * @param string $input The raw content without Front-matter
  * 
  * @return string
  */
 public function convert($input)
 {
     if (!is_string($input)) {
         throw new \InvalidArgumentException('Expected Markdown string to parse');
     }
     return MarkdownExtra::defaultTransform($input);
 }
开发者ID:pancao,项目名称:Spress,代码行数:14,代码来源:Markdown.php


示例20: parseMarkup

 /**
  * Runs the given string through the "markup" parser (MarkdownExtra).
  *
  * @param string $source
  *
  * @return string
  */
 public function parseMarkup($source)
 {
     $source = $this->callHook('modifySmartDownMarkupInput', $source);
     $source = MarkdownExtra::defaultTransform($source);
     $source = $this->callHook('modifySmartDownMarkupOutput', $source);
     return $source;
 }
开发者ID:kamicrafted,项目名称:designhub,代码行数:14,代码来源:Parser.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ckeditor\CKEditor类代码示例发布时间:2022-05-23
下一篇:
PHP Michelf\Markdown类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap