本文整理汇总了PHP中Michelf\MarkdownExtra::transform方法的典型用法代码示例。如果您正苦于以下问题:PHP MarkdownExtra::transform方法的具体用法?PHP MarkdownExtra::transform怎么用?PHP MarkdownExtra::transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Michelf\MarkdownExtra
的用法示例。
在下文中一共展示了MarkdownExtra::transform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderFullpage
public function renderFullpage(AbstractMediaEntity $entity)
{
/* @var MarkdownEntity $entity */
$raw = file_get_contents($entity->getPath());
$rendered = $this->markdownExtraParser->transform($raw);
return $this->renderEngine->render('CmfcmfMediaModule:MediaType/Markdown:Fullpage.html.twig', ['entity' => $entity, 'rendered' => $rendered, 'raw' => $raw]);
}
示例2: block
/**
* @param string $text
* @return string
*/
public function block($text)
{
$pattern = '~<(code|pre)>(.+?)</\\1>|```php\\s(.+?)\\n```~s';
$highlighted = preg_replace_callback($pattern, [$this, 'highlightCb'], $text);
$text = $this->markdown->transform($highlighted);
return trim($text);
}
示例3: parse
private function parse($str)
{
if (!preg_match($this->regex, $str, $matches) === 1) {
throw new \DomainException('Invalid markdown format');
}
$meta = trim($matches[2]) !== '' ? $this->yamlParser->parse(trim($matches[2])) : null;
$str = ltrim($matches[4]);
return new Post($meta['id'], $meta['title'], $meta['summary'], $this->markdownParser->transform($str), $meta['tags'], $meta['published'], $meta['modified']);
}
示例4: 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);
}
示例5: transform
public function transform($text)
{
$text = parent::transform($text);
$text = preg_replace_callback(TBGTextParser::getIssueRegex(), array($this, '_parse_issuelink'), $text);
$text = preg_replace_callback(TBGTextParser::getMentionsRegex(), array($this, '_parse_mention'), $text);
return $text;
}
示例6: transform
public function transform($text)
{
$text = parent::transform($text);
$harusame = new \Denshoch\Harusame(array("autoTcy" => $this->autoTcy, "tcyDigit" => $this->tcyDigit, "autoTextOrientation" => $this->autoTextOrientation));
$text = $harusame->transform($text);
return $text;
}
示例7: escapeDescription
/**
* @param CollectionEntity|AbstractMediaEntity $entity
*
* @return string
*/
public function escapeDescription($entity)
{
$description = $entity->getDescription();
$strategy = null;
$hookName = null;
if ($entity instanceof CollectionEntity) {
$strategy = \ModUtil::getVar('CmfcmfMediaModule', 'descriptionEscapingStrategyForCollection');
$hookName = 'collections';
} elseif ($entity instanceof AbstractMediaEntity) {
$strategy = \ModUtil::getVar('CmfcmfMediaModule', 'descriptionEscapingStrategyForMedia');
$hookName = 'media';
} else {
throw new \LogicException();
}
$eventName = "cmfcmfmediamodule.filter_hooks.{$hookName}.filter";
$hook = new \Zikula_FilterHook($eventName, $description);
$description = $this->hookDispatcher->dispatch($eventName, $hook)->getData();
switch ($strategy) {
case 'raw':
return $description;
case 'text':
return htmlentities($description);
case 'markdown':
return $this->markdownExtra->transform($description);
default:
throw new \LogicException();
}
}
示例8: 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');
}
示例9: parse
public function parse($text)
{
$markdown = new MarkdownExtra();
$text = $this->doShortcodes($text);
$text = $markdown->transform($text);
$text = $this->extendTags($text);
return $text;
}
示例10: 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);
}
示例11: transform
public function transform($text)
{
$this->no_markup = true;
$this->no_entities = true;
$text = parent::transform($text);
$text = preg_replace_callback(\thebuggenie\core\helpers\TextParser::getIssueRegex(), array($this, '_parse_issuelink'), $text);
$text = preg_replace_callback(\thebuggenie\core\helpers\TextParser::getMentionsRegex(), array($this, '_parse_mention'), $text);
return $text;
}
示例12: transform
public function transform($text)
{
if ($this->running) {
return parent::runBlockGamut($text);
}
$this->running = true;
$text = parent::transform($text);
$this->running = false;
return $text;
}
示例13: 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);
}
示例14: 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);
}
}
示例15: 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);
}
}