本文整理汇总了PHP中ParsedownExtra::text方法的典型用法代码示例。如果您正苦于以下问题:PHP ParsedownExtra::text方法的具体用法?PHP ParsedownExtra::text怎么用?PHP ParsedownExtra::text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParsedownExtra
的用法示例。
在下文中一共展示了ParsedownExtra::text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* @param string $string
* @param array $args
*
* @return string
*/
public function render($string, array $args = [])
{
@preg_match_all('#{~sm:(.*)}#i', $string, $matches);
if (0 < count($matches[0])) {
for ($i = 0; $i < count($matches[0]); ++$i) {
$replace = '<small class="text-muted">' . $this->parsedown->text($matches[1][$i]) . '</small>';
$string = str_ireplace($matches[0][$i], $replace, $string);
}
}
@preg_match_all('#{~scml:([^}]*)}#i', $string, $matches);
if (0 < count($matches[0])) {
for ($i = 0; $i < count($matches[0]); ++$i) {
$replace = '<span class="scml">' . $matches[1][$i] . '</span>';
$string = str_ireplace($matches[0][$i], $replace, $string);
}
}
@preg_match_all('#{~scml-tag:([^}]*)}#i', $string, $matches);
if (0 < count($matches[0])) {
for ($i = 0; $i < count($matches[0]); ++$i) {
$replace = '<span class="scml-tag"><<span class="scml">' . $matches[1][$i] . '</span>></span>';
$string = str_ireplace($matches[0][$i], $replace, $string);
}
}
@preg_match_all('#{~app-menu:([^}]*)}#i', $string, $matches);
if (0 < count($matches[0])) {
for ($i = 0; $i < count($matches[0]); ++$i) {
$replace = '<span class="app-menu">' . $matches[1][$i] . '</span>';
$string = str_ireplace($matches[0][$i], $replace, $string);
}
}
return $string;
}
示例2: render
public function render($path, $params)
{
$view = $this->_view;
$options = $this->_options;
$Extra = new \ParsedownExtra();
echo $Extra->text(file_get_contents($path));
}
示例3: changelog
public function changelog()
{
$output = '';
$url = 'https://api.github.com/repos/arastta/arastta/releases';
$json = $this->utility->getRemoteData($url);
if (empty($json)) {
return $output;
}
$parsedown = new ParsedownExtra();
$releases = json_decode($json);
foreach ($releases as $release) {
if ($release->tag_name <= VERSION) {
continue;
}
if (empty($release->body)) {
continue;
}
$output .= '<h2><span class="label label-primary">' . $release->tag_name . '</span></h2>';
// Parse markdown output
$markdown = str_replace('## Changelog', '', $release->body);
$output .= $parsedown->text($markdown);
$output .= '<hr>';
}
return $output;
}
示例4: parse_string
public function parse_string($template, $data = array(), $return = FALSE, $config = array())
{
if (!is_array($config)) {
$config = array();
}
$config = array_merge($this->config, $config);
$ci = $this->ci;
$is_mx = false;
if (!$return) {
list($ci, $is_mx) = $this->detect_mx();
}
switch ($config['markdown_implementation']) {
case 'parsedown':
$parser = new ParsedownExtra();
$template = @$parser->text($template);
break;
default:
if (!empty($config['detect_code_blocks'])) {
$template = preg_replace('/`{3,}[a-z]*/i', '~~~', $template);
}
$parser = new MarkdownExtra_Parser();
$template = @$parser->transform($template);
if (!empty($config['apply_autolink'])) {
$this->ci->load->helper('url');
$template = auto_link($template);
}
break;
}
return $this->output($template, $return, $ci, $is_mx);
}
示例5: convert
/**
* Convert the input data.
*
* @param string $input The raw content without Front-matter
*
* @return string
*/
public function convert($input)
{
if (is_string($input) === false) {
throw new \InvalidArgumentException('Expected a string value at Parsedown converter.');
}
$converter = new \ParsedownExtra();
return $converter->text($input);
}
示例6: parseMarkdown
public static function parseMarkdown($value)
{
include_once __DIR__ . '/vendor/Parsedown.php';
include_once __DIR__ . '/vendor/ParsedownExtra.php';
$parser = new \ParsedownExtra();
$parser->setUrlsLinked(false);
return $parser->text($value);
}
示例7: previewpost
public function previewpost()
{
$this->load->library('Parsedown');
$this->load->library('ParsedownExtra');
$tulisan = $this->input->post('inilah');
/*$tulisan = htmlspecialchars($_POST['inilah']);*/
$Tulis = new ParsedownExtra();
echo $Tulis->text($tulisan);
}
示例8: get
public function get()
{
$content = [];
$count = 1;
// initial object creation
foreach (glob(ELSA . '/content/' . $this->folder . '/*.' . $this->extension) as $contentItem) {
// parse content
$frontmatter = new FrontMatter($contentItem);
$parsedown = new ParsedownExtra();
$meta = [];
$type = preg_match('/content\\/(.*)\\//', $contentItem, $match);
$type = $match[1];
foreach ($frontmatter->fetchMeta() as $key => $value) {
$meta[$key] = $value;
}
// compose
$content[$count]['id'] = (int) @explode('_', array_pop(explode('/', $contentItem)))[0];
$content[$count]['slug'] = @explode('.', explode('_', array_pop(explode('/', $contentItem)))[1])[0];
$content[$count]['content'] = $parsedown->text($frontmatter->fetchContent());
$content[$count]['content_raw'] = $frontmatter->fetchContent();
$content[$count]['type'] = $type;
$content[$count]['meta'] = $meta;
$count++;
}
// order
usort($content, function ($a, $b) {
// id desc
if ($this->orderby === 'id' && $this->order === 'desc') {
return $b['id'] - $a['id'];
}
// id asc
if ($this->orderby === 'id' && $this->order === 'asc') {
return $a['id'] - $b['id'];
}
// timestamp desc
if ($this->orderby === 'timestamp' && $this->order === 'desc') {
return $b['meta']['timestamp'] - $a['meta']['timestamp'];
}
// timestamp asc
if ($this->orderby === 'timestamp' && $this->order === 'asc') {
return $a['meta']['timestamp'] - $b['meta']['timestamp'];
}
});
// convert to objects
$content = json_decode(json_encode($content));
// with slug ...
if ($this->slug) {
// find the content we want
foreach ($content as $contentItem) {
if ($contentItem->slug === $this->slug) {
return $contentItem;
break;
}
}
}
return $content;
}
示例9: getPageContent
/**
* Get the content of a file
* @param string $path file path
* @return string markdown formated string
*/
public function getPageContent($path)
{
$extra = new \ParsedownExtra();
$content = null;
if (Storage::exists($path) === true) {
$content = $extra->text(Storage::get($path));
}
return $content;
}
示例10: execute
protected function execute(array $arguments)
{
if (isset($arguments[0]) && ($wf_id = (int) $GLOBALS['workflow_id'])) {
$extra = new \ParsedownExtra();
WorkflowRepository::component_result($wf_id, 'markdown-view', $extra->text($arguments[0]));
return '';
}
throw new InvalidArgumentException('strings invalid');
}
示例11: printPostRSS
function printPostRSS($post)
{
$parseDown = new ParsedownExtra();
echo " <item>\n";
echo " <title>" . $post['title'] . "</title>\n";
echo " <link>http://fisherevans.com/blog/post/" . $post['title_slug'] . "</link>\n";
echo " <guid>http://fisherevans.com/blog/post/" . $post['title_slug'] . "</guid>\n";
echo " <pubDate>" . date("D, d M Y H:i:s O", strtotime($post['posted_date'])) . "</pubDate>\n";
echo " <content:encoded><![CDATA[" . fixRelativeLinks($parseDown->text($post['content'])) . "]]></content:encoded>\n";
echo " </item>\n";
}
示例12: markdown
/**
* Markdown
*
* Parse Markdown to HTML
*
* @since 2.0.0
*
* @param $content (string) Markdown string or file to parse
*/
function markdown($content)
{
// Check for file
if (is_readable($content)) {
$content = file_get_contents($content);
}
// Parse Markdown
$markdown = new ParsedownExtra();
$result = $markdown->text($content);
return $result;
}
示例13: index
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$this->load->helper('url');
$data = array();
$data['readme'] = null;
$readme = @file_get_contents(FCPATH . 'README.md');
if ($readme != '') {
$parser = new ParsedownExtra();
$data['readme'] = @$parser->text($readme);
}
$this->load->view('welcome_message', $data);
}
示例14: text
public function text($text)
{
// Fix markdown blockquote syntax - > gets encoded.
if (substr($text, 0, 4) == '>') {
$text = '>' . substr($text, 5);
}
$text = preg_replace('/[\\n\\r]>\\s/', "\n> ", $text);
// Fix autolink syntax
$text = preg_replace('#<(http[a-zA-Z0-9-\\.\\/:]*)>#', "<\$1>", $text);
$text = parent::text($text);
$text = $this->smartypants($text);
// Parsedown has naive encoding of URLs - fix it.
$text = str_replace('&amp;', '&', $text);
return $text;
}
示例15: ParsedownExtra
function text_to_html($text)
{
/*
static $parser;
if (!isset($parser)) {
$parser = new MarkdownExtra_Parser();
}
return @ $parser->transform($text);
*/
static $parser;
if (!isset($parser)) {
$parser = new ParsedownExtra();
}
return @$parser->text($text);
}