本文整理匯總了PHP中Parsedown::setMarkupEscaped方法的典型用法代碼示例。如果您正苦於以下問題:PHP Parsedown::setMarkupEscaped方法的具體用法?PHP Parsedown::setMarkupEscaped怎麽用?PHP Parsedown::setMarkupEscaped使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Parsedown
的用法示例。
在下文中一共展示了Parsedown::setMarkupEscaped方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _getMarkdownContent
public function _getMarkdownContent()
{
// Parsedown
$Parsedown = new \Parsedown();
$texte = $Parsedown->setMarkupEscaped(true)->text($this->content);
// Emojione
$client = new \Emojione\Client(new \Emojione\Ruleset());
$client->imageType = 'png';
return $client->shortnameToImage($texte);
}
示例2: markdown
function markdown($s)
{
$pd = new Parsedown();
$pd->setMarkupEscaped(true);
$pd->setimagesEnabled(false);
return $pd->text($s);
}
示例3: test_no_markup
public function test_no_markup()
{
$markdownWithHtml = <<<MARKDOWN_WITH_MARKUP
<div>_content_</div>
sparse:
<div>
<div class="inner">
_content_
</div>
</div>
paragraph
<style type="text/css">
p {
color: red;
}
</style>
comment
<!-- html comment -->
MARKDOWN_WITH_MARKUP;
$expectedHtml = <<<EXPECTED_HTML
<p><div><em>content</em></div></p>
<p>sparse:</p>
<p><div>
<div class="inner">
<em>content</em>
</div>
</div></p>
<p>paragraph</p>
<p><style type="text/css">
p {
color: red;
}
</style></p>
<p>comment</p>
<p><!-- html comment --></p>
EXPECTED_HTML;
$parsedownWithNoMarkup = new Parsedown();
$parsedownWithNoMarkup->setMarkupEscaped(true);
$this->assertEquals($expectedHtml, $parsedownWithNoMarkup->text($markdownWithHtml));
}
示例4: 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();
}
示例5: documentation
public function documentation()
{
global $pawUsers;
$request = $this->_check("user_config");
// GET DOCUMENTATION PAGE
$docs = pawUsers_PATH . "/docs";
$file = $docs . "/index.md";
if (isset($_GET["page"]) && endsWith($_GET["page"], ".md")) {
$page = urldecode($_GET["page"]);
if (startsWith(realpath($docs . "/" . $page), realpath($docs)) && is_file($docs . "/" . $page)) {
$file = $docs . "/" . $page;
} else {
$file = $docs . "/error.md";
}
}
// READ DOCUMENTATION PAGE
$mdtext = file_get_contents($file);
$parser = new Parsedown();
$parser->setMarkupEscaped(false);
$content = $parser->text($mdtext);
// DISPLAY DOCUMENTATION PAGE
$this->display("../../plugins/paw_users/admin/docs", array("content" => $content));
}
示例6: process_markdown
/**
* Render shaare contents through Markdown parser.
* 1. Remove HTML generated by Shaarli core.
* 2. Generate markdown descriptions.
* 3. Wrap description in 'markdown' CSS class.
*
* @param string $description input description text.
*
* @return string HTML processed $description.
*/
function process_markdown($description)
{
$parsedown = new Parsedown();
$processedDescription = $description;
$processedDescription = reverse_text2clickable($processedDescription);
$processedDescription = reverse_nl2br($processedDescription);
$processedDescription = reverse_space2nbsp($processedDescription);
$processedDescription = reset_quote_tags($processedDescription);
$processedDescription = $parsedown->setMarkupEscaped(false)->setBreaksEnabled(true)->text($processedDescription);
$processedDescription = '<div class="markdown">' . $processedDescription . '</div>';
return $processedDescription;
}
示例7: 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);
}
示例8: setMarkupEscaped
/**
*
*
* @static
*/
public static function setMarkupEscaped($markupEscaped)
{
return \Parsedown::setMarkupEscaped($markupEscaped);
}
示例9: process_markdown
/**
* Render shaare contents through Markdown parser.
* 1. Remove HTML generated by Shaarli core.
* 2. Reverse the escape function.
* 3. Generate markdown descriptions.
* 4. Sanitize sensible HTML tags for security.
* 5. Wrap description in 'markdown' CSS class.
*
* @param string $description input description text.
*
* @return string HTML processed $description.
*/
function process_markdown($description)
{
$parsedown = new Parsedown();
$processedDescription = $description;
$processedDescription = reverse_text2clickable($processedDescription);
$processedDescription = reverse_nl2br($processedDescription);
$processedDescription = reverse_space2nbsp($processedDescription);
$processedDescription = unescape($processedDescription);
$processedDescription = $parsedown->setMarkupEscaped(false)->setBreaksEnabled(true)->text($processedDescription);
$processedDescription = sanitize_html($processedDescription);
if (!empty($processedDescription)) {
$processedDescription = '<div class="markdown">' . $processedDescription . '</div>';
}
return $processedDescription;
}
示例10: formatage_links
function formatage_links($texte)
{
if ($GLOBALS['use_markdown']) {
include_once 'parsedown/parsedown.php';
$Parsedown = new Parsedown();
return stripslashes($Parsedown->setMarkupEscaped(true)->text($texte));
}
$tofind = array('#([^"\\[\\]|])((http|ftp)s?://([^"\'\\[\\]<>\\s]+))#i', '#\\[([^[]+)\\|([^[]+)\\]#', '#\\[b\\](.*?)\\[/b\\]#s', '#\\[i\\](.*?)\\[/i\\]#s', '#\\[s\\](.*?)\\[/s\\]#s', '#\\[u\\](.*?)\\[/u\\]#s');
$toreplace = array('$1<a href="$2">$2</a>', '<a href="$2">$1</a>', '<strong>$1</strong>', '<em>$1</em>', '<del>$1</del>', '<u>$1</u>');
// ceci permet de formater l’ensemble du message, sauf les balises [code],
$nb_balises_code_avant = preg_match_all('#\\[code\\](.*?)\\[/code\\]#s', $texte, $balises_code, PREG_SET_ORDER);
$texte_formate = preg_replace($tofind, $toreplace, ' ' . $texte . ' ');
$texte_formate = nl2br(trim($texte_formate));
if ($nb_balises_code_avant) {
$nb_balises_code_apres = preg_match_all('#\\[code\\](.*?)\\[/code\\]#s', $texte_formate, $balises_code_apres, PREG_SET_ORDER);
foreach ($balises_code as $i => $code) {
$texte_formate = str_replace($balises_code_apres[$i][0], '<pre>' . $balises_code[$i][1] . '</pre>', $texte_formate);
}
}
return $texte_formate;
}
示例11: parse_message
function parse_message($text, $hide_smilies)
{
global $pun_config, $lang_common, $pun_user;
if ($pun_config['o_censoring'] == '1') {
$text = censor_words($text);
}
// If the message contains a code tag we have to split it up (text within [code][/code] shouldn't be touched)
if (strpos($text, '[code]') !== false && strpos($text, '[/code]') !== false) {
list($inside, $text) = extract_blocks($text, '[code]', '[/code]');
}
$Parsedown = new Parsedown();
$text = $Parsedown->setMarkupEscaped(true)->setUrlsLinked(false)->text($text);
if ($pun_config['o_make_links'] == '1') {
$text = do_clickable($text);
}
// If the message contains code in Markdown
if (strpos($text, '[code]') !== false && strpos($text, '[/code]') !== false) {
// If we have code from BBCode, put them back into the text
if (isset($inside)) {
$parts = explode("", $text);
$text = '';
foreach ($parts as $i => $part) {
$text .= $part . (isset($inside[$i]) ? '[code]' . $inside[$i] . '[/code]' : '');
}
}
// And take them out again.
list($inside, $text) = extract_blocks($text, '[code]', '[/code]');
}
if ($pun_config['p_message_bbcode'] == '1' && strpos($text, '[') !== false && strpos($text, ']') !== false) {
$text = do_bbcode($text);
}
if ($pun_config['o_smilies'] == '1' && $pun_user['show_smilies'] == '1' && $hide_smilies == '0') {
$text = do_smilies($text);
}
// Deal with newlines, tabs and multiple spaces
$pattern = array("\n", "\t", ' ', ' ');
$replace = array('<br />', '    ', '  ', '  ');
$text = str_replace($pattern, $replace, $text);
// If we split up the message before we have to concatenate it together again (code tags)
if (isset($inside)) {
$parts = explode("", $text);
$text = '';
foreach ($parts as $i => $part) {
$text .= $part;
if (isset($inside[$i])) {
$num_lines = substr_count($inside[$i], "\n");
$text .= '</p><div class="codebox"><pre' . ($num_lines > 28 ? ' class="vscroll"' : '') . '><code>' . pun_trim(pun_htmlspecialchars($inside[$i]), "\n\r") . '</code></pre></div><p>';
}
}
}
return clean_paragraphs($text);
}