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

PHP Markdown类代码示例

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

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



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

示例1: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $topics = Topic::all();
     $markdown = new Markdown();
     $transfer_count = 0;
     $convert_count = 0;
     foreach ($topics as $topic) {
         if (empty($topic->body_original)) {
             // store the original data
             $topic->body_original = $topic->body;
             // convert to markdown
             $topic->body = $markdown->convertMarkdownToHtml($topic->body);
             $topic->save();
             $transfer_count++;
         } else {
             // convert to markdown
             $topic->body = $markdown->convertMarkdownToHtml($topic->body_original);
             $topic->save();
             $convert_count++;
         }
     }
     $this->info("Transfer old data count: " . $transfer_count);
     $this->info("Convert original to body count: " . $convert_count);
     $this->info("It's Done, have a good day.");
 }
开发者ID:adminrt,项目名称:phphub,代码行数:30,代码来源:TopicMarkdownConvertionCommand.php


示例2: testDecoding

 public function testDecoding()
 {
     $formatter = new Markdown();
     $data = array('name' => 'Joe', 'age' => 21, 'employed' => true, 'body' => "Lorem ipsum dolor\nsit amet");
     $raw = file_get_contents(__DIR__ . '/fixtures/joe.md');
     $this->assertEquals($data, $formatter->decode($raw));
 }
开发者ID:gekt,项目名称:www,代码行数:7,代码来源:MarkdownTest.php


示例3: agregarProducto

 /**
  * Añade el producto a la base de datos con el nombre, medida, descripcion, rutaimagen, categoria y familia.
  *
  * @param $nombreprod string.
  * @param $precioprod string.
  * @param $medidas string.
  * @param $descripcionprod string.
  * @param $rutaimagen string.
  * @param $idcategoria int.
  * @param $idfamilia int.
  * @return boolean.
  */
 public function agregarProducto($nombreprod, $precioprod, $medidas, $descripcionprod, $rutaimagen, $idcategoria, $idfamilia)
 {
     $Markdown = new Markdown();
     $my_html = $Markdown->transform($descripcionprod);
     $query = "INSERT INTO producto(nombreprod, precioprod, medidas, descripcionprod, rutaimagen, categoria_idcategoria, categoria_familia_idfamilia)" . "VALUES('{$nombreprod}', '{$precioprod}', '{$medidas}','{$my_html}', '{$rutaimagen}', '{$idcategoria}', '{$idfamilia}');";
     $this->logger->getLogger($query);
     $result = $this->connection->query($query);
     return $result;
 }
开发者ID:Jupaba,项目名称:ccientifica,代码行数:21,代码来源:ProductosDAO.class.php


示例4: testTablesHaveTableClass

    public function testTablesHaveTableClass()
    {
        $parser = new Markdown();
        $content = <<<'MARKDOWN'
|Tables|Is|
|------|--|
|OK    |? |
MARKDOWN;
        $result = $parser->text($content);
        $this->assertEquals("<table class=\"table\">\n<thead>\n<tr>\n<th>Tables</th>\n<th>Is</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>OK</td>\n<td>?</td>\n</tr>\n</tbody>\n</table>", $result);
    }
开发者ID:jvelo,项目名称:datatext,代码行数:11,代码来源:MarkdownTest.php


示例5: markdown

function markdown($string)
{
    #
    # Initialize the parser and return the result of its transform method.
    #
    # Setup static parser variable.
    static $parser;
    if (!isset($parser)) {
        $parser = new Markdown();
    }
    # Transform text using parser.
    return $parser->transform($string);
}
开发者ID:ToddBudde,项目名称:phrails,代码行数:13,代码来源:text.php


示例6: update

 public function update($id)
 {
     $topic = Topic::findOrFail($id);
     $data = Input::only('title', 'body', 'node_id');
     $this->authorOrAdminPermissioinRequire($topic->user_id);
     $markdown = new Markdown();
     $data['body_original'] = $data['body'];
     $data['body'] = $markdown->convertMarkdownToHtml($data['body']);
     $data['excerpt'] = Topic::makeExcerpt($data['body']);
     // Validation
     App::make('Phphub\\Forms\\TopicCreationForm')->validate($data);
     $topic->update($data);
     Flash::success(lang('Operation succeeded.'));
     return Redirect::route('topics.show', $topic->id);
 }
开发者ID:azonwan,项目名称:pingju,代码行数:15,代码来源:TopicsController.php


示例7: _cache_content

 /**
  * Encodes the content into HTML based on Markdown
  *
  * @return  void
  */
 protected function _cache_content()
 {
     $this->cached_content = Markdown::encode($this->content);
     if (preg_match_all('/<p>(.*)<\\/p>/', $this->cached_content, $matches)) {
         $this->description = substr(strip_tags($matches[1][0]), 0, 500);
     }
 }
开发者ID:samsoir,项目名称:def.reyssi.net-legacy,代码行数:12,代码来源:article.php


示例8: getMarkdownParagraph

 /**
  * Returns a function converting Markdown into HTML but only parsing inline elements.
  * @return \Closure A function converting Markdown into HTML but only parsing inline elements.
  */
 public function getMarkdownParagraph() : \Closure
 {
     return function ($value, \Mustache_LambdaHelper $helper) {
         $args = $this->parseArguments($helper->render($value), 'markdown', ['flavor' => Markdown::$defaultFlavor]);
         return Markdown::processParagraph($args['markdown'], $args['flavor']);
     };
 }
开发者ID:cedx,项目名称:yii2-mustache,代码行数:11,代码来源:HTML.php


示例9: previewNoEnclosingPage

 /**
  * compile markdown to html and render as text
  *
  * @return Illuminate\View\View
  */
 public function previewNoEnclosingPage()
 {
     $markdown = Markdown::defaultTransform(e(Input::get('data')));
     $response = Response::make($markdown);
     $response->header('Content-Type', 'text/html');
     return $response;
 }
开发者ID:hrenos,项目名称:spreadit,代码行数:12,代码来源:UtilityController.php


示例10: setRenderer

 /**
  * Sets the renderer for markdown fields to use
  * @param {string} $renderer Class Name of an implementation of IMarkdownRenderer
  */
 public static function setRenderer($renderer)
 {
     if (ClassInfo::classImplements($renderer, 'IMarkdownRenderer')) {
         self::$renderer = $renderer;
     } else {
         user_error('The renderer ' . $renderer . ' does not implement IMarkdownRenderer', E_USER_ERROR);
     }
 }
开发者ID:undefinedoffset,项目名称:silverstripe-markdown,代码行数:12,代码来源:Markdown.php


示例11: get_how_to_use_content

 private function get_how_to_use_content($f3)
 {
     $content = "How to use content.";
     $file = F3::instance()->read('help/README.md');
     $html = Markdown::instance()->convert($file);
     $f3->set('how_to_use_content', $html);
     return $content;
 }
开发者ID:rivalinx,项目名称:php-file-host,代码行数:8,代码来源:Upload_form.php


示例12: get

 /**
  * Get the given documentation page.
  *
  * @param  string $manual
  * @param  string $version
  * @param  string $page
  * @return string
  */
 public function get($manual, $version, $page)
 {
     $pageFile = $this->storagePath . '/' . $manual . '/' . $version . '/' . $page . '.md';
     if ($this->files->exists($pageFile)) {
         return $this->cached("{$manual}.{$version}.{$pageFile}", Markdown::parse($this->files->get($pageFile), $manual . '/' . $version . '/' . dirname($page)));
     } else {
         App::abort(404);
     }
 }
开发者ID:nothing-fr,项目名称:legacy-codex,代码行数:17,代码来源:CodexRepositoryFlat.php


示例13: updateExportSettings

 private function updateExportSettings()
 {
     $input = Input::only($this->export_features);
     $input['ex_disclaimer_html'] = Markdown::string($input['ex_disclaimer']);
     foreach ($input as $key => $value) {
         Setting::set($key, $value);
     }
     return true;
 }
开发者ID:l0ngestever,项目名称:logboek,代码行数:9,代码来源:SettingsController.php


示例14: generatePost

 /**
  * Generate a preview
  *
  * @param array $input
  * @param       $user
  * @return \Illuminate\View\View
  */
 public function generatePost($input, $user)
 {
     // Generate preview post
     $post = $this->postRepo->getEmptyPost();
     $post->author = $user;
     $post->markdown = $input['content'];
     $post->html = \Purifier::clean(\Markdown::text($input['content']));
     return $post;
 }
开发者ID:kaamaru,项目名称:laravel-forums,代码行数:16,代码来源:Preview.php


示例15: testFacadeRoot

 public function testFacadeRoot()
 {
     $class = get_class(Markdown::getFacadeRoot());
     if ('sundown' == Conf::get('markdown')) {
         $this->assertEquals('Pochika\\Markdown\\Sundown', $class);
     } else {
         $this->assertEquals('Pochika\\Markdown\\PHPMarkdownExtra', $class);
     }
 }
开发者ID:a11enwong,项目名称:pochika,代码行数:9,代码来源:MarkdownTest.php


示例16: convert

 /**
  * convert 
  * 
  * @param string $text 
  * @return string
  */
 public static function convert($text)
 {
     if (empty(self::$parser)) {
         self::$parser = new HyperDown();
         self::$parser->hook('afterParseCode', array('Markdown', 'transerCodeClass'));
         self::$parser->hook('beforeParseInline', array('Markdown', 'transerComment'));
     }
     return self::$parser->makeHtml($text);
 }
开发者ID:ldsink,项目名称:typecho,代码行数:15,代码来源:Markdown.php


示例17: parse

function parse($str, $markdown = true)
{
    // process tags
    $pattern = '/[\\{\\{]{1}([a-z]+)[\\}\\}]{1}/i';
    if (preg_match_all($pattern, $str, $matches)) {
        list($search, $replace) = $matches;
        foreach ($replace as $index => $key) {
            $replace[$index] = Config::meta($key);
        }
        $str = str_replace($search, $replace, $str);
    }
    $str = html_entity_decode($str, ENT_NOQUOTES, System\Config::app('encoding'));
    //  Parse Markdown as well?
    if ($markdown === true) {
        $md = new Markdown();
        $str = $md->transform($str);
    }
    return $str;
}
开发者ID:gautamkrishnar,项目名称:Anchor-CMS-openshift-quickstart,代码行数:19,代码来源:helpers.php


示例18: preview

 public function preview()
 {
     $md = $this->request->get('md');
     if (!empty($md)) {
         $html = Markdown::convert($md);
         echo $html;
     }
     echo '';
     exit;
 }
开发者ID:Jsechoo,项目名称:sisome,代码行数:10,代码来源:Publish.php


示例19: create

 /**
  * Create post
  *
  * @param array $input
  * @param                $topic
  * @param                $user
  * @param bool $add
  * @return \Illuminate\Http\RedirectResponse|object
  */
 public function create($input, $topic, $user, $add = true)
 {
     // Create post
     $data = ['markdown' => $input['content'], 'html' => \Purifier::clean(\Markdown::text($input['content'])), 'topic_id' => $topic->id, 'user_id' => $user->id];
     if (\Bouncer::hasPermission('devresponse') and \Input::get('devresponse') == 1) {
         $data['developer_response'] = true;
     }
     $post = $this->postRepo->create($data);
     return $post;
 }
开发者ID:kaamaru,项目名称:laravel-forums,代码行数:19,代码来源:PostCreator.php


示例20: getReadme

 public static function getReadme($owner, $repo)
 {
     $token = self::getAccessToken();
     $readmeUrl = 'https://api.github.com/repos/' . $owner . '/' . $repo . '/readme?access_token=' . $token;
     $client = self::getClient();
     $res = $client->get($readmeUrl, []);
     $readmeHash = json_decode($res->getBody(), true);
     $readme = ['readme' => \Markdown::convertToHtml(imap_base64($readmeHash['content']))];
     return $readme;
 }
开发者ID:briscula,项目名称:astral,代码行数:10,代码来源:GithubClient.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Markdown_Parser类代码示例发布时间:2022-05-23
下一篇:
PHP Mapper类代码示例发布时间: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