本文整理汇总了PHP中Markdown::defaultTransform方法的典型用法代码示例。如果您正苦于以下问题:PHP Markdown::defaultTransform方法的具体用法?PHP Markdown::defaultTransform怎么用?PHP Markdown::defaultTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Markdown
的用法示例。
在下文中一共展示了Markdown::defaultTransform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: previewNoEnclosingPage
/**
* compile markdown to html and render as text
*
* @return Illuminate\View\View
*/
public function previewNoEnclosingPage()
{
$markdown = Markdown::defaultTransform(e(Input::get('data')));
$response = Response::make($markdown);
$response->header('Content-Type', 'text/html');
return $response;
}
示例2: setTemplateFilters
public function setTemplateFilters()
{
//markdown
$this->template->addFilter('md', function ($s) {
return \Michelf\Markdown::defaultTransform($s);
});
//inline markdown
$this->template->addFilter('imd', function ($s) {
return strip_tags(Markdown::defaultTransform($s), '<a><strong><em>');
});
}
示例3: format
public function format($value)
{
$flag = $this->module->flag;
if ($flag == "L") {
return Markdown::defaultTransform(Str::limit($value, $this->listLimit));
}
if ($flag == "R") {
return Markdown::defaultTransform($value);
}
return $value;
}
示例4: toHtml
public function toHtml(array $data)
{
$text = $data['text'];
$html = '<blockquote>';
$html .= Markdown::defaultTransform($text);
// Add the cite if necessary
if (isset($data['cite']) && !empty($data['cite'])) {
// remove the indent thats added by Sir Trevor
$cite = ltrim($data['cite'], '>');
$html .= '<cite>' . Markdown::defaultTransform($cite) . '</cite>';
}
$html .= '</blockquote>';
return $html;
}
示例5: setTemplateFilters
public function setTemplateFilters($template)
{
//markdown
$template->addFilter('md', function ($s) {
return \Michelf\Markdown::defaultTransform($s);
});
//inline markdown
$template->addFilter('imd', function ($s) {
return strip_tags(Markdown::defaultTransform($s), '<a><strong><em>');
});
//stars
$this->template->addFilter('stars', function ($s) {
return \App\Components\ReviewForm::renderRatingStars($s);
});
}
示例6: showMarkitupPreview
function showMarkitupPreview($txtData, $type = "markitup")
{
$htmlData = "";
switch ($type) {
case 'markitup':
require dirname(__FILE__) . "/Michelf/Markdown.inc.php";
//require dirname(__FILE__)."/Michelf/MarkdownExtra.inc.php";
$htmlData = Markdown::defaultTransform($txtData);
break;
default:
$htmlData = $txtData;
break;
}
return $htmlData;
}
示例7: ajaxPublishItem
function ajaxPublishItem($server, $node, $form)
{
$content = $form['content'];
$title = $form['title'];
$geo = false;
if (isset($form['latlonpos']) && $form['latlonpos'] != '') {
list($lat, $lon) = explode(',', $form['latlonpos']);
$pos = json_decode(file_get_contents('http://nominatim.openstreetmap.org/reverse?format=json&lat=' . $lat . '&lon=' . $lon . '&zoom=27&addressdetails=1'));
$geo = array('latitude' => (string) $pos->lat, 'longitude' => (string) $pos->lon, 'altitude' => (string) $pos->alt, 'country' => (string) $pos->address->country, 'countrycode' => (string) $pos->address->country_code, 'region' => (string) $pos->address->county, 'postalcode' => (string) $pos->address->postcode, 'locality' => (string) $pos->address->city, 'street' => (string) $pos->address->path, 'building' => (string) $pos->address->building, 'text' => (string) $pos->display_name, 'uri' => '');
}
if ($content != '') {
$content = Markdown::defaultTransform($content);
$p = new PostPublish();
$p->setFrom($this->user->getLogin())->setTo($server)->setNode($node)->setLocation($geo)->setTitle($title)->setContentHtml(rawurldecode($content))->enableComments()->request();
}
}
示例8: ExplainMarkdown
function ExplainMarkdown($path)
{
$text = file_get_contents($path);
return Markdown::defaultTransform($text);
}
示例9: github_readme_wikipage
/**
* Handler for github_wikipage shortcode.
*
* @param array $atts
*
* @return string
*/
function github_readme_wikipage($atts)
{
$defaults = array('repo' => 'octalmage/GitHub Shortcode', 'trim' => 0, 'cache' => 60, 'page' => '');
shortcode_atts($defaults, $atts, 'github_wikipage');
$repo = empty($atts['repo']) ? $defaults['repo'] : $atts['repo'];
$trim = empty($atts['trim']) ? $defaults['trim'] : abs((int) $atts['trim']);
$cache = empty($atts['cache']) ? $defaults['cache'] : abs((int) $atts['cache']);
$page = empty($atts['page']) ? $defaults['page'] : $atts['page'];
$transient = github_readme_transient_name('github_wikipage_' . $repo . '_' . $page . '_' . $trim . '_' . $cache);
$html = get_transient($transient);
if (false === $html) {
$url = 'https://raw.githubusercontent.com/wiki/' . $repo . '/' . $page . '.md';
$markdown = github_readme_get_url($url);
$markdown = github_readme_trim_markdown($markdown, $trim);
$html = Markdown::defaultTransform($markdown);
set_transient($transient, $html, $cache);
}
return $html;
}
示例10: saveHomepage
/**
* saves user homepage and shows saved homepage page
*
* @return Illuminate\View\View
*/
public function saveHomepage()
{
$profile_markdown = Input::get('data', '');
$profile_data = Markdown::defaultTransform(e($profile_markdown));
$profile_css = Input::get('css', '');
$this->user->saveHomepage(Auth::id(), ['profile_data' => $profile_data, 'profile_markdown' => $profile_markdown, 'profile_css' => $profile_css]);
$sections = $this->section->get();
$section = $this->section->sectionFromEmptySection();
return View::make('page.user.prefs.savedhomepage', ['sections' => $sections, 'section' => $section]);
}
示例11: amend
public function amend($comment_id, $content)
{
$block = new SuccessBlock();
if ($block->success) {
if (Auth::user()->points < 1) {
$block->success = false;
$block->errors[] = 'You need at least one point to edit a comment';
}
}
if ($block->success) {
$comment = $this->findOrFail($comment_id);
if ($comment->user_id != Auth::user()->id) {
$block->success = true;
$block->errors[] = 'This comment does not have the same user id as you';
}
}
if ($block->success) {
$data['user_id'] = Auth::user()->id;
$data['data'] = Markdown::defaultTransform(e($content));
$data['markdown'] = $content;
$rules = array('user_id' => 'required|numeric', 'markdown' => 'required|max:' . Constant::COMMENT_MAX_MARKDOWN_LENGTH);
$validate = Validator::make($data, $rules);
if ($validate->fails()) {
$block->success = false;
foreach ($validate->messages()->all() as $v) {
$block->errors[] = $v;
}
}
}
if ($block->success) {
$history = new History();
$history->data = $comment->data;
$history->markdown = $comment->markdown;
$history->user_id = Auth::user()->id;
$history->type = Constant::COMMENT_TYPE;
$history->type_id = $comment->id;
$history->save();
Cache::forget(Constant::COMMENT_CACHE_NEWLIST_NAME . $comment->post_id);
$comment->markdown = $data['markdown'];
$comment->data = $data['data'];
$comment->save();
}
return $block;
}
示例12: prepareData
public function prepareData($data)
{
if (empty($data['data']) && empty($data['url'])) {
$data['type'] = 1;
} else {
if (!empty($data['data']) && !empty($data['url'])) {
$data['type'] = 0;
} else {
if (!empty($data['data'])) {
$data['type'] = 1;
} else {
if (!empty($data['url'])) {
$data['type'] = 0;
}
}
}
}
$data['title'] = e($data['title']);
$data['url'] = e($data['url']);
$data['markdown'] = $data['data'];
$data['data'] = Markdown::defaultTransform(e($data['markdown']));
return $data;
}
示例13: toHtml
public function toHtml(array $data)
{
return Markdown::defaultTransform('## ' . $data['text']);
}
示例14: markdown_mk2html
function markdown_mk2html(&$post)
{
$post->Content = Markdown::defaultTransform($post->Content);
$post->Intro = Markdown::defaultTransform($post->Intro);
}
示例15: markdown
public static function markdown($text)
{
if (!class_exists('Markdown')) {
require Kohana::find_file('vendor', 'markdown/Markdown');
}
return Markdown::defaultTransform($text);
}