本文整理汇总了PHP中Parsedown::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Parsedown::instance方法的具体用法?PHP Parsedown::instance怎么用?PHP Parsedown::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parsedown
的用法示例。
在下文中一共展示了Parsedown::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHtmlFromMDFile
public static function getHtmlFromMDFile($mdFile, $search = array(), $replace = array(), $setBreaksEnabled = true, $useDocsDir = false)
{
global $REX;
$curLocale = strtolower($REX['LANG']);
if ($useDocsDir) {
$rootPath = $REX['INCLUDE_PATH'] . '/addons/navigation_factory/docs/';
} else {
$rootPath = $REX['INCLUDE_PATH'] . '/addons/navigation_factory/';
}
if ($curLocale == 'de_de') {
$file = $rootPath . $mdFile;
} else {
$file = $rootPath . 'lang/' . $curLocale . '/' . $mdFile;
}
if (file_exists($file)) {
$md = file_get_contents($file);
$md = str_replace($search, $replace, $md);
$md = self::makeHeadlinePretty($md);
$md = str_replace('```php', "```php\r\n<?php", $md);
if (method_exists('Parsedown', 'set_breaks_enabled')) {
$out = Parsedown::instance()->set_breaks_enabled($setBreaksEnabled)->parse($md);
} elseif (method_exists('Parsedown', 'setBreaksEnabled')) {
$out = Parsedown::instance()->setBreaksEnabled($setBreaksEnabled)->parse($md);
} else {
$out = Parsedown::instance()->parse($md);
}
$out = str_replace('<?php<br />', "", $out);
return $out;
} else {
return '[translate:' . $file . ']';
}
}
示例2: index
/**
* 默认动作
*/
public function index()
{
require_once TCH_CORE_ROOT . '/vendor/Parsedown.php';
$content = Parsedown::instance()->parse(file_get_contents(TCH_CORE_ROOT . '/template/admin/doc/readme.md'));
$this->setVar('content', $content);
$this->display();
}
示例3: index
public function index()
{
$version = $this->request->post['version'];
$lookup = $version;
if ($version == '@version@') {
$version = 'develop';
$lookup = '';
}
if (substr($version, 0, 4) == 'dev-') {
$version = preg_replace('/^dev-/i', '', $version);
$lookup = '';
}
$url = $this->url . '/' . $version . '/' . $this->file;
$changelog = RemoteResponse::get($url);
if ($changelog) {
$found = preg_match("/(#\\s" . $lookup . ".+?\\n.*?)(?=\\n{1,}#|\$)/uis", $changelog, $changelog);
if ($found) {
$changelog = \Parsedown::instance()->parse($changelog[0]);
// auto-link issues
$changelog = preg_replace("/#(\\d{1,})/uis", '<a target="_blank" href="' . $this->issues . '/$1">#$1</a>', $changelog);
// auto-link contributors
$changelog = preg_replace("/@([\\w]+)[^\\w]/uis", '<a target="_blank" href="' . $this->contrib . '/$1">@$1</a> ', $changelog);
// add icons for platforms
foreach ($this->platforms as $platform => $icon) {
$changelog = preg_replace('/(<a href="\\#' . $platform . '">)/uis', '$1<i class="fa fa-' . ($icon ?: $platform) . '"></i> ', $changelog);
}
} else {
$changelog = 'No changelog for version <strong>' . $version . '</strong> was found.';
}
}
$response = ['html' => $this->container['admin.theme']->render('@gantry-admin/ajax/changelog.html.twig', ['changelog' => $changelog, 'version' => $version, 'url' => $url, 'fullurl' => $this->fullurl . '/' . $this->file])];
return new JsonResponse($response);
}
示例4: getMod
public function getMod($slug)
{
$table_javascript = route('tdf_name', ['modmodpacks', '0', $slug]);
$mod = Mod::where('slug', '=', $slug)->first();
if (!$mod) {
$redirect = new URLRedirect();
$do_redirect = $redirect->getRedirect(Request::path());
if ($do_redirect) {
return Redirect::to($do_redirect->target, 301);
}
App::abort(404);
}
$can_edit = false;
if (Auth::check()) {
$maintainer = $mod->maintainers()->where('user_id', Auth::id())->first();
if ($maintainer) {
$can_edit = true;
}
}
$authors = $mod->authors;
$spotlights = $mod->youtubeVideos()->where('category_id', 2)->get();
$tutorials = $mod->youtubeVideos()->where('category_id', 3)->get();
$raw_links = ['website' => $mod->website, 'download_link' => $mod->download_link, 'donate_link' => $mod->donate_link, 'wiki_link' => $mod->wiki_link];
$links = [];
foreach ($raw_links as $index => $link) {
if ($link != '') {
$links["{$index}"] = $link;
}
}
$markdown_html = Parsedown::instance()->setBreaksEnabled(true)->text(strip_tags($mod->description));
$mod_description = str_replace('<table>', '<table class="table table-striped table-bordered">', $markdown_html);
$title = $mod->name . ' - Mod - ' . $this->site_name;
$meta_description = $mod->deck;
return View::make('mods.detail', ['table_javascript' => $table_javascript, 'mod' => $mod, 'mod_description' => $mod_description, 'links' => $links, 'authors' => $authors, 'title' => $title, 'meta_description' => $meta_description, 'sticky_tabs' => true, 'spotlights' => $spotlights, 'tutorials' => $tutorials, 'can_edit' => $can_edit]);
}
示例5: testSetParsedown
public function testSetParsedown()
{
$renderer = new \DavidePastore\Slim\Views\MarkdownRenderer(__DIR__ . '/mocks/');
$expected = \Parsedown::instance()->setMarkupEscaped(true);
$renderer->setParsedown($expected);
$this->assertEquals($expected, $renderer->getParsedown());
}
示例6: render
/**
* Field Render Function.
*
* Takes the vars and outputs the HTML for the field in the settings
*
* @since ReduxFramework 1.0.0
*/
function render()
{
// If align value is not set, set it to false, the default
if (!isset($this->field['align'])) {
$this->field['align'] = false;
}
// Set align flag.
$doAlign = $this->field['align'];
// The following could needs to be omitted if align is true.
// Only print it if allign is false.
if (false == $doAlign) {
echo '<style>#' . $this->parent->args['opt_name'] . '-' . $this->field['id'] . ' {padding: 0;}</style>';
echo '</td></tr></table><table class="form-table no-border redux-group-table redux-raw-table" style="margin-top: -20px;"><tbody><tr><td>';
}
echo '<fieldset id="' . $this->parent->args['opt_name'] . '-' . $this->field['id'] . '" class="redux-field redux-container-' . $this->field['type'] . ' ' . $this->field['class'] . '" data-id="' . $this->field['id'] . '">';
if (!empty($this->field['include']) && file_exists($this->field['include'])) {
include $this->field['include'];
}
if (!empty($this->field['content']) && isset($this->field['content'])) {
if (isset($this->field['markdown']) && $this->field['markdown'] == true) {
require_once dirname(__FILE__) . "/parsedown.php";
echo Parsedown::instance()->parse($this->field['content']);
} else {
echo $this->field['content'];
}
}
do_action('redux-field-raw-' . $this->parent->args['opt_name'] . '-' . $this->field['id']);
echo '</fieldset>';
// Only print is align is false.
if (false == $doAlign) {
echo '</td></tr></table><table class="form-table no-border" style="margin-top: 0;"><tbody><tr style="border-bottom: 0;"><th></th><td>';
}
}
示例7: renderMarkdown
public function renderMarkdown($markdownText, $isEditMode)
{
$config = $this->context->getConfig();
require_once __DIR__ . '/../lib/parsedown/Parsedown.php';
$html = Parsedown::instance()->text($markdownText);
// Support `TODO` and `FIXME`
$html = preg_replace('/(^|\\W)(TODO|FIXME):?(\\W|$)/', '$1<span class="todo">$2</span>$3', $html);
// Enhance links
$openExternalLinksInNewTab = $config['openExternalLinksInNewTab'];
$html = preg_replace_callback('|(<a href="([^"]+))"|', function ($match) use($isEditMode, $openExternalLinksInNewTab) {
$url = $match[2];
$isLocalLink = !strpos($url, '//');
if ($isLocalLink && $isEditMode) {
// Append `?edit` to local links (in order to stay in edit mode)
return $match[1] . '?edit"';
} else {
if (!$isLocalLink && $openExternalLinksInNewTab) {
// Add `target="_blank"` to external links
return $match[0] . ' target="_blank"';
} else {
return $match[0];
}
}
}, $html);
return $html;
}
示例8: __construct
public function __construct($path, $outputName, FileReflector $reflector)
{
$this->path = $path;
$this->outputName;
$this->reflector = $reflector;
$this->markdown = \Parsedown::instance();
}
示例9: CMS_DATA
function CMS_DATA()
{
$cms_folder = 'weasel-cms/';
require_once $cms_folder . 'parsedown.php';
$_DATA = [];
$_DATA['site'] = (include $cms_folder . 'config.php');
$_DATA['site']['path'] = dirname($_SERVER['PHP_SELF']);
unset($_DATA['site']['user']);
unset($_DATA['site']['pass']);
// Get all the existing data on to from the .dat file
$db_data = file($cms_folder . $_DATA['site']['db'], FILE_IGNORE_NEW_LINES);
$_DATA['pages'] = array();
foreach ($db_data as $data_line) {
$_DATA['pages'][] = json_decode($data_line, true);
}
// Order the data array by descending datetime, extract slugs and exclude inactive posts
$db_slugs = array();
$items_datetime = array();
foreach ($_DATA['pages'] as $key => $row) {
if (empty($row['active'])) {
unset($_DATA['pages'][$key]);
} else {
$items_datetime[$key] = $row['timedate'];
$db_slugs[] = $row['slug'];
$_DATA['pages'][$key]['link'] = in_array('mod_rewrite', apache_get_modules()) ? dirname($_SERVER['PHP_SELF']) . '' . $row['slug'] . '.cms' : 'index.php?p=' . $row['slug'];
unset($_DATA['pages'][$key]['order']);
unset($_DATA['pages'][$key]['active']);
unset($_DATA['pages'][$key]['timestamp']);
$_DATA['pages'][$key]['timedate'] = date('Y.m.j H:i', $_DATA['pages'][$key]['timedate']);
$_DATA['pages'][$key]['tags'] = implode(', ', $_DATA['pages'][$key]['tags']);
$_DATA['pages'][$key]['content'] = Parsedown::instance()->text($_DATA['pages'][$key]['content']);
}
}
array_multisort($items_datetime, SORT_DESC, $_DATA['pages']);
// Get the current page data
$_DATA['page'] = $_DATA['pages'][0];
$_DATA['is_page'] = false;
if (!empty($_GET['p']) && in_array($_GET['p'], $db_slugs)) {
foreach ($_DATA['pages'] as $db_element) {
if ($_GET['p'] == $db_element['slug']) {
$_DATA['page'] = $db_element;
$_DATA['is_page'] = true;
break;
}
}
}
// Navigation Menu output
$_DATA['menu'] = '<ul>';
foreach ($_DATA['pages'] as $_PAGEITEM) {
$current = $_PAGEITEM['slug'] == $_DATA['page']['slug'] ? ' class="active"' : '';
$_DATA['menu'] .= '<li' . $current . '>';
$_DATA['menu'] .= '<a href="' . $_PAGEITEM['link'] . '" title="' . $_PAGEITEM['title'] . '">';
$_DATA['menu'] .= $_PAGEITEM['title'] . '</a>';
$_DATA['menu'] .= '</li>';
}
$_DATA['menu'] .= '</ul>';
// Returns the parsed data
return $_DATA;
}
示例10: setTemplateVars
public function setTemplateVars()
{
$md = Parsedown::instance();
$content = $md->parse(file_get_contents(realpath(dirname(__FILE__) . '/../../') . "/lib/view/help.txt"));
$content = str_replace('${basepath}', INIT::$BASE_URL, $content);
$this->template->content = $content;
$this->template->basepath = INIT::$BASE_URL;
}
示例11: markdown
/**
* Markdown filter.
*
* Example usage inside template would be:
*
* ```
* <div class="long_description">
* <xsl:value-of
* select="php:function('phpDocumentor\Plugin\Core\Xslt\Extension::markdown',
* string(docblock/long-description))"
* disable-output-escaping="yes" />
* </div>
* ```
*
* @param string $text
*
* @return string
*/
public static function markdown($text)
{
if (!is_string($text)) {
return $text;
}
$markdown = \Parsedown::instance();
return $markdown->parse($text);
}
示例12: parse_md
public static function parse_md($text)
{
if (!class_exists('Parsedown')) {
$path = VP_FileSystem::instance()->resolve_path('includes', 'parsedown');
require $path;
}
return Parsedown::instance()->parse($text);
}
示例13: setUpdate
/**
* Updates the text of a LiveUpdate, and also sets the updatedAt field and the markdown representation of that update.
*
* @param $updateInput
*/
public function setUpdate($updateInput)
{
$this->updatedAt = Carbon::now();
$this->update = $updateInput;
$this->parseIntegrations();
$this->update = (new AcronymService())->parseAndExpand($this->update);
$this->updateMd = \Parsedown::instance()->text($this->update);
}
示例14: parseContent
private function parseContent($filePath)
{
$content = "";
if (file_exists($filePath)) {
$fileContent = file_get_contents($filePath);
$content = Parsedown::instance()->text($fileContent);
}
return $content;
}
示例15: buildPost
private function buildPost($post)
{
require_once $_SERVER['DOCUMENT_ROOT'] . "/app/core/Parsedown.php";
$buildarr = array();
// Get the whole post
$blog_content = Parsedown::instance()->parse(join('', array_slice($post, 0)));
$buildarr = array("content" => $blog_content);
return $buildarr;
}