本文整理匯總了PHP中Markdown函數的典型用法代碼示例。如果您正苦於以下問題:PHP Markdown函數的具體用法?PHP Markdown怎麽用?PHP Markdown使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Markdown函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: load_page
public function load_page($action)
{
$this->file = new File(format_page_name($action->page, true));
$this->markdown = Markdown($this->file->data);
$this->action = $action->action;
$this->page = $action->page;
}
示例2: action_docs
public function action_docs()
{
$page = $this->request->param('page');
if (!$page) {
// Redirect to the default page
$this->request->redirect($this->guide->uri(array('page' => 'about.kohana')));
}
$file = $this->file($page);
if (!$file) {
throw new Kohana_Exception('User guide page not found: :page', array(':page' => $page));
}
// Set the page title
$this->template->title = $this->title($page);
// Parse the page contents into the template
$this->template->content = Markdown(file_get_contents($file));
// Attach the menu to the template
$this->template->menu = Markdown(file_get_contents($this->file('menu')));
// Bind module menu items
$this->template->bind('module_menus', $module_menus);
// Attach module-specific menu items
$module_menus = array();
foreach (Kohana::modules() as $module => $path) {
if ($file = $this->file('menu.' . $module)) {
$module_menus[$module] = Markdown(file_get_contents($file));
}
}
// Bind the breadcrumb
$this->template->bind('breadcrumb', $breadcrumb);
// Add the breadcrumb
$breadcrumb = array();
$breadcrumb[$this->guide->uri()] = __('User Guide');
$breadcrumb[] = $this->section($page);
$breadcrumb[] = $this->template->title;
}
示例3: diaspora2bb
function diaspora2bb($s)
{
$s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
// Remove CR to avoid problems with following code
$s = str_replace("\r", "", $s);
$s = str_replace("\n", " \n", $s);
// The parser cannot handle paragraphs correctly
$s = str_replace(array("</p>", "<p>", '<p dir="ltr">'), array("<br>", "<br>", "<br>"), $s);
// Escaping the hash tags
$s = preg_replace('/\\#([^\\s\\#])/', '#$1', $s);
$s = Markdown($s);
$s = preg_replace('/\\@\\{(.+?)\\; (.+?)\\@(.+?)\\}/', '@[url=https://$3/u/$2]$1[/url]', $s);
$s = str_replace('#', '#', $s);
$s = html2bbcode($s);
// protect the recycle symbol from turning into a tag, but without unescaping angles and naked ampersands
$s = str_replace('♲', html_entity_decode('♲', ENT_QUOTES, 'UTF-8'), $s);
// Convert everything that looks like a link to a link
$s = preg_replace("/([^\\]\\=]|^)(https?\\:\\/\\/)([a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url=$2$3]$2$3[/url]', $s);
//$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
$s = bb_tag_preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\[\\/url\\]/ism", '[youtube]$2[/youtube]', 'url', $s);
$s = bb_tag_preg_replace("/\\[url\\=https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\].*?\\[\\/url\\]/ism", '[youtube]$1[/youtube]', 'url', $s);
$s = bb_tag_preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/vimeo.com\\/([0-9]+)(.*?)\\[\\/url\\]/ism", '[vimeo]$2[/vimeo]', 'url', $s);
$s = bb_tag_preg_replace("/\\[url\\=https?:\\/\\/vimeo.com\\/([0-9]+)\\](.*?)\\[\\/url\\]/ism", '[vimeo]$1[/vimeo]', 'url', $s);
// remove duplicate adjacent code tags
$s = preg_replace("/(\\[code\\])+(.*?)(\\[\\/code\\])+/ism", "[code]\$2[/code]", $s);
// Don't show link to full picture (until it is fixed)
$s = scale_external_images($s, false);
return $s;
}
示例4: newCmtFormHlr
function newCmtFormHlr($author = false, $email = false, $author_id = false, $article_id = false, $content = false, $date = false)
{
if ($content == false) {
$content = $_REQUEST['comment_text'];
}
if ($article_id == false) {
$article_id = $_REQUEST['id'];
}
$reg = Registry::instance();
$_hinfo = $reg->get('hamster_info');
$login_status = $reg->get('login_status');
if ($login_status == 3) {
$author = mysql_escape_string(htmlspecialchars($_hinfo['name']));
$email = '';
$author_id = intval($_hinfo['id']);
if ($_REQUEST['comment_text'] == '') {
return array();
}
require_once 'lib/markdown/markdown.php';
$content = Markdown(strip_tags($content));
} else {
$content = '<p>' . htmlspecialchars($content) . '</p>';
$email = mysql_escape_string(htmlspecialchars($_REQUEST['comment_email']));
if ($_REQUEST['comment_name'] != '' && $name == false) {
$author = mysql_escape_string(htmlspecialchars($_REQUEST['comment_name']));
} else {
$author = 'НЛО';
}
if (strpos($_REQUEST['comment_text'], 'http://') !== false || $_REQUEST['comment_text'] == '' || $_REQUEST['comment_sid'] != $_SESSION['comment_sid'] || !isset($_SESSION['comment_sid']) || time() - $_SESSION['comment_stamp'] < 2) {
return array();
}
}
$prs = array('author' => $author, 'email' => $email, 'author_id' => $author_id, 'article_id' => intval($article_id), 'content' => mysql_escape_string($content), 'date' => local2gm());
return $prs;
}
示例5: help_content
function help_content(&$a)
{
nav_set_selected('help');
global $lang;
$text = '';
if ($a->argc > 1) {
$text = load_doc_file('doc/' . $a->argv[1] . '.md');
$a->page['title'] = t('Help:') . ' ' . str_replace('-', ' ', notags($a->argv[1]));
}
$home = load_doc_file('doc/Home.md');
if (!$text) {
$text = $home;
$a->page['title'] = t('Help');
} else {
$a->page['aside'] = Markdown($home);
}
if (!strlen($text)) {
header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
$tpl = get_markup_template("404.tpl");
return replace_macros($tpl, array('$message' => t('Page not found.')));
}
$html = Markdown($text);
$html = "<style>.md_warning { padding: 1em; border: #ff0000 solid 2px; background-color: #f9a3a3; color: #ffffff;</style>" . $html;
return $html;
}
示例6: MarkdownFile
/**
* return a parsed version of the Markdown file
* @static
* @throws King23_Exception
* @param string $filename
* @return string
*/
public static function MarkdownFile($filename)
{
if (!file_exists($filename)) {
throw new King23_Exception("could not find {$filename} for Markdown");
}
return Markdown(file_get_contents($filename));
}
示例7: action_docs
public function action_docs()
{
// Get the path for this page
$file = $this->file($page = $this->request->param('page'));
if (!$file) {
throw new Kohana_Exception('User guide page not found: :page', array(':page' => $page));
}
// Set the page title
$this->template->title = $this->title($page);
// Parse the page contents into the template
$this->template->content = Markdown(file_get_contents($file));
// Attach the menu to the template
$this->template->menu = Markdown(file_get_contents($this->file('menu')));
// Bind the breadcrumb
$this->template->bind('breadcrumb', $breadcrumb);
// Get the docs URI
$guide = Route::get('docs/guide');
// Add the breadcrumb
$breadcrumb = array();
$breadcrumb[$guide->uri(array('page' => NULL))] = __('User Guide');
if (strpos($page, '.')) {
list($section) = explode('.', $page);
$breadcrumb[$guide->uri(array('page' => $section))] = $this->title($section);
}
$breadcrumb[] = $this->template->title;
}
示例8: markdownify
static function markdownify($text)
{
if (strpos($text, '<nomarkdown />') !== FALSE) {
return $text;
}
return Markdown($text);
}
示例9: run
function run($string)
{
if (!function_exists('Markdown')) {
include_once EXTENSIONS . '/markdown/lib/markdown.php';
}
return stripslashes(Markdown($string));
}
示例10: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
require_once sfConfig::get('sf_lib_dir') . '/vendor/markdown.php';
$d = file_get_contents(sfConfig::get('sf_root_dir') . '/doc/user_doc_' . $this->getUser()->getCulture() . '.markdown');
$d = htmlentities($d, ENT_QUOTES, 'UTF-8');
$this->body = Markdown($d);
}
示例11: help_display
function help_display($helpname = FALSE)
{
include_once 'plan_read.php';
include_once 'markdown.php';
include_once 'smartypants.php';
if ($helpname) {
if (file_exists("{$_SERVER['HELP_ROOT']}/{$helpname}.help")) {
include_once "{$_SERVER['HELP_ROOT']}/{$helpname}.help";
} else {
$filelist = files_list("{$_SERVER['HELP_ROOT']}/", "*{$helpname}*.help");
if ($filelist) {
include_once "{$_SERVER['HELP_ROOT']}/{$filelist['0']}";
$helpname = str_replace('.help', '', $filelist[0]);
} else {
return FALSE;
}
}
}
if (user_is_valid($_SERVER['USERINFO_ARRAY']['username'], $_SERVER['USERINFO_ARRAY']['userpass'])) {
$editlink = "<a style='font-size: 9pt; font-family: sans-serif; background: #eec; padding: 2px; border: thin solid #eee;' href='{$_SERVER['WEB_ROOT']}/help/edit/{$helpname}'>edit</a>";
} else {
$editlink = '';
}
$content = Smartypants(Markdown(plan_process_directives(plan_add_user_links(plan_process_smileys("<h1><a href='/help'><img src='{$GLOBALS['helpicon']}' /></a> {$title} {$editlink}</h1>\n\n{$body}")))));
if ($title || $body) {
return $content;
} else {
return FALSE;
}
}
示例12: getBio
function getBio()
{
error_log("getBio ", 0);
//Define the bio image header file.
$this->image = "./.." . BIO_DIR . BIO_HEADER;
if (!file_exists($this->image)) {
$this->image = "./" . BIO_DIR . BIO_HEADER;
}
//Define the bio foto header file.
$this->foto = "./.." . BIO_DIR . BIO_FOTO;
if (!file_exists($this->foto)) {
$this->foto = "./" . BIO_DIR . BIO_FOTO;
}
// Define the bio file.
//$fcontents = file("./..".BIO_DIR.BIO_TXT);
if (file_exists("./.." . BIO_DIR . BIO_TXT)) {
$fcontents = file("./.." . BIO_DIR . BIO_TXT);
} else {
$fcontents = file("./" . BIO_DIR . BIO_TXT);
}
// Define the post title.
$this->title = str_replace(array("\n", '#'), '', $fcontents[0]);
// Define the post content
$this->content = Markdown($fcontents[1]);
return $this;
}
示例13: create_object
public function create_object($data)
{
try {
$mc = new \Core\Backend\MemcachedContainer();
$m = $mc->get_backend();
$m_enable = True;
} catch (\Core\Backend\MemcachedNotLoadedError $e) {
}
$data = \Core\Dict::create($data);
if (strlen($data->custom_url) > 0) {
$data->seo_title = $data->custom_url;
} else {
$data->seo_title = strtolower(str_replace(' ', '-', $data->title));
}
if (extension_loaded('discount')) {
$md = \MarkdownDocument::createFromString($data['body']);
$md->compile();
$data['body_html'] = $md->getHtml();
} else {
import('3rdparty.markdown');
$data['body_html'] = Markdown($data['body']);
}
$data->preview = substr(strip_tags($data['body_html']), 0, 440);
$a = Article::create($data)->form_values();
return $a;
}
示例14: diaspora2bb
function diaspora2bb($s)
{
// for testing purposes: Collect raw markdown articles
// $file = tempnam("/tmp/friendica/", "markdown");
// file_put_contents($file, $s);
$s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
// Too many new lines. So deactivated the following line
// $s = str_replace("\r","\n",$s);
// Simply remove cr.
$s = str_replace("\r", "", $s);
// <br/> is invalid. Replace it with the valid expression
$s = str_replace("<br/>", "<br />", $s);
$s = preg_replace('/\\@\\{(.+?)\\; (.+?)\\@(.+?)\\}/', '@[url=https://$3/u/$2]$1[/url]', $s);
// Escaping the hash tags - doesn't always seem to work
// $s = preg_replace('/\#([^\s\#])/','\\#$1',$s);
// This seems to work
$s = preg_replace('/\\#([^\\s\\#])/', '#$1', $s);
$s = Markdown($s);
$s = str_replace('#', '#', $s);
$s = str_replace("\n", '<br />', $s);
$s = html2bbcode($s);
// $s = str_replace('*','*',$s);
// Convert everything that looks like a link to a link
$s = preg_replace("/([^\\]\\=]|^)(https?\\:\\/\\/)([a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url=$2$3]$2$3[/url]', $s);
//$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
$s = preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\[\\/url\\]/ism", '[youtube]$2[/youtube]', $s);
$s = preg_replace("/\\[url\\=https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\].*?\\[\\/url\\]/ism", '[youtube]$1[/youtube]', $s);
$s = preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/vimeo.com\\/([0-9]+)(.*?)\\[\\/url\\]/ism", '[vimeo]$2[/vimeo]', $s);
$s = preg_replace("/\\[url\\=https?:\\/\\/vimeo.com\\/([0-9]+)\\](.*?)\\[\\/url\\]/ism", '[vimeo]$1[/vimeo]', $s);
// remove duplicate adjacent code tags
$s = preg_replace("/(\\[code\\])+(.*?)(\\[\\/code\\])+/ism", "[code]\$2[/code]", $s);
// Don't show link to full picture (until it is fixed)
$s = scale_external_images($s, false);
return $s;
}
示例15: __construct
/**
* Loads a class and uses [reflection](http://php.net/reflection) to parse
* the class. Reads the class modifiers, constants and comment. Parses the
* comment to find the description and tags.
*
* @param string class name
* @return void
*/
public function __construct($class)
{
$this->class = new ReflectionClass($class);
if ($modifiers = $this->class->getModifiers()) {
$this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
}
if ($constants = $this->class->getConstants()) {
foreach ($constants as $name => $value) {
$this->constants[$name] = Kohana::debug($value);
}
}
$parent = $this->class;
do {
if ($comment = $parent->getDocComment()) {
// Found a description for this class
break;
}
} while ($parent = $parent->getParentClass());
list($this->description, $this->tags) = Kodoc::parse($comment);
// If this class extends Kodoc_Missing, add a warning about possible
// incomplete documentation
$parent = $this->class;
while ($parent = $parent->getParentClass()) {
if ($parent->name == 'Kodoc_Missing') {
$warning = "[!!] **This class, or a class parent, could not be\n\t\t\t\t found or loaded. This could be caused by a missing\n\t\t\t\t\t\t module or other dependancy. The documentation for\n\t\t\t\t\t\t class may not be complete!**";
$this->description = Markdown($warning) . $this->description;
}
}
}