本文整理汇总了PHP中Parsedown::setBreaksEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP Parsedown::setBreaksEnabled方法的具体用法?PHP Parsedown::setBreaksEnabled怎么用?PHP Parsedown::setBreaksEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parsedown
的用法示例。
在下文中一共展示了Parsedown::setBreaksEnabled方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* ParsedownPlugin constructor.
*
* @param \Parsedown $parser
* @param string $rootDir
*/
public function __construct(\Parsedown $parser, $rootDir = __DIR__)
{
// Initialize parser
$this->parser = $parser;
$parser->setBreaksEnabled(self::BREAKS_ENABLED)->setMarkupEscaped(self::MARKUP_ESCAPED)->setUrlsLinked(self::URLS_LINKED);
// Set roots
$this->rootPath = plugin_dir_path($rootDir);
$this->rootUrl = plugin_dir_url($rootDir);
// Register init action
add_action('init', [$this, 'init']);
$this->registerActionsAndFilters();
}
示例2: _load_content
private function _load_content($view, $ext, $data = array(), $parse_view = TRUE)
{
$file = file_get_contents($view);
$content_part = explode("{:", $file);
array_shift($content_part);
// if user set fields
if (count($content_part) > 1) {
foreach ($content_part as $elm) {
$segs = preg_split("/( :} | :}|:} |:})/", $elm, 2);
if ($this->_ci->session->userdata(SITE_SLUG . '_role') != 'admin') {
if (trim($segs[0]) == 'role') {
$roles = preg_split("/(\\s,\\s|\\s,|,\\s|,|\n)/", $segs[1]);
if (!in_array($this->_ci->session->userdata(SITE_SLUG . '_role'), $roles)) {
show_404();
}
}
}
if (trim($segs[0]) == 'title') {
$this->_ci->config->set_item('page_title', trim($segs[1]) . ' - ' . $this->_ci->config->item('page_title'));
}
// set meta to config
if (in_array(trim($segs[0]), array('meta_description', 'author'))) {
$this->_ci->config->set_item(trim($segs[0]), trim($segs[1]));
}
if (in_array(trim($segs[0]), array('meta_keywords'))) {
$this->_ci->config->set_item(trim($segs[0]), trim($segs[1]) . ', ' . $this->_ci->config->item('meta_keywords'));
}
if (trim($segs[0]) == 'layout') {
$this->set_layout(trim($segs[1]));
} elseif (trim($segs[0]) == 'content') {
// parse content first with lex parser
if ($this->_parser_enabled === TRUE and $parse_view === TRUE) {
$content = $this->_lexparser->parse(trim($segs[1]), $data, array($this, '_lex_callback'));
}
$Parsedown = new Parsedown();
$content = $Parsedown->setBreaksEnabled(true)->text($content);
} else {
$this->fields[trim($segs[0])] = trim($segs[1]);
}
}
} else {
// parse content first with lex parser
if ($this->_parser_enabled === TRUE and $parse_view === TRUE) {
$content = $this->_lexparser->parse($file, $data, array($this, '_lex_callback'));
}
$Parsedown = new Parsedown();
$content = $Parsedown->setBreaksEnabled(true)->text($content);
}
return $content;
}
示例3: build_doc
<?php
global $parser, $content;
include __DIR__ . '/../../../../bootstrap.php';
$parser = new Parsedown();
$parser->setBreaksEnabled(false);
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 'start';
$content = ['nav1' => '', 'nav2' => '', 'page' => ''];
$content['page'] = build_doc($page);
function build_doc($page)
{
global $parser, $content;
$paths = [__DIR__ . '/../../../../docs', __DIR__ . '/../docs'];
$replaces = ['{{card-end}}' => '</div></div>', '{{card-list-end}}' => '</ul></div>', '{{navbar-end}}' => '</ul></nav>', 'href="!' => 'href="index.php?page='];
$final_file_path = null;
foreach ($paths as $path) {
$test_path = $path . '/' . $page . '.md';
if (file_exists($test_path) && is_null($final_file_path) === true) {
$final_file_path = $test_path;
}
}
if (is_null($final_file_path) === true) {
throw new Exception('Could not find page: ' . $page);
}
$html = $parser->text(file_get_contents($final_file_path));
# strip the start/end <p> tags that parsedown puts in >_<;
#
foreach ($replaces as $key => $value) {
$html = str_replace($key, $value, $html);
}
# first do all includes
示例4: explode
/**
* get detail page
*
* @access private
* @param string category, null for get all
* @param int page number
* @return array
*/
function get_page($url = null, $parse = true)
{
if (!($file = $this->page_exist($url))) {
return $file;
}
if (!empty($file)) {
$page = explode("{:", $file);
array_shift($page);
$page_arr = array('url' => $url);
$file_segment = explode('/', $url);
if (count($url) > 0) {
$page_arr['slug'] = array_pop($file_segment);
if (count($url) > 0) {
$page_arr['parent'] = implode('/', $file_segment);
}
}
if ($parse) {
foreach ($page as $elm) {
$segs = preg_split("/( :} | :}|:} |:})/", $elm, 2);
// set meta to config
if (in_array(trim($segs[0]), array('meta_keywords', 'meta_description', 'author'))) {
$this->CI->config->set_item(trim($segs[0]), trim($segs[1]));
}
if (trim($segs[0]) == 'labels') {
$page_arr[trim($segs[0])] = preg_split("/(\\s,\\s|\\s,|,\\s)/", $segs[1]);
} elseif (trim($segs[0]) == 'content') {
$Parsedown = new Parsedown();
$page_arr[trim($segs[0])] = $Parsedown->setBreaksEnabled(true)->text($segs[1]);
} else {
$page_arr[trim($segs[0])] = trim($segs[1]);
}
}
} else {
foreach ($page as $elm) {
$segs = preg_split("/( :} | :}|:} |:})/", $elm, 2);
$page_arr[trim($segs[0])] = trim($segs[1]);
}
}
return $page_arr;
}
return false;
}
示例5:
?>
<div id="content">
<?php
$project_id = mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $_GET["proj_id"]);
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT project_name, project_desc, project_url, project_owner FROM projects WHERE project_id = " . $project_id . " " . $pub_proj);
while ($row = mysqli_fetch_array($result)) {
echo "<h1>Viewing project <strong>";
if (is_null($row['project_url']) == false) {
echo "<a href=" . $row['project_url'] . ">" . $row['project_name'] . "</a>";
} else {
echo $row['project_name'];
}
echo "</strong></h1>";
if (is_null($row['project_desc']) == false) {
echo "<div id='projDesc'>";
echo $Parsedown->setBreaksEnabled(true)->text($row['project_desc']);
echo "</div>";
}
$project_owner_id = $row['project_owner'];
}
?>
<table class="globalTables" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th></th>
<th>
<a href="?proj_id=<?php
echo $project_id;
?>
&by=name&order=<?php
示例6: htmlspecialchars
echo "<p>User " . htmlspecialchars($_POST['blid']) . " not found.</p>";
}
}
//One of the few time's we'll use a direct SQL query on a page
$result = $db->query($baseQuery . $extendedQuery);
echo "<h2>Search Results for ";
echo "\"<u>" . htmlspecialchars($_POST['query']) . "</u>\"";
if (isset($user) && $user) {
echo " by <a href=\"/user/view.php?id=" . $user->getID() . "\">" . htmlspecialchars($user->getUsername()) . "</a>";
}
echo "</h2><hr />";
if ($result->num_rows) {
while ($row = $result->fetch_object()) {
echo "<p><b><a href=\"addon.php?id=" . $row->id . "\">" . htmlspecialchars($row->name) . "</a></b><br />";
if (strlen($row->description) > 200) {
$desc = substr($row->description, 0, 196) . " ...";
} else {
$desc = $row->description;
}
$Parsedown = new Parsedown();
$Parsedown->setBreaksEnabled(true);
$Parsedown->setMarkupEscaped(true);
//may need escaping
echo $Parsedown->text($desc);
echo "</p><br />";
}
} else {
echo "We couldn't find anything. Sorry about that.";
}
$result->close();
}
示例7: getHtmlLine
public static function getHtmlLine($md, $breaksEnabled = true)
{
$parsedown = new Parsedown();
$parsedown->setBreaksEnabled($breaksEnabled);
return $parsedown->line($md);
}
示例8: markdown
function markdown($text, $allow_html = false)
{
static $parsedown = null;
if ($parsedown === null) {
include BOOTSTRAP_ROOT . 'includes/Parsedown.php';
$parsedown = new Parsedown();
}
$parsedown->setBreaksEnabled(true);
// should convert \n to <br/>?
$parsedown->setMarkupEscaped(!$allow_html);
// should escape HTML?
$parsedown->setUrlsLinked(true);
// should automatically link urls?
return $parsedown->text($text);
}
示例9: setBreaksEnabled
/**
*
*
* @static
*/
public static function setBreaksEnabled($breaksEnabled)
{
return \Parsedown::setBreaksEnabled($breaksEnabled);
}
示例10: substr
$root = substr($_SERVER["PHP_SELF"], 0, -strlen(basename($_SERVER["PHP_SELF"])));
$link = basename(parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH));
parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH) === $root ? $link = "" : "";
$type = strpos($_SERVER["REQUEST_URI"], "post/") ? "post" : "page";
$pages = glob(__DIR__ . "/items/*" . $link . ".{json}", GLOB_BRACE);
$link = $pages ? $pages[0] : "./items/error-404.txt";
$page = load($link);
echo "<!DOCTYPE html><html lang=\"en\"><head><title>", $sitename, trim($page->data->title) ? " - " . $page->data->title : "", "</title><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"initial-scale=1, minimum-scale=1, maximum-scale=1\"><meta http-equiv=\"x-ua-compatible\" content=\"ie=edge\"><link rel=\"stylesheet\" type=\"text/css\" href=\"/assets/css/web.css\"><base href=\"", htmlspecialchars($root, ENT_QUOTES, "UTF-8"), "\"></head><body><header><h1><a href=\".\">", $sitename, "<small>", $sitespot, "</small></a></h1><nav>";
foreach ($pages as $menu) {
$menu_item = load($menu);
if ($menu_item->data->menu) {
echo "<a href=\"", $menu_item->data->url ? $menu_item->data->url : pathinfo($menu)['filename'], "\">", $menu_item->data->title, "</a>";
}
}
echo "</nav></header><main>";
if ($type === "post") {
echo "<article><h2>", $page->data->title, "</h2><h3>", $page->data->spot, "</h3>", $page->data->cover ? "<p><img src=\"" . $page->data->cover . "\" alt=\"" . $page->data->title . "\"></p>" : "", $pd->setBreaksEnabled(true)->text($page->data->body), "</article>";
} else {
if ($type === "page") {
echo "<article><h2>", $page->data->title, "</h2><h3>", $page->data->spot, "</h3>", $page->data->cover ? "<p><img src=\"" . $page->data->cover . "\" alt=\"" . $page->data->title . "\"></p>" : "", $pd->setBreaksEnabled(true)->text($page->data->body), "</article>";
}
}
if ($page->data->title === $blogname) {
foreach ($pages as $post) {
$post_item = load($post);
if ($post_item->data->post) {
echo "<article><h2><a href=\"./post/", $post_item->data->url ? $post_item->data->url : pathinfo($post)['filename'], "\">", $post_item->data->title, "</a></h2><h3>", $post_item->data->spot, "</h3>", $page->data->cover ? "<p><img src=\"" . $page->data->cover . "\" alt=\"" . $post_item->data->title . "\"></p>" : "", "</article>";
}
}
}
echo "</main><footer><p>", $sitename, " © ", date("Y"), " | Powered by <a href=\"https://github.com/boralp/divless\" target=\"_blank\">{divless}</a>. (", round(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 4), " seconds)</p></footer></body></html>";