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


PHP Markdown::defaultTransform方法代码示例

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


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

示例1: loadPost

function loadPost($page)
{
    // traduire les donné du markdown en html
    $text = file_get_contents($page);
    $html = Markdown::defaultTransform($text);
    return $html;
}
开发者ID:medanisL,项目名称:ExoSimplon,代码行数:7,代码来源:index.php

示例2: __construct

 public function __construct($file, $app = null)
 {
     $env = $app->environment;
     $info = new \SplFileInfo($file);
     $this->type = $info->getExtension();
     $file_text = file_get_contents($file);
     $file_header = substr($file_text, 0, strpos($file_text, '}') + 1);
     $file_header = json_decode($file_header, true);
     $page_path = ltrim(str_replace($env['PAGES_ROOT_PATH'], '', $file), '/');
     $this->id = str_replace('.' . $this->type, '', $page_path);
     $this->header = $file_header;
     if (!isset($this->header['order'])) {
         $this->header['order'] = '';
     }
     $file_body = substr_replace($file_text, '', 0, strpos($file_text, '}') + 2);
     $this->contents = $file_body;
     if ($this->type == 'md') {
         $this->contents = str_replace('@@siteurl@@', $env['ROOT_PATH'], $this->contents);
         $this->contents = Markdown::defaultTransform($this->contents);
     } else {
         if ($this->type == 'html') {
             $this->contents = str_replace('@@siteurl@@', $env['ROOT_PATH'], $this->contents);
         } else {
             if ($this->type == 'txt') {
                 $this->contents = '<p>' . str_replace("\n", '</p><p>', $this->contents) . '</p>';
             }
         }
     }
 }
开发者ID:centorino,项目名称:phybrid,代码行数:29,代码来源:PhybridPage.php

示例3: __invoke

 public function __invoke($string = null)
 {
     if (!class_exists('Michelf\\Markdown')) {
         require_once __DIR__ . '/vendor/php-markdown/Michelf/Markdown.inc.php';
     }
     return \Michelf\Markdown::defaultTransform($string);
 }
开发者ID:omusico,项目名称:cursoZf2,代码行数:7,代码来源:Module.php

示例4: transform

function transform($mysql, $text)
{
    //Transforms a mardown text to LUNI flavored HTML
    $text = linkUsers($mysql, $text);
    $my_html = Markdown::defaultTransform($text);
    return $my_html;
}
开发者ID:LEGOUniverseArchive,项目名称:UniverseLauncher,代码行数:7,代码来源:forums.php

示例5: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $user = User::findWithPermission($id);
     $document = $this->policyRepository->getByName('member-agreement');
     $htmlDocument = Markdown::defaultTransform($document);
     return view('account.induction.show')->with('user', $user)->with('document', $htmlDocument);
 }
开发者ID:adamstrawson,项目名称:BBMembershipSystem,代码行数:13,代码来源:MemberInductionController.php

示例6: onStartNoticeSave

 function onStartNoticeSave($notice)
 {
     // Only run this on local notices
     if ($notice->isLocal()) {
         $text = $notice->content;
         // From /lib/util.php::common_render_text
         // We don't want to call it directly since we don't want to
         // run common_linkify() on the text
         $text = common_remove_unicode_formatting($text);
         $text = preg_replace('/[\\x{0}-\\x{8}\\x{b}-\\x{c}\\x{e}-\\x{19}]/', '', $text);
         $text = common_replace_urls_callback($text, 'common_linkify');
         // Link #hashtags
         $rendered = preg_replace_callback('/(^|\\&quot\\;|\'|\\(|\\[|\\{|\\s+)#([\\pL\\pN_\\-\\.]{1,64})/u', function ($m) {
             return "{$m[1]}#" . common_tag_link($m[2]);
         }, $text);
         // Link @mentions, !mentions, @#mentions
         $rendered = common_linkify_mentions($rendered, $notice->getProfile(), $notice->hasParent() ? $notice->getParent() : null);
         // Prevent leading #hashtags from becoming headers by adding a backslash
         // before the "#", telling markdown to leave it alone
         // $repl_rendered = preg_replace('/^#[\pL\pN_\-\.]{1,64}/u', 'replaced!', $rendered);
         $repl_rendered = preg_replace('/^#<span class="tag">/u', '\\\\\\0', $rendered);
         // Only use the replaced value from above if it returned a success
         if ($rendered !== null) {
             $rendered = $repl_rendered;
         }
         // handle Markdown link forms in order not to convert doubly.
         $rendered = preg_replace('/\\[([^]]+)\\]\\((<a [^>]+>)([^<]+)<\\/a>\\)/u', '\\2\\1</a>', $rendered);
         // Convert Markdown to HTML
         $notice->rendered = \Michelf\Markdown::defaultTransform($rendered);
     }
     return true;
 }
开发者ID:shnarazk,项目名称:gs-markdown,代码行数:32,代码来源:MarkdownPlugin.php

示例7: transform

function transform($text)
{
    //Transforms a mardown text to LUNI flavored HTML
    //Only compiles Markdown atm
    $my_html = Markdown::defaultTransform($text);
    return $my_html;
}
开发者ID:Timtech,项目名称:UniverseLauncher,代码行数:7,代码来源:forums.php

示例8: handleRequest

 public function handleRequest()
 {
     // TODO create "page not found" page
     $uri = Request::path();
     // Default version of the documentation
     $page = 'introduction';
     $versions = array("4.0", "4.1", "4.2", "4.3", "4.6", "5.0", "5.6", "5.12");
     $version = end($versions);
     // If not the root, then split the uri to find the content
     $segment1 = Request::segment(1);
     $segment2 = Request::segment(2);
     if (!empty($segment1)) {
         $version = $segment1;
         if (!empty($segment2)) {
             $page = $segment2;
         }
     }
     // Show the correct markdown contents
     $page = __DIR__ . '/docs/' . $version . '/' . $page . '.md';
     if (file_exists($page)) {
         $contents = file_get_contents($page);
         $sidebar = file_get_contents(__DIR__ . '/docs/' . $version . '/sidebar.md');
         // Transform documents
         $contents_html = Markdown::defaultTransform($contents);
         $sidebar_html = Markdown::defaultTransform($sidebar);
         // Replace url variable
         $sidebar_html = preg_replace('/{url}/mi', URL::to($version), $sidebar_html);
         return View::make('layouts.master')->with('version', $version)->with('versions', $versions)->with('sidebar', $sidebar_html)->with('content', $contents_html);
     } else {
         \App::abort(400, "The page you were looking for could not be found.");
     }
 }
开发者ID:rossjones,项目名称:docs,代码行数:32,代码来源:HomeController.php

示例9: processAll

 public function processAll($viewType)
 {
     foreach ($this->posts as $post) {
         if (!$post->isRepost() && $post->hasAnnotation(self::ANNOTATION_TYPE)) {
             // Use longpost template
             $post->setTemplate('longpost.twig.html');
             // Convert longpost annotation to HTML and move to meta for access from the template
             $annotation = $post->getAnnotationValue(self::ANNOTATION_TYPE);
             $post->setMetaField('title', $annotation['title']);
             $post->setMetaField('truncated', false);
             $bodyLines = explode("\n", $annotation['body']);
             if ($viewType == View::PERMALINK) {
                 $body = $annotation['body'];
             } else {
                 $body = '';
                 $i = 0;
                 foreach ($bodyLines as $l) {
                     if (trim($l) != '') {
                         $body .= $l . "\n\n";
                         $i++;
                         if ($i >= self::TRUNCATED_PARAGRAPH_COUNT) {
                             $post->setMetaField('truncated', true);
                             break;
                         }
                     }
                 }
             }
             $post->set('html', Markdown::defaultTransform($body));
             $post->setMetaField('description', $bodyLines[0]);
             // Do not handle other annotations
             $post->stopProcessing();
         }
     }
 }
开发者ID:lukasros,项目名称:phpadnsite,代码行数:34,代码来源:LongPostsPlugin.php

示例10: send

 /**
  * @param array $values
  * @return bool
  * @throws \UnexpectedValueException
  * @throws \InvalidArgumentException
  */
 public function send(array $values)
 {
     $this->values = $values;
     // Substitute markers
     $subject = $this->renderWithFluid($this->getSubject(), $values);
     $body = $this->renderWithFluid($this->getBody(), $values);
     // Parse body through Markdown processing.
     $body = Markdown::defaultTransform($body);
     $this->getMailMessage()->setFrom($this->getFrom())->setTo($this->getTo())->setSubject($subject);
     // According to preference.
     if ($this->isPlainTextPreferred()) {
         $text = Html2Text::getInstance()->convert($body);
         $this->getMailMessage()->setBody($text);
     } else {
         $this->getMailMessage()->setBody($body, 'text/html');
         // Attach plain text version if HTML tags are found in body
         if ($this->hasHtml($body)) {
             $text = Html2Text::getInstance()->convert($body);
             $this->getMailMessage()->addPart($text, 'text/plain');
         }
     }
     // Handle attachment
     #foreach ($this->attachments as $attachment) {
     #    $this->getMailMessage()->attach($attachment);
     #}
     $this->getMailMessage()->send();
     $isSent = $this->getMailMessage()->isSent();
     $this->getLoggingService()->log($this->getMailMessage());
     return $isSent;
 }
开发者ID:Ecodev,项目名称:formule,代码行数:36,代码来源:MessageService.php

示例11: _eg_shortcode_readme

 /**
  * Get github readme
  *
  * @param array $atts
  * @param string $content
  * @return string
  */
 public function _eg_shortcode_readme($atts)
 {
     $atts = shortcode_atts(array('repo' => 'johnie/embedgithub', 'file' => false, 'trim' => 0), $atts);
     $transient = "embedgithub_" . $atts['repo'] . "_" . $atts['file'] . "_" . $atts['trim'];
     if (false === ($html = get_transient($transient))) {
         if ($atts['file']) {
             $url = "https://api.github.com/repos/" . $atts['repo'] . "/contents/" . $atts['file'];
         } else {
             $url = "https://api.github.com/repos/" . $atts['repo'] . "/readme";
         }
         $ch = curl_init();
         $timeout = 5;
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_USERAGENT, 'WordPress');
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
         $data = curl_exec($ch);
         curl_close($ch);
         $json = json_decode($data);
         $markdown = base64_decode($json->content);
         if ($atts['trim'] > 0) {
             $markdown = implode("\n", array_slice(explode("\n", $markdown), $atts['trim']));
         }
         $html = Markdown::defaultTransform($markdown);
         set_transient($transient, $html, 12 * HOUR_IN_SECONDS);
     }
     return $html;
 }
开发者ID:frozzare,项目名称:embedgithub,代码行数:35,代码来源:embedgithub.php

示例12: indexAction

 public function indexAction()
 {
     $title = '# Hello world ! ';
     $content = '*This is my first mardown parsing !*';
     $my_html_title = Markdown::defaultTransform($title);
     $my_html_content = Markdown::defaultTransform($content);
     return $this->render('KarkTutoBundle:Default:index.html.twig', array('title' => $my_html_title, 'content' => $my_html_content));
 }
开发者ID:chadyred,项目名称:markdown-symfony2,代码行数:8,代码来源:AcmeController.php

示例13: smarty_function_markdown

function smarty_function_markdown($params, &$smarty)
{
    if (!in_array('text', array_keys($params))) {
        trigger_error("markdown missing 'text' parameter", E_USER_NOTICE);
        return;
    }
    return Markdown::defaultTransform($params['text']);
}
开发者ID:PercyODI,项目名称:copeappgames,代码行数:8,代码来源:function.markdown.php

示例14: makeEmbed

 public function makeEmbed($embed, $markdown)
 {
     $position = $embed['position'];
     $url = $embed['url'];
     $text = $embed['text'];
     $line = $embed['line'];
     return ['url' => $url, 'text' => $text, 'markdown' => $line, 'html' => rtrim(strip_tags(Markdown::defaultTransform($line), '<a>')), 'indices' => [$position, $position + strlen($text)]];
 }
开发者ID:thantai574,项目名称:laravel-editor,代码行数:8,代码来源:Link.php

示例15: smarty_block_markdown

function smarty_block_markdown($params, $content, $template, &$repeat)
{
    if (!$repeat) {
        if (isset($content)) {
            return Markdown::defaultTransform($content);
        }
    }
}
开发者ID:nagumo,项目名称:Phest,代码行数:8,代码来源:block.markdown.php


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