本文整理汇总了PHP中ParsedownExtra::setBreaksEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP ParsedownExtra::setBreaksEnabled方法的具体用法?PHP ParsedownExtra::setBreaksEnabled怎么用?PHP ParsedownExtra::setBreaksEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParsedownExtra
的用法示例。
在下文中一共展示了ParsedownExtra::setBreaksEnabled方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* Parse a given path to the documentation for a file. Performs a case
* insensitive lookup on the file system. Automatically appends the file
* extension to one of the markdown extensions as well so /install/ in a
* web browser will match /install.md or /INSTALL.md.
*
* Filepath: /var/www/myproject/src/cms/en/folder/subfolder/page.md
* URL: http://myhost/mywebroot/dev/docs/2.4/cms/en/folder/subfolder/page
* Webroot: http://myhost/mywebroot/
* Baselink: dev/docs/2.4/cms/en/
* Pathparts: folder/subfolder/page
*
* @param DocumentationPage $page
* @param String $baselink Link relative to webroot, up until the "root"
* of the module. Necessary to rewrite relative
* links
*
* @return String
*/
public static function parse(DocumentationPage $page, $baselink = null)
{
if (!$page || !$page instanceof DocumentationPage) {
return false;
}
$md = $page->getMarkdown(true);
// Pre-processing
$md = self::rewrite_image_links($md, $page);
$md = self::rewrite_relative_links($md, $page, $baselink);
$md = self::rewrite_api_links($md, $page);
$md = self::rewrite_heading_anchors($md, $page);
$md = self::rewrite_code_blocks($md);
$parser = new ParsedownExtra();
$parser->setBreaksEnabled(false);
$text = $parser->text($md);
return $text;
}
示例2: markdown
/**
* markdown
*
* @param mixed $text
* @access public
* @return void
*/
public function markdown($text)
{
$html = $this->pluginHandle(__CLASS__)->trigger($parsed)->markdown($text);
if (!$parsed) {
static $parser;
if (empty($parser)) {
$parser = new ParsedownExtra();
$parser->setBreaksEnabled(true);
}
$html = $parser->text($text);
}
return $html;
}
示例3: ParsedownExtra
* Copyright (c) 2016 AvikB, some rights reserved.
* Copyright under Creative Commons Attribution-ShareAlike 3.0 Unported,
* for details visit: https://creativecommons.org/licenses/by-sa/3.0/
*
* @Contributors:
* Created by AvikB for noncommercial MusicBee project.
* Spelling mistakes and fixes from community members.
*
*/
require_once $_SERVER['DOCUMENT_ROOT'] . '/functions.php';
include_once $link['root'] . 'includes/parsedown/Parsedown.php';
include_once $link['root'] . 'includes/parsedown/ParsedownExtra.php';
$data = Format::parsePage($link['url'] . 'pages/credit/credit.md');
//load parsedown for markdown to html converter
$ParsedownExtra = new ParsedownExtra();
$ParsedownExtra->setBreaksEnabled(true);
$data['html_raw'] = $ParsedownExtra->text($data['markdown']);
//load and use html purifier for unsafe html.
$data['html_safe'] = Format::htmlSafeOutput($data['html_raw']);
//purify the readme note html
?>
<!DOCTYPE html>
<html>
<head>
<title><?php
echo $data['title'];
?>
</title>
<meta name="description" content="<?php
echo $data['description'];
?>
示例4: markdown
/**
* A very simple markdown parser.
*
* @since 150113 First documented version.
*
* @param string $string Input string to convert.
* @param array $args Any additional behavioral args.
*
* @return string Markdown converted to HTML markup.
*/
public function markdown($string, array $args = [])
{
if (!($string = trim((string) $string))) {
return $string;
// Not possible.
}
$default_args = ['oembed' => false, 'breaks' => true, 'no_p' => false];
$args = array_merge($default_args, $args);
$args = array_intersect_key($args, $default_args);
$oembed = (bool) $args['oembed'];
$breaks = (bool) $args['breaks'];
$no_p = (bool) $args['no_p'];
if ($oembed && strpos($string, '://') !== false) {
$_spcsm = $this->spcsmTokens($string, [], __FUNCTION__);
$_oembed_args = array_merge(wp_embed_defaults(), ['discover' => false]);
$_spcsm['string'] = preg_replace_callback('/^\\s*(https?:\\/\\/[^\\s"]+)\\s*$/im', function ($m) use($_oembed_args) {
$oembed = wp_oembed_get($m[1], $_oembed_args);
return $oembed ? $oembed : $m[0];
}, $_spcsm['string']);
$string = $this->spcsmRestore($_spcsm);
unset($_spcsm, $_oembed_args);
// Housekeeping.
}
if (is_null($parsedown =& $this->cacheKey(__FUNCTION__, 'parsedown'))) {
$parsedown = new \ParsedownExtra();
// Singleton.
}
$parsedown->setBreaksEnabled($breaks);
$html = $parsedown->text($string);
if ($no_p) {
// Remove `<p></p>` wrap?
$html = preg_replace('/^\\<p\\>/i', '', $html);
$html = preg_replace('/\\<\\/p\\>$/i', '', $html);
}
return $html;
// Gotta love Parsedown :-)
}
示例5: dateHMDMY
}
// fin while
echo '
</ul>
';
} else {
$displayDate = "";
// initialiser
if ($donnees['edited']) {
$displayDate = "<sup>édité</sup> ";
}
$displayDate .= dateHMDMY($donnees["date"]);
echo '
<a href="/news/" class="btn btn-primary btn-sm"><i class="ionicons ion-arrow-left-c"> </i> Revenir à la liste</a>
<div class="news">
<span class="date">' . $displayDate . '</span>
<h1>' . $donnees["titre"] . '</h1>
<div class="art">' . $md->setBreaksEnabled(true)->text($donnees["article"]) . '</div>
</div>
';
}
?>
</div>
</div>
</div> <!-- //.bs-component -->
</div> <!-- //.col-lg-9 -->
<?php
require '../includes/footer.php';
示例6: __construct
private function __construct()
{
$this->parser = new ParsedownExtra();
$this->parser->setBreaksEnabled(true);
}