public function parseMarkdown($content) { $parser = new GithubMarkdown(); $parser->enableNewlines = true; return $parser->parse($content); // Parser markdown }
public function getDbPrepValue() { $parser = new GithubMarkdown(); $parser->enableNewlines = true; $parser->html5 = true; return (string) $parser->parse($this->value); }
public function getContent() { $doc = Parser::parse(file_get_contents($this->url)); $parser = new GithubMarkdown(); $parser->enableNewLines = true; return $parser->parse($doc->getContent()); }
public function postProcess($post) { $parser = new GithubMarkdown(); $parser->html5 = true; $parser->enableNewlines = true; $parser->keepListStartNumber = true; return $parser->parse($post); }
/** * Get HTML mail part from ID * @param string $title * @param string $body * @paramn string $template_path * @return string $html */ public function getEmailHtml($title, $body, $template_path = null) { $template = $this->getHtmlTemplate($template_path); if ($this->titleInBody) { $body = "# " . $title . PHP_EOL . PHP_EOL . $body; } $parser = new GithubMarkdown(); $body = $parser->parse($body); $subject = html::specialEncode($title); $str = str_replace(array('{title}', '{content}'), array($subject, $body), $template); return $str; }
/** * @inheritdoc */ protected function renderLink($block) { $result = parent::renderLink($block); // add special syntax for linking to the guide $result = preg_replace_callback('/href="guide:([A-z0-9-.#]+)"/i', function ($match) { return 'href="' . static::$renderer->generateGuideUrl($match[1]) . '"'; }, $result, 1); return $result; }
/** * @inheritdoc */ protected function parseLink($markdown) { list($result, $skip) = parent::parseLink($markdown); // add special syntax for linking to the guide $result = preg_replace_callback('/href="guide:([A-z0-9-.#]+)"/i', function ($match) { return 'href="' . static::$renderer->generateGuideUrl($match[1]) . '"'; }, $result, 1); return [$result, $skip]; }
/** * @inheritdoc */ protected function renderLink($block) { $result = parent::renderLink($block); // add special syntax for linking to the guide $result = preg_replace_callback('/href="([A-z0-9-.#]+).md"/i', function ($match) { return 'href="/docs/' . $match[1] . '"'; }, $result, 1); return $result; }
public function youtubeDescriptionAsHtml() { $parser = new GithubMarkdown(); return $parser->parse(array_get($this->youtube_meta, 'description')); }
/** * Humanizes github Readme.md file content * We adopt github retrieves Readme.md as json string where "content" field contains base64 encoded markdown * @param $data * @return string */ public static function humanizeReadme($data) { $readme = ''; $data = Json::decode($data); if (false === empty($data['content'])) { $content = base64_decode(str_replace('\\n', '', $data['content'])); $parser = new GithubMarkdown(); $readme = $parser->parse($content); } return $readme; }
/** * {@inheritdoc} */ public function run($markdown = '') { return $this->markdown->parse($markdown); }
protected function inlineMarkers() { return array_merge(parent::inlineMarkers(), ['[[' => 'parseApiLinks']); }
echo $form->field($model, 'username'); ?> <?php echo $form->field($model, 'email'); ?> <?php echo $form->field($model, 'email_repeat'); ?> <?php echo $form->field($model, 'password')->passwordInput(); ?> <?php echo $form->field($model, 'password_repeat')->passwordInput(); ?> <div class="form-group"> <?php echo Html::submitButton('Зарегистрироватся', ['class' => 'btn btn-primary', 'name' => 'signup-button']); ?> </div> <?php ActiveForm::end(); ?> </div> </div> <?php Modal::begin(['id' => 'rulesModal', 'header' => '<h4 class="modal-title"><strong>Правила на сайте</strong></h4>']); $parser = new GithubMarkdown(); echo $parser->parse($rules->content); Modal::end();
/** * Parse content using Markdown * @param string $content * @return string */ private function parse_markdown($content) { $parser = new GithubMarkdown(); $parser->enableNewlines = true; return $parser->parse($content); }
<?php echo Html::a($data->title, ['#']); ?> <br/> <span class="hint-block small">Категория: <?php echo $data->category->title; ?> </span> </span> <?php echo Html::img(Yii::$app->request->baseUrl . $data->anons_img, ['class' => 'img-responsive article_anons_img']); ?> <div class="article_anons"> <?php $parser = new GithubMarkdown(); echo $parser->parse($data->anons); ?> </div> <div class="article_content"> <?php echo $parser->parse($data->post); ?> </div> <div class="article_config"> <i class="glyphicon glyphicon-calendar"></i> <?php echo Yii::$app->formatter->asDate($data->created_at); ?> | <i class="glyphicon glyphicon-user" title="Кто создал"></i> <?php echo Html::encode($data->author->username);
/** * Add bootstrap classes to tables. * @inheritdoc */ public function renderTable($block) { return str_replace('<table>', '<table class="table table-bordered table-striped">', parent::renderTable($block)); }
public function handle() { $channelTitle = 'Realfagsbiblioteket'; $channelShortDescription = 'Videoer om vitenskap'; $channelDescription = 'Vitenskap formidlet fra scenen i Realfagsbiblioteket. Realfagsbiblioteket er Norges største f*g- og forskningsbibliotek innen fagområdene fagområdene fysikk, astrofysikk, biofag, farmasi, geofag, kjemi, informatikk og matematikk.'; $channelUrl = 'https://www.ub.uio.no/om/aktuelt/arrangementer/ureal/'; $channelAuthor = 'Realfagsbiblioteket'; $channelAuthorEmail = '*****@*****.**'; $channelImage = 'http://titan.uio.no/sites/default/files/thumbnails/image/realfagsbiblioteket_topp_titan.png'; $parser = new GithubMarkdown(); $writer = new \XMLWriter(); $writer->openMemory(); $writer->startDocument('1.0', 'UTF-8'); $writer->setIndent(true); $writer->setIndentString(' '); $writer->startElement('rss'); $writer->writeAttribute('version', '2.0'); $writer->writeAttribute('xmlns:media', 'http://search.yahoo.com/mrss/'); $writer->writeAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom'); $writer->writeAttribute('xmlns:dct', 'http://dublincore.org/documents/2012/06/14/dcmi-terms/'); $writer->writeAttribute('xmlns:itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd'); $writer->startElement('channel'); $writer->writeElement('title', $channelTitle); $writer->writeElement('link', $channelUrl); $writer->writeElement('description', $channelDescription); $writer->writeElement('itunes:subtitle', $channelShortDescription); $writer->writeElement('itunes:author', $channelAuthor); $writer->writeElement('itunes:summary', $channelDescription); $writer->startElement('itunes:owner'); $writer->writeAttribute('itunes:name', $channelAuthor); $writer->writeAttribute('itunes:email', $channelAuthorEmail); $writer->writeAttribute('href', 'https://www.ub.uio.no/om/aktuelt/arrangementer/ureal/feed-til-titan.xml'); $writer->endElement(); $writer->startElement('itunes:image'); $writer->writeAttribute('href', $channelImage); $writer->endElement(); $writer->startElement('atom:link'); $writer->writeAttribute('rel', 'self'); $writer->writeAttribute('type', 'application/rss+xml'); $writer->writeAttribute('href', 'https://www.ub.uio.no/om/aktuelt/arrangementer/ureal/feed-til-titan.xml'); $writer->endElement(); $lastModified = Carbon::createFromDate(2000, 1, 1); foreach (Recording::with('presentation', 'presentation.event')->orderBy('recorded_at', 'desc')->get() as $video) { if (!$video->presentation) { continue; } $event = $video->presentation->event; if (count($event->presentations) != 1) { continue; } $body = $parser->parse($event->intro); $body = str_replace('<hr />', '', $body); $primaryResource = null; foreach ($event->resources as $resource) { if ($resource->filetype == 'image') { $primaryResource = $resource; } } $mp4Url = null; $mp4filesize = 0; $writer->startElement('item'); $writer->startElement('guid'); $writer->writeAttribute('isPermaLink', 'false'); $writer->writeRaw($event->uuid); $writer->endElement(); //$event->start_date . ' ' . $video->presentation->start_time $writer->writeElement('pubDate', $video->presentation->getStartDateTime()->toRssString()); $writer->writeElement('dct:created', $video->presentation->getStartDateTime()->toIso8601String()); $writer->writeElement('dct:modified', $event->updated_at->toIso8601String()); $writer->writeElement('dct:language', $video->language); $writer->writeElement('title', $event->title); // $writer->writeElement('recordDate', $video->recorded_at); // $writer->writeElement('bodyLength', mb_strlen($body)); $writer->startElement('description'); $writer->writeCData($body); $writer->endElement(); $content = '<iframe width="560" height="315" src="https://www.youtube.com/embed/' . $video->youtube_id . '" frameborder="0" allowfullscreen></iframe>'; $writer->startElement('content'); $writer->writeCData($content); $writer->endElement(); $writer->startElement('media:embed'); // ??? $writer->writeAttribute('url', $video->youtubeLink('embed')); $writer->endElement(); if (!is_null($mp4Url)) { $writer->startElement('enclosure'); $writer->writeAttribute('url', $mp4Url); $writer->writeAttribute('length', $mp4filesize); $writer->writeAttribute('type', 'video/mp4'); } if (!is_null($primaryResource)) { $writer->startElement('media:content'); $writer->writeAttribute('url', $primaryResource->url('webdav')); $writer->writeAttribute('width', $primaryResource->width); $writer->writeAttribute('height', $primaryResource->height); $writer->writeAttribute('type', 'image/jpeg'); // $writer->writeElement('attribution', $primaryResource->attribution); // Se: http://www.rssboard.org/media-rss#media-license //$writer->writeElement('media:license', $primaryResource->license); $writer->endElement(); } if ($event->updated_at > $lastModified) { $lastModified = $event->updated_at; } $writer->endElement(); } $writer->writeElement('dct:modified', $lastModified->toIso8601String()); $writer->writeElement('lastBuildDate', $lastModified->toIso8601String()); $writer->endElement(); $writer->endDocument(); echo $writer->outputMemory(); }
public function descriptionAsHtml() { $parser = new GithubMarkdown(); return $parser->parse($this->description); }
public function __invoke(Filter $node, Compiler $compiler) { $parser = new Parser(); return $parser->parseParagraph($this->getNodeString($node, $compiler)); }
<?php echo Html::a($model->title, $model->getArticleUrl()); ?> <br/> <span class="hint-block small">Категория: <?php echo $model->category->title; ?> </span> </span> <?php echo Html::img(Yii::$app->request->baseUrl . $model->anons_img, ['class' => 'img-responsive article_anons_img']); ?> <div class="article_anons"> <?php $parser = new GithubMarkdown(); echo $parser->parse($model->anons); ?> </div> <div class="article_content"> <?php echo $parser->parse($model->post); ?> </div> <div class="article_config"> <i class="glyphicon glyphicon-calendar"></i> <?php echo Yii::$app->formatter->asDate($model->created_at); ?> | <i class="glyphicon glyphicon-user" title="Кто создал"></i> <?php echo Html::encode($model->author->username);
/** * @inheritdoc */ protected function renderCode($block) { if (self::$highlighter === null) { self::$highlighter = new Highlighter(); self::$highlighter->setAutodetectLanguages(['apache', 'nginx', 'bash', 'dockerfile', 'http', 'css', 'less', 'scss', 'javascript', 'json', 'markdown', 'php', 'sql', 'twig', 'xml']); } try { if (isset($block['language'])) { $result = self::$highlighter->highlight($block['language'], $block['content'] . "\n"); return "<pre><code class=\"hljs {$result->language} language-{$block['language']}\">{$result->value}</code></pre>\n"; } else { $result = self::$highlighter->highlightAuto($block['content'] . "\n"); return "<pre><code class=\"hljs {$result->language}\">{$result->value}</code></pre>\n"; } } catch (DomainException $e) { echo $e; return parent::renderCode($block); } }
/* @var $this yii\web\View */ /* @var $language common\models\Language */ /* @var $snippet common\models\Snippet */ use yii\helpers\Html; use cebe\markdown\GithubMarkdown; use common\models\SnippetComment; use common\models\Bookmark; use yii\bootstrap\ActiveForm; $this->title = $snippet->name; $geshi = new GeSHi($snippet->code, $language->renderCode); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->set_header_type(GESHI_HEADER_DIV); $geshi->set_tab_width(4); $geshiCode = $geshi->parse_code(); $markdown = new GithubMarkdown(); $markdown->html5 = true; $markdown->enableNewlines = true; $comments = SnippetComment::find()->where(['snippetId' => $snippet->id])->with('member')->orderBy('createdTime ASC')->all(); $hasBookmarked = false; if ($this->context->member) { $hasBookmarked = Bookmark::find()->where(['memberId' => $this->context->member->id, 'snippetId' => $snippet->id])->count(); } if (!$this->context->member && $this->context->params['registrationsOpen']) { ?> <span class="bookmark"> <a href="/login?r=<?php echo $_SERVER['REQUEST_URI']; ?> " title="Login and return here">Login</a> or
/** * Make auto-linked URLs use the rel="noreferrer" attribute * * @param $markdown * @return array */ protected function parseUrl($markdown) { $array = parent::parseUrl($markdown); $array[0] = $this->addNoReferrerAttribute($array[0]); return $array; }
<?php namespace Project; require '../../header.php'; require "../../vendor/autoload.php"; require '../../include/config.php'; use cebe\markdown\GithubMarkdown; use Slim\Slim; use stdClass, Oda\SimpleObject\OdaPrepareInterface, Oda\SimpleObject\OdaPrepareReqSql, Oda\OdaLibBd; $slim = new Slim(); //-------------------------------------------------------------------------- $slim->notFound(function () { $params = new OdaPrepareInterface(); $INTERFACE = new OdaRestInterface($params); $INTERFACE->dieInError('not found'); }); $slim->get('/', function () { $markdown = file_get_contents('./doc.markdown', true); $parser = new GithubMarkdown(); echo $parser->parse($markdown); }); $slim->get('/entity/:id', function ($id) use($slim) { $params = new OdaPrepareInterface(); $params->slim = $slim; $INTERFACE = new EntityInterface($params); $INTERFACE->get($id); }); $slim->run();
/** * Parse markdown to HTML, similar to postParse, except online inline elements are accepted. This is good for * one-line descriptions and such, but bad for bodies of text, i.e. posts. * @param Request $request * @return string */ public function postInlineParse(Request $request) { $markdown = PostProcessor::postProcess($request->input('markdown')); return $this->parser->parseParagraph($markdown); }