laravelfy/parsedown-extra-plugin 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

laravelfy/parsedown-extra-plugin

Composer 安装命令:

composer require laravelfy/parsedown-extra-plugin

包简介

Configurable Markdown to HTML converter with Parsedown Extra.

README 文档

README

Configurable Markdown to HTML converter with Parsedown Extra.

Table of Content

Installation

Include ParsedownExtraPlugin.php just after the Parsedown.php and ParsedownExtra.php:

require 'Parsedown.php';
require 'ParsedownExtra.php';
require 'ParsedownExtraPlugin.php';

$parser = new ParsedownExtraPlugin();

// settings ...
$parser->code_class = 'lang-%s';

echo $parser->text('# Header {.sth}');

Features

HTML or XHTML

$parser->element_suffix = '>'; // HTML5

Predefined Abbreviations

$parser->abbreviations = array(
    'CSS' => 'Cascading Style Sheet',
    'HTML' => 'Hyper Text Markup Language',
    'JS' => 'JavaScript'
);

Predefined Links

$parser->links = array(
    'mecha-cms' => array(
        'url' => 'http://mecha-cms.com',
        'title' => 'Mecha CMS'
    ),
    'test-image' => array(
        'url' => 'http://example.com/favicon.ico',
        'title' => 'Test Image'
    )
);

Automatic rel="nofollow" Attribute on External Links

// custom link attributes
$parser->links_attr = array();

// custom external link attributes
$parser->links_external_attr = array(
    'rel' => 'nofollow',
    'target' => '_blank'
);

// custom image attributes
$parser->images_attr = array(
    'alt' => ""
);

// custom external image attributes
$parser->images_external_attr = array();

Custom Code Class Format

$parser->code_class = 'language-%s';
$parser->code_class = function($text) {
    return trim(str_replace('.', ' ', $text));
};

Custom Code Text Format

$parser->code_text = '<span class="my-code">%s</span>';
$parser->code_block_text = '<span class="my-code-block">%s</span>';
$parser->code_text = function($text) {
    return do_syntax_highlighter($text);
};

$parser->code_block_text = function($text) {
    return do_syntax_highlighter($text);
};

Put <code> Attributes on <pre> Element

$parser->code_block_attr_on_parent = true;

Custom Table Class

$parser->table_class = 'table-bordered';

Custom Table Alignment Class

$parser->table_align_class = 'text-%s';

Custom Footnote ID Format

$parser->footnote_link_id = 'cite_note:%s';

Custom Footnote Back ID Format

$parser->footnote_back_link_id = 'cite_ref:%s-%s';

Custom Footnote Class

$parser->footnote_class = 'footnotes';

Custom Footnote Link Class

$parser->footnote_link_class = 'footnote-ref';

Custom Footnote Back Link Class

$parser->footnote_back_link_class = 'footnote-backref';

Custom Footnote Link Text

$parser->footnote_link_text = '[%s]';
$parser->footnote_link_text = function($text) {
    return '[' . $text . ']';
};

Custom Footnote Back Link Text

$parser->footnote_back_link_text = '<i class="icon icon-back"></i>';

Advance Attribute Parser

  • {#foo}<tag id="foo">
  • {#foo#bar}<tag id="bar">
  • {.foo}<tag class="foo">
  • {.foo.bar}<tag class="foo bar">
  • {#foo.bar.baz}<tag id="foo" class="bar baz">
  • {#foo .bar .baz}<tag id="foo" class="bar baz"> (white-space before # and . becomes optional in my extension)
  • {foo="bar"}<tag foo="bar">
  • {foo="bar baz"}<tag foo="bar baz">
  • {foo='bar'}<tag foo="bar">
  • {foo='bar baz'}<tag foo="bar baz">
  • {foo=bar}<tag foo="bar">
  • {foo=}<tag foo="">
  • {foo}<tag foo="foo">
  • {foo=bar baz}<tag foo="bar" baz="baz">
  • {#a#b.c.d e="f" g="h i" j='k' l='m n' o=p q= r s t="u#v.w.x y=z"}<tag id="b" class="c d" e="f" g="h i" j="k" l="m n" o="p" q="" r="r" s="s" t="u#v.w.x y=z">

Code Block Class Without language- Prefix

Dot prefix in class name are now becomes optional, custom attributes syntax also acceptable:

  • php<pre><code class="language-php">
  • php html<pre><code class="language-php language-html">
  • .php<pre><code class="php">
  • .php.html<pre><code class="php html">
  • .php html<pre><code class="php language-html">
  • {.php #foo}<pre><code id="foo" class="php">

统计信息

  • 总下载量: 520
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-12-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固