本文整理汇总了PHP中Michelf\MarkdownExtra::defaultTransform方法的典型用法代码示例。如果您正苦于以下问题:PHP MarkdownExtra::defaultTransform方法的具体用法?PHP MarkdownExtra::defaultTransform怎么用?PHP MarkdownExtra::defaultTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Michelf\MarkdownExtra
的用法示例。
在下文中一共展示了MarkdownExtra::defaultTransform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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(';');
}
示例2: 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;
}
示例3: 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;
}
示例4: render
public function render($content)
{
$html = $this->getLayoutHead();
$html .= MarkdownExtra::defaultTransform($content);
$html .= $this->getLayoutFooter();
return $html;
}
示例5: 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);
}
示例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 MichelfMarkdown converter.');
}
return MarkdownExtra::defaultTransform($input);
}
示例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);
$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;
}
示例8: 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;
}
示例9: getContent
public function getContent($page)
{
$pageFile = $this->getDocumentationPath() . "/{$page}.md";
return $this->cache->rememberForever("doc_page_{$pageFile}_content", function () use($pageFile) {
$data = $this->parser->parse($this->finder->get($pageFile));
return MarkdownExtra::defaultTransform($data->getContent());
});
}
示例10: 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);
}
示例11: getParsedContent
public function getParsedContent()
{
// Replace old announcements
$oldAnnouncementDiv = ['<div style="color:#222;width:400px;font-family:Georgia, serif;text-align:justify;line-height:14pt;' . 'font-size:12pt;">', '<div style="color:#222;width:400px;font-family:Georgia, serif;text-align:left;line-height:14pt;' . 'font-size:12pt;">'];
$newOldAnnouncementDiv = '<div style="width:400px;font-family:Georgia, serif;text-align:justify;' . 'line-height:14pt;font-size:12pt;">';
$content = str_replace($oldAnnouncementDiv, $newOldAnnouncementDiv, $this->content);
return MarkdownExtra::defaultTransform($content);
}
示例12: toHtml
public function toHtml($mdStr)
{
$html = $this->preTransformText($mdStr);
$html = MarkdownExtra::defaultTransform($html);
$html = SmartyPants::defaultTransform($html);
$html = $this->postTransformText($html);
return $html;
}
示例13: markdown
public static function markdown($content)
{
$html = \Michelf\MarkdownExtra::defaultTransform($content);
if (Options::get('habarimarkdown__smarty', false)) {
$html = SmartyPants($html);
}
return $html;
}
示例14: toHTML
public function toHTML($text)
{
$text = $this->preTransformText($text);
$text = MarkdownExtra::defaultTransform($text);
$text = SmartyPants::defaultTransform($text);
$text = $this->postTransformText($text);
return $text;
}
示例15: 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);
}
}