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


PHP Markdown::process方法代码示例

本文整理汇总了PHP中yii\helpers\Markdown::process方法的典型用法代码示例。如果您正苦于以下问题:PHP Markdown::process方法的具体用法?PHP Markdown::process怎么用?PHP Markdown::process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\helpers\Markdown的用法示例。


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

示例1: actionRss

 public function actionRss()
 {
     /** @var News[] $news */
     $news = News::find()->where(['status' => News::STATUS_PUBLIC])->orderBy('id DESC')->limit(50)->all();
     $feed = new Feed();
     $feed->title = 'YiiFeed';
     $feed->link = Url::to('');
     $feed->selfLink = Url::to(['news/rss'], true);
     $feed->description = 'Yii news';
     $feed->language = 'en';
     $feed->setWebMaster('sam@rmcreative.ru', 'Alexander Makarov');
     $feed->setManagingEditor('sam@rmcreative.ru', 'Alexander Makarov');
     foreach ($news as $post) {
         $item = new Item();
         $item->title = $post->title;
         $item->link = Url::to(['news/view', 'id' => $post->id], true);
         $item->guid = Url::to(['news/view', 'id' => $post->id], true);
         $item->description = HtmlPurifier::process(Markdown::process($post->text));
         if (!empty($post->link)) {
             $item->description .= Html::a(Html::encode($post->link), $post->link);
         }
         $item->pubDate = $post->created_at;
         $item->setAuthor('noreply@yiifeed.com', 'YiiFeed');
         $feed->addItem($item);
     }
     $feed->render();
 }
开发者ID:Rudianasaja,项目名称:yiifeed,代码行数:27,代码来源:NewsController.php

示例2: actionTest

 public function actionTest()
 {
     echo \yii\helpers\Markdown::process('**strong text***emphasized text*');
     exit;
     //        echo Yii::getAlias('@yii/storage');
     return $this->render('test');
 }
开发者ID:igaojie,项目名称:yii-QA,代码行数:7,代码来源:SiteController.php

示例3: actionBlog

 public function actionBlog()
 {
     $id = Yii::$app->request->get('id');
     $data = TblBlog::find()->joinwith('category')->where([TblBlog::tableName() . '.id' => $id])->asArray()->one();
     $data['text'] = Markdown::process($data['text'], 'gfm');
     return $this->render('article', ['data' => $data]);
 }
开发者ID:chrisye909,项目名称:homesite,代码行数:7,代码来源:HomeController.php

示例4: prepareForSave

 public static function prepareForSave($model)
 {
     list($model->PostText, $imgs, $urls) = self::parseText($model->PostText);
     $model->PostTextParsed = Markdown::process($model->PostText);
     $model->PostHeader = self::createHeader(strip_tags($model->PostText));
     return [$model, $imgs, $urls];
 }
开发者ID:vladimirgolovanov,项目名称:purrfect-awesome-friends-feed-decorator,代码行数:7,代码来源:Wishlist.php

示例5: parseData

 protected function parseData($path)
 {
     preg_match('~guide-?(.*)/(.+)\\.md$~', $path, $matches);
     $language = $matches[1] ? $matches[1] : Yii::$app->sourceLanguage;
     $language = Locale::getPrimaryLanguage($language);
     $slug = strtolower($matches[2]);
     $doc = file_get_contents($path);
     $doc = Markdown::process($doc, 'gfm');
     $html = new HTMLDocument();
     @$html->loadHTML($doc);
     $html->addPrefix("/{lang}/", 'a', 'href');
     $imgPath = dirname($path) . '/images';
     $imgPath = $this->publishImages($imgPath);
     if ($imgPath) {
         $html->addPrefix(function ($src) use($imgPath) {
             return $imgPath . '/' . basename($src);
         }, 'img', 'src');
     }
     foreach (['h1', 'h2', 'h3', 'h4'] as $tag) {
         /** @var \DOMElement $item */
         foreach ($html->getElementsByTagName($tag) as $item) {
             /** @var \DOMElement $span */
             if ($span = $item->getElementsByTagName('span')[0]) {
                 $item->setAttribute('id', $span->getAttribute('id'));
             }
         }
     }
     /** @var DOMElement $title */
     $title = $html->getElementsByTagName('h1')[0];
     return ['language' => $language, 'slug' => $slug, 'title' => $title->textContent, 'description' => $html->saveHTML()];
 }
开发者ID:lav45,项目名称:yii2-translated-behavior-demo,代码行数:31,代码来源:m160418_201842_page_data.php

示例6: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'alias'], 'value' => function ($event) {
         return Inflector::slug($event->sender->title);
     }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_AFTER_FIND => 'body'], 'value' => function ($event) {
         return HtmlPurifier::process(Markdown::process($event->sender->content, 'gfm'));
     }]];
 }
开发者ID:faninv,项目名称:gtqa,代码行数:11,代码来源:Question.php

示例7: beforeSave

 public function beforeSave($insert)
 {
     parent::beforeSave($insert);
     $this->historyTemp = new History();
     $this->historyTemp->attributes = ['title' => $this->title, 'content' => $this->content, 'user_id' => 1];
     $this->content = Markdown::process($this->content, 'gfm');
     if (!$this->isNewRecord) {
         $this->historyTemp->renderDiff($this->lastEdit);
     }
     return true;
 }
开发者ID:zabachok,项目名称:yii2-burivuh,代码行数:11,代码来源:DocumentEdit.php

示例8: up

 public function up()
 {
     $works = Work::find()->all();
     foreach ($works as $work) {
         if ($work->description && strpos('<p>', $work->description) === false) {
             echo "Convert  {$work->id} 's description...\n";
             $work->description = Markdown::process($work->description, 'gfm');
             $work->save(false);
         }
     }
     echo "DOne\n";
 }
开发者ID:dawei101,项目名称:plants,代码行数:12,代码来源:m151211_061522_update_description_of_markdown.php

示例9: process

 /**
  * Converts markdown into HTML
  *
  * @param string $content
  * @param TypeDoc $context
  * @param boolean $paragraph
  * @return string
  */
 public static function process($content, $context = null, $paragraph = false)
 {
     if (!isset(Markdown::$flavors['api-latex'])) {
         Markdown::$flavors['api-latex'] = new static();
     }
     if (is_string($context)) {
         $context = static::$renderer->apiContext->getType($context);
     }
     Markdown::$flavors['api-latex']->renderingContext = $context;
     if ($paragraph) {
         return Markdown::processParagraph($content, 'api-latex');
     } else {
         return Markdown::process($content, 'api-latex');
     }
 }
开发者ID:trntv,项目名称:yii2,代码行数:23,代码来源:ApiMarkdownLaTeX.php

示例10: render

 /**
  * @inheritdoc
  * @throws \InvalidArgumentException when params are not empty
  */
 public function render($view, $file, $params)
 {
     if (!empty($params)) {
         throw new \InvalidArgumentException('MdViewRenderer does not support params.');
     }
     if ($this->cache) {
         $key = self::CACHE_PREFIX . $file;
         $result = $this->cache->get($key);
         if ($result === false) {
             $result = Markdown::process(file_get_contents($file), $this->flavor);
             $this->cache->set($key, $result, 0, new FileDependency(['fileName' => $file]));
         }
     } else {
         $result = Markdown::process(file_get_contents($file), $this->flavor);
     }
     return $result;
 }
开发者ID:netis-pl,项目名称:yii2-crud,代码行数:21,代码来源:MdViewRenderer.php

示例11: createHtml

 /**
  * Helper function for the docs action
  * @return string
  */
 private function createHtml($file, $useRootPath = false)
 {
     \Yii::trace("Creating HTML for '{$file}'", __METHOD__);
     try {
         $filePath = \Yii::getAlias($this->module->markdownUrl) . '/' . $file;
         $markdown = file_get_contents($filePath);
         \Yii::trace("Loaded markdown for '{$filePath}'", __METHOD__);
     } catch (\Exception $e) {
         \Yii::$app->session->addFlash("error", "File '{$file}' not found,");
         return false;
     }
     $_slash = $useRootPath ? '' : '/';
     $html = Markdown::process($markdown, 'gfm');
     $html = preg_replace('|<a href="(?!http)' . $_slash . '(.+\\.md)">|U', '<a href="__INTERNAL_URL__$1">', $html);
     $dummyUrl = Url::to(['/' . $this->module->id . '/default/index', 'file' => '__PLACEHOLDER__']);
     $html = strtr($html, ['__INTERNAL_URL__' => $dummyUrl]);
     $html = strtr($html, ['__PLACEHOLDER__' => '']);
     return $html;
 }
开发者ID:schmunk42,项目名称:yii2-markdocs-module,代码行数:23,代码来源:DefaultController.php

示例12:

		<a href="index.php?r=post/searchby&text=">
		<?php 
        echo $t_el['name'];
        ?>
</a>,
		<?php 
    }
    ?>
	</div>




	<div class="post-body2">
		<?php 
    echo \yii\helpers\HtmlPurifier::process(\yii\helpers\Markdown::process(substr($post_el['text'], 0, 700) . ' ...'));
    ?>

	</div>
	<span style="float: right;padding-right: 1cm;">
	<?php 
    echo Html::a('Read more', ['post/view', 'id' => $post_el['post_id']], ['class' => 'btnread']);
    ?>
	</span>




<hr class="style-two">

开发者ID:koakumasd,项目名称:blogsite,代码行数:29,代码来源:index.php

示例13: function

          //
          //  The onchange event handler that typesets the
          //  math entered by the user
          //
          window.UpdateMath = function (TeX) {
            QUEUE.Push(["Text",math,"\\displaystyle{"+TeX+"}"]);
          }
        })();
      </script>
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Удалить', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
?>
    </p>
    
    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['name', ['attribute' => 'type_id', 'value' => $model->taskType->name], ['attribute' => 'text', 'value' => Markdown::process($model->text), 'format' => 'html']]]);
?>
    

</div>
<?php 
Pjax::end();
开发者ID:mrhat24,项目名称:site-for-pm,代码行数:31,代码来源:view.php

示例14: substr

    $baseDir = '';
    $this->title = substr($page, 0, strrpos($page, '.'));
} else {
    $baseDir = substr($page, 0, $pos) . '/';
    $this->title = substr($page, $pos + 1, strrpos($page, '.') - $pos - 1);
}
if ($page == 'README.md') {
    $this->params['breadcrumbs'][] = 'Readme';
    $menus = $this->context->module->getMenus();
    $links = [];
    foreach ($menus as $menu) {
        $url = Url::to($menu['url'], true);
        $links[] = "[**{$menu['label']}**]({$url})";
    }
    $body = str_replace(':smile:.', ".\n\n" . implode('  ', $links) . "\n", $this->render("@thinkwill/admin/README.md"));
} else {
    $body = $this->render("@thinkwill/admin/{$page}");
}
$body = preg_replace_callback('/\\]\\((.*?)\\)/', function ($matches) use($baseDir) {
    $link = $matches[1];
    if (strpos($link, '://') === false) {
        if ($link[0] == '/') {
            $link = Url::current(['page' => ltrim($link, '/')], true);
        } else {
            $link = Url::current(['page' => $baseDir . $link], true);
        }
    }
    return "]({$link})";
}, $body);
echo Markdown::process($body, 'gfm');
开发者ID:thinkwill,项目名称:yii2-admin,代码行数:30,代码来源:index.php

示例15: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_AFTER_FIND => 'body'], 'value' => function ($event) {
         return HtmlPurifier::process(Markdown::process($event->sender->content, 'gfm-comment'));
     }], ['class' => BlameableBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'user_id']]];
 }
开发者ID:faninv,项目名称:gtqa,代码行数:9,代码来源:Answer.php


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