public static function create(Document $data, string $url) : Article { $article = new static(); $article->title = $data->matter('title', ''); $article->contents = markdown($data->body()); $article->description = $data->matter('description', ''); $article->date = Carbon::createFromFormat('d/m/Y', $data->matter('date', '01/02/1992')); $article->era = $data->matter('era', ''); $article->commentable = $data->matter('comments', true); $article->url = $url; return $article; }
function odc_display_content($request_tag = "default", $anypage = FALSE) { $tag = strtolower($request_tag); $page = strtolower($_SERVER['SCRIPT_NAME']); // now check for/get content from the database... if ($anypage) { $sql = 'SELECT content,markdown FROM odc WHERE tag="' . $tag . '" AND page="any";'; } else { $sql = 'SELECT content,markdown FROM odc WHERE tag="' . $tag . '" AND page="' . $page . '";'; } $rows = odc_my_query($sql); $content = mysql_fetch_assoc($rows); if (empty($content)) { // call function to create new content-stub if there is none odc_new($tag, $anypage); } else { // print out content if ($content['markdown'] > 0) { require_once $GLOBALS['MD_file']; echo markdown($content['content']); } else { echo $content['content']; } } // just for debugging, return nothing normally... //return "Tag: ".$tag." Page: ".$page; return; }
function _process($items, $return_single = FALSE) { $this->load->helper('url'); if ($items) { foreach ($items as $key => $value) { $new_item = new Sweetcron_item(); //item feed components $new_item->feed_id = $items[$key]->feed_id; $new_item->feed_title = $items[$key]->feed_title; $new_item->feed_icon = $items[$key]->feed_icon; $new_item->feed_url = $items[$key]->feed_url; $new_item->feed_data = $items[$key]->feed_data; $new_item->feed_status = $items[$key]->feed_status; $new_item->feed_domain = $items[$key]->feed_domain; //standard item components $new_item->ID = $items[$key]->ID; $new_item->item_date = $items[$key]->item_date; //autolinks $new_item->item_content = auto_link($items[$key]->item_content); $new_item->item_content = markdown($new_item->item_content); $new_item->item_title = auto_link($items[$key]->item_title); $new_item->item_original_permalink = $items[$key]->item_permalink; $new_item->item_permalink = $this->config->item('base_url') . 'items/view/' . $new_item->ID; $new_item->item_status = $items[$key]->item_status; $new_item->item_name = $items[$key]->item_name; $new_item->item_data = unserialize($items[$key]->item_data); $new_item->item_tags = $this->get_tags($items[$key]->ID); //make adjustments if blog post if (!$items[$key]->feed_id) { $new_item->feed_icon = '/favicon.ico'; $url = parse_url($this->config->item('base_url')); if (substr($url['host'], 0, 4) == 'www.') { $new_item->feed_domain = substr($url['host'], 4); } else { $new_item->feed_domain = $url['host']; } } $new_item->feed_class = str_replace('.', '_', $new_item->feed_domain); //extended item components if ($new_item->feed_id) { $new_item = $this->sweetcron->extend('pre_display', $new_item->feed_domain, $new_item); } //custom item components $new_item->nice_date = timespan($items[$key]->item_date); if ($new_item->item_date < strtotime('1 day ago')) { $new_item->human_date = date('F j Y, g:ia', $items[$key]->item_date); } else { $new_item->human_date = $new_item->nice_date . ' ago'; } $items[$key] = $new_item; } if ($return_single) { return $items[0]; } else { return $items; } } else { return false; } }
public function setBody($v) { parent::setBody($v); require_once 'markdown.php'; // strip all HTML tags $v = htmlentities($v, ENT_QUOTES, 'UTF-8'); $this->setHtmlBody(markdown($v)); }
function get() { $text = preg_replace_callback('!(?=[^\\]])\\((' . implode('|', $this->tags) . '):(.*?)\\)!i', array($this, 'parse'), (string) $this->text); $text = preg_replace_callback('!```(.*?)```!is', array($this, 'code'), $text); $text = $this->mdown ? markdown($text) : $text; $text = $this->smartypants ? smartypants($text) : $text; return $text; }
function kirbytext($text, $markdown = true) { $text = kirbytext::get($text); if ($markdown) { $text = markdown($text); } return $text; }
protected function acquireData($params, $userRec) { $data = parent::acquireData($params, $userRec); $data['config']['google_maps_api_key'] = GOOGLE_MAPS_API_KEY; for ($i = 1; $i <= 7; $i++) { $data['help'][] = markdown(file_get_contents('./help_doc_' . $i . '.markdown.text')); } return $data; }
/** * Transform single resource. * * @param \App\Article $article * @return array */ public function transform(Article $article) { $id = optimus((int) $article->id); $payload = ['id' => $id, 'title' => $article->title, 'content_raw' => strip_tags($article->content), 'content_html' => markdown($article->content), 'created' => $article->created_at->toIso8601String(), 'view_count' => (int) $article->view_count, 'link' => ['rel' => 'self', 'href' => route('api.v1.articles.show', $id)], 'comments' => (int) $article->comments->count(), 'author' => ['name' => $article->author->name, 'email' => $article->author->email, 'avatar' => 'http:' . gravatar_profile_url($article->author->email)], 'tags' => $article->tags->pluck('slug'), 'attachments' => (int) $article->attachments->count()]; if ($fields = $this->getPartialFields()) { $payload = array_only($payload, $fields); } return $payload; }
/** * Transform single resource. * * @param \App\Comment $comment * @return array */ public function transform(Comment $comment) { $id = optimus((int) $comment->id); $payload = ['id' => $id, 'content_raw' => strip_tags($comment->content), 'content_html' => markdown($comment->content), 'created' => $comment->created_at->toIso8601String(), 'vote' => ['up' => (int) $comment->up_count, 'down' => (int) $comment->down_count], 'link' => ['rel' => 'self', 'href' => route('api.v1.comments.show', $id)], 'author' => ['name' => $comment->author->name, 'email' => $comment->author->email, 'avatar' => 'http:' . gravatar_profile_url($comment->author->email)]]; if ($fields = $this->getPartialFields()) { $payload = array_only($payload, $fields); } return $payload; }
function format($text) { $text = markdown($text); $text = smartypants($text); $search = array("<table>", "</table>"); $replace = array("<figure class='table'><table>", "</table></figure>"); $text = str_replace($search, $replace, $text); return $text; }
/** * Get the given documentation page. * * @param string $version * @param string $page * @return string */ public function get($version, $page) { return $this->cache->remember('docs.' . $version . '.' . $page, 5, function () use($version, $page) { $path = base_path('resources/docs/' . $page . '.md'); if ($this->files->exists($path)) { return $this->replaceLinks($version, markdown($this->files->get($path))); } return null; }); }
function lang_markdown($name) { include __DIR__ . "/../res/markdown.php"; $output = lang($name); if ($output != null) { return markdown($output); } else { return null; } }
/** * Show document page in response to the given $file. * * @param string $file * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function show($file = '01-welcome.md') { $index = Cache::remember('documents.index', 120, function () { return markdown($this->document->get()); }); $content = Cache::remember("documents.{$file}", 120, function () use($file) { return markdown($this->document->get($file)); }); return view('documents.index', compact('index', 'content')); }
public function executeAbout() { require_once 'markdown.php'; $file = sfConfig::get('sf_data_dir') . '/content/about_' . $this->getUser()->getCulture() . '.txt'; if (!is_readable($file)) { $file = sfConfig::get('sf_data_dir') . '/content/about_en.txt'; } $this->html = markdown(file_get_contents($file)); $this->getResponse()->setTitle('askeet! » about'); }
public function update(UpdateReply $request, $id) { $reply = Reply::findOrFail($id); $mention = new Mention(); $data = $request->all(); $reply->body_original = $data['body']; $data['body'] = $mention->parse($data['body']); $reply->body = markdown($data['body']); $reply->save(); flash()->success('Pranešimas sėkmingai atnaujintas!'); return redirect()->route('topic.show', [$reply->topic->slug]); }
/** * Get the given documentation page. * * @param string $version * @param string $page * * @return string */ public function get($version, $page) { return $this->cache->remember('docs.' . $version . '.' . $page, $this->cacheTime, function () use($version, $page) { $path = $this->fullPagePath($version, $page); if ($this->files->exists($path)) { $content = $this->replaceLinks($version, markdown($this->files->get($path))); $title = $content ? $this->getDocTitleByContent($content) : null; return compact('content', 'title'); } return null; }); }
/** * Converts the code to HTML * * @param File $file File to render * @param Tool_Result $res Tool result to integrate * * @return string HTML */ public function toHtml(File $file, Tool_Result $res = null) { if (class_exists('\\Michelf\\Markdown', true)) { //composer-installed version 1.4+ $markdown = \Michelf\Markdown::defaultTransform($file->getContent()); } else { //PEAR-installed version 1.0.2 has a different API require_once 'markdown.php'; $markdown = \markdown($file->getContent()); } return '<div class="markdown">' . $markdown . '</div>'; }
/** * Get the given documentation page. * * @param string $version * @param string $page * @return string */ public function get($version, $page) { // If the enviroment is local forget the cache if (app()->environment() == 'local') { $this->cache->forget('docs.' . $version . '.' . $page); } return $this->cache->remember('docs.' . $version . '.' . $page, 5, function () use($version, $page) { $path = base_path('resources/docs/' . $version . '/' . $page . '.md'); if ($this->files->exists($path)) { return $this->replaceLinks($version, markdown($this->files->get($path))); } return null; }); }
/** * retrieves and parses file for output * * @return string * @param $file Base name of file to parse */ public function outputFile($infile) { require_once 'markdown.php'; $hostPrefix = '/content/'; if (preg_match('/^sandbox/', $this->getRequest()->getHost())) { $hostPrefix .= 'sandbox_'; } $fileRoot = sfConfig::get('sf_data_dir') . $hostPrefix . $infile . '_'; $file = $fileRoot . $this->getUser()->getCulture() . '.txt'; if (!is_readable($file)) { $file = $fileRoot . '_en.txt'; } $this->html = markdown(file_get_contents($file)); $this->getContext()->getResponse()->setTitle(sfConfig::get('app_title_prefix') . $infile); }
function smarty_modifier_wikimarkdown($string) { require_once 'modifier.markdown.php'; global $purifier; $string = stripslashes($string); $znaki = "[a-zA-Z0-9ąśćęłńóśżźĄŚĆĘŁŃÓŚŻŹ\\-\\_\\.: \\/]"; // {html}....{/html} // $string=preg_replace("/{html}(.*?){\/html}/me","wm_rawhtml('\\1')",$string); $string = markdown($string); $string = preg_replace("/\\[({$znaki}+)\\]([^\\(])/e", "''.wm_href('\\1').'\\2'", $string); // "'<a href=\"'.Wiki::urlifyParts('\\1').'\">'.wm_lastpart('\\1').'</a>\\2'",$string); // [tekst|katalog/odnosnik] $string = preg_replace("/\\[({$znaki}+)\\|({$znaki}+)\\]/e", "''.wm_href('\\1','\\2').''", $string); $string = $purifier->purify($string); return $string; }
protected function index() { global $config; $pkg = new Packager($config['packages']); $data = array(); foreach ($pkg->get_packages() as $package) { $data[$package] = array('files' => array(), 'package' => $package, 'package_web' => markdown($pkg->get_package_web($package)), 'package_authors' => markdown(implode(' & ', $pkg->get_package_authors($package))), 'package_description' => markdown($pkg->get_package_description($package)), 'package_license' => markdown($pkg->get_package_license($package)), 'package_copyright' => markdown($pkg->get_package_copyright($package))); foreach ($pkg->get_all_files($package) as $file) { $file_meta = array('name' => $pkg->get_file_name($file), 'depends' => implode(', ', $pkg->get_file_dependancies($file)), 'provides' => implode(', ', $pkg->get_file_provides($file)), 'description' => markdown($pkg->get_file_description($file))); $data[$package]['files'][$file] = $file_meta; } } $this->data('packages', $data); $this->data('config', $config['view']); $this->render($config['view']['theme']); }
function out($dirty, $filter_method = 'toHtml', $echo = false, $links = true) { if ($filter_method == 'toHtml') { $res = htmlentities($dirty); } else { $filter = new Filter(); $res = $filter->{$filter_method}($dirty); } if ($links) { // Render http:// sections as links. $res = replace_urls($res); } $res = markdown($res); if (!$echo) { return $res; } echo $res; }
public function parse() { if (!$this->field) { return ''; } $val = $this->field->value; // pre filters foreach (static::$pre as $filter) { $val = call_user_func_array($filter, array($this, $val)); } // tags $val = preg_replace_callback('!(?=[^\\]])\\([a-z0-9]+:.*?\\)!i', array($this, 'tag'), $val); // markdownify $val = markdown($val); // post filters foreach (static::$post as $filter) { $val = call_user_func_array($filter, array($this, $val)); } return $val; }
function out($dirty, $filter_callback = 'toHtml', $echo = false, $links = true) { if ($filter_callback == 'toHtml') { $res = htmlentities($dirty); } else { $res = $dirty; if ($filter_callback && function_exists($filter_callback)) { $res = $filter_callback($dirty); } } if ($links) { // Render http:// sections as links. $res = replace_urls($res); } $res = markdown($res); if (!$echo) { return $res; } echo $res; }
public function parse() { if (!$this->field) { return ''; } $text = $this->field->value; // pre filters foreach (static::$pre as $filter) { $text = call_user_func_array($filter, array($this, $text)); } // tags $text = preg_replace_callback('!(?=[^\\]])\\([a-z0-9]+:.*?\\)!i', array($this, 'tag'), $text); // markdownify $text = markdown($text); // smartypants if (kirby()->option('smartypants')) { $text = smartypants($text); } // post filters foreach (static::$post as $filter) { $text = call_user_func_array($filter, array($this, $text)); } return $text; }
Cookie::queue('docs_version', '4.1', 525600); return Redirect::back(); }); Route::get('docs/4-2', function () { Cookie::queue('docs_version', '4.2', 525600); return Redirect::back(); }); /** * Main Documentation Route... */ Route::get('docs/{page?}', function ($page = null) { if (is_null($page)) { $page = 'introduction'; } $index = Cache::remember('docs.' . DOCS_VERSION . '.index', 5, function () { return markdown(file_get_contents(base_path() . '/docs/' . DOCS_VERSION . '/documentation.md')); }); $contents = Cache::remember('docs.' . DOCS_VERSION . '.' . $page, 5, function () use($page) { if (file_exists($path = base_path() . '/docs/' . DOCS_VERSION . '/' . $page . '.md')) { return markdown(file_get_contents($path)); } else { return 'Not Found'; } }); if ($contents == 'Not Found') { return Redirect::to('docs'); } // @todo: Remove duplication between this and the array above $docs_versions = ['master' => ['title' => 'Dev', 'url_key' => 'dev'], '4.2' => ['title' => '4.2', 'url_key' => '4-2'], '4.1' => ['title' => '4.1', 'url_key' => '4-1'], '4.0' => ['title' => '4.0', 'url_key' => '4-0']]; return View::make('layouts.docs', compact('index', 'contents', 'docs_versions')); });
/** * Returns the comment description. You can pass it an array of formatting parameters which include: <ul> <li><strong>markdown:</strong> applies the <a href="[user_guide_url]helpers/markdown_helper">markdown</a> function </li> <li><strong>short:</strong> filters just the first paragraphs of the description if multiple paragraphs </li> <li><strong>long:</strong> returns the entire description</li> <li><strong>one_line:</strong> filters the description to appear on one line by removing returns</li> <li><strong>entities:</strong> converts html entities</li> <li><strong>eval:</strong> evaluates php code</li> <li><strong>periods:</strong> adds periods at the end of lines that don't have them</li> <li><strong>ucfirst:</strong> uppercases the first word</li> </ul> * * @access public * @param int The index (order) of the parameter to retrieve * @param string The part of the parameter to retrieve. Options are 'type' and 'comment' * @return boolean */ public function description($format = FALSE) { if (!isset($this->_description)) { preg_match('#/\\*\\*\\s*(.+ )(@|\\*\\/)#Ums', $this->_text, $matches); if (isset($matches[1])) { $this->_description = $matches[1]; // removing preceding * and tabs $this->_description = preg_replace('#\\* *#m', "", $matches[1]); $this->_description = preg_replace("#^ +#m", "", $this->_description); // remove code examples since they are handled by the example method $this->_description = preg_replace('#<code>.+</code>#ms', '', $this->_description); $this->_description = trim($this->_description); } else { $this->_description = $this->_text; } } $desc = $this->_description; $desc = $this->filter($desc); // apply different formats if ($format) { if (is_string($format)) { $format = (array) $format; } foreach ($format as $f) { switch (strtolower($f)) { case 'markdown': // must escape underscores to prevent <em> tags $desc = str_replace('_', '\\_', $desc); $desc = markdown($desc); // the we replace back any that didn't get processed'(e.g. ones inside links) $desc = str_replace('\\_', '_', $desc); break; case 'short': $desc_lines = explode(PHP_EOL, $desc); $first_line = TRUE; foreach ($desc_lines as $d) { if (!empty($d)) { if ($first_line) { $first_line = FALSE; $desc = $d; break; } } } break; case 'long': $desc_lines = explode(PHP_EOL, $desc); $new_desc = ''; $first_line = TRUE; foreach ($desc_lines as $d) { if (!empty($d)) { if ($first_line) { $first_line = FALSE; continue; } else { $new_desc .= $d . ' '; } } else { if (!$first_line) { $new_desc .= "\n\n"; } } } $desc = $new_desc; break; case 'one_line': $desc = str_replace(PHP_EOL, ' ', $desc); break; case 'entities': $desc = htmlentities($desc); break; case 'eval': $desc = eval_string($desc); break; case 'periods': $desc_lines = explode(PHP_EOL, $desc); $lines = ''; $past_first = FALSE; foreach ($desc_lines as $d) { $d = trim($d); if (!empty($d)) { if (!$past_first) { $d = preg_replace('#(.+[^\\.|>]\\s*)$#', '$1. ', $d); } $lines .= $d . ' '; $past_first = TRUE; } else { if ($past_first) { $lines .= "\n\n"; } } } $lines = preg_replace('#(.+[^\\.|>]\\s*)$#', '$1. ', trim($lines)); $desc = $lines; case 'ucfirst': $desc = ucfirst($desc); break; } } } // auto link $desc = auto_link($desc); // trim white space $desc = trim($desc); // clean $desc = xss_clean($desc); $desc = strip_image_tags($desc); return $desc; }
$output = $start; if($infopath == "/"){ $infopath = ""; } if(strstr($page, ".md") || $markdown_disabled){ if(!$markdown_disabled){ $config["md_switch"] = '<a href="'.$infopath.str_replace(".md", "", $page).'" title="View Markup">⇡</a>'; } $output .= "<pre>"; $output .= $header."\n\n"; $output .= htmlspecialchars($content); $output .= "\n\n".$footer; $output .= "</pre>"; } else { if(!$markdown_disabled){ $config["md_switch"] = '<a href="'.$infopath.$page.'.md" title="View Markdown">⇣</a>'; } $output .= markdown($header); $output .= markdown($content); $output .= markdown($footer); $output .= $hidden_tag_list; } $output .= $end; ?>
<?php // Dm test post : Show // Vars : $dmTestPost echo _open('div.dm_test_post.show'); echo _tag('h1', $dmTestPost), _tag('p.user', $dmTestPost->Author) . _tag('p.excerpt', $dmTestPost->excerpt) . _tag('div.body', markdown($dmTestPost->body)) . _tag('p.url', _link($dmTestPost->url)) . _tag('p.categ', _link($dmTestPost->Categ)) . _tag('p.image', _media($dmTestPost->Image)->size(200, 200)) . _tag('p.file', _link($dmTestPost->File)) . _tag('p.date', $dmTestPost->date); echo _close('div');
echo _open('div.body.recurso'); // Wrap the title in a H1 echo _tag('h1.t_big', 'Título: ' . $patente->titulo); // Open a P tag to display some article infos if ($patente->createdBy) { echo _tag('p.recurso_infos', _tag('span', 'Creado el: ' . format_date($patente->createdAt, 'D')) . ' | ' . _tag('span', 'Creado por: ' . $patente->createdBy)); } else { echo _tag('p.recurso_infos', _tag('span', 'Creado el: ' . format_date($patente->createdAt, 'D')) . ' | ' . _tag('span', 'Creado por: ' . $patente->updatedBy)); } // render the article image. // scale it to 200px width and height. // give it the "image" CSS class. //echo _media($article->Image)->size(200, 200)->set('.image'); // render article body processed with markdown. if ($patente->resumen) { echo _tag('span.descriptor', 'Resumen: ' . _tag('span.recurso_list', markdown($patente->resumen, '.resumen'))); } else { echo _tag('p.descriptor_rojo', 'Sin resumen'); } echo _open('p'); echo _tag('span.descriptor', 'Palabras claves: ' . _tag('span.recurso_list', $patente->palabras_claves)); echo _close('p'); echo _open('p'); echo _tag('span.descriptor', 'País: ' . _tag('span.recurso_list', $patente->pais)); echo _close('p'); echo _open('p'); echo _tag('span.descriptor', 'Institución: ' . _tag('span.recurso_list', $patente->institucion)); echo _close('p'); echo _open('p'); echo _tag('span.descriptor', 'No. de publicación: ' . _tag('span.recurso_list', $patente->num_internacional)); echo _close('p');