定制 izadori/parsedown-plus 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

izadori/parsedown-plus

最新稳定版本:v1.0.3

Composer 安装命令:

composer require izadori/parsedown-plus

包简介

An Extension for Parsedown/ParsedownExtra

README 文档

README

An Extension for Parsedown/ParsedownExtra.

Features

  1. Auto-generation of table of contents
    1. By specifying the table of contents tag in the text, ParsedownPlus inserts an automatically generated table of contents.
  2. Support for mathematical expressions in LaTeX format
    1. ParsedownPlus recognize $ ... $ or $$ ... $$ as LaTeX-like formulas and do not parse in Markdown text.
    2. $ ... $ is inline and $$ ... $$ is block.
  3. Recognize file name in fenced code
    1. ParsedownPlus recognize ```lang:file ... ``` and set filename in data-filename attribute of <code> tag.

Usage

With composer

When using composer, you move to your project folder and type following command.

composer require izadori/parsedown-plus

Parsedown will be also installed when it is not found. If you use ParsedownExtra, you may install it manually.

composer require erusev/parsedown-extra

You have to require autoload.php to use ParsedownPlus in your project.

require_once __DIR__ . "/vender/autoload.php";

use \Izadori\ParsedownPlus\ParsedownPlus;

$parser = new ParsedownPlus();

$text = <<<EOF
# Equation of _Circle_

$ x_{1}^{2} + x_{2}^{2} = 1 $
EOF;

$line = "It's **inline** text!";

// parses Markdown text
echo $parser->text($text); // prints: <h1>Equation of <em>Circle</em></h1> <p>$  x_{1}^{2} + x_{2}^{2} = 1  $</p>
// parses inline text
echo $parser->line($line); // prints: It's <strong>inline</strong> text!

Without composer

When not using composer, you download ParsedownPlus in your project here.

To use ParsedownPlus, you require Parsedown.php. And you require ParsedownExtra.php if you need. Then, you require ParsedownPlus.php;

require_once __DIR__ . "/Parsedown.php";
require_once __DIR__ . "/ParsedownExtra.php"; // if you need
require_once __DIR__ . "/ParsedownPlus.php";

use /Izadori;

$parser = new ParsedownPlus();

$text = <<<EOF
# Equation of _Circle_

$ x_{1}^{2} + x_{2}^{2} = 1 $
EOF;

$line = "It's **inline** text!";

// parses Markdown text
echo $parser->text($text); // prints: <h1>Equation of <em>Circle</em></h1> <p>$  x_{1}^{2} + x_{2}^{2} = 1  $</p>
// parses inline text
echo $parser->line($line); // prints: It's <strong>inline</strong> text!

Options

ParsedownPlus has some public variables as its options.

variable description
$langPrefix A prefix added class name of language in fenced code.
The default value is language- for prism.js.
$tocTag A associative array with two members, 'begin' and 'end'.
Give the start and end numbers of the heading tags recognizing as table of contents.
$tocIdentTag Specifies a pseudo-tag for inserting a table of contents in the Markdown text as an array of strings.
$tocFormat Specify the format to include the generated table of contents^1.
%s is given as placeholder of the table of contents. ParsedownPlus uses sprintf() function.

About automatically generating table of contentes

The table of contents generated by ParsedownPlus is an ordered-list like the following.

<ol>
  <li>Heading 1</li>
  <li>Heading 2</li>
    <ol>
      <li>Heading 2.1</li>
      <li>Heading 2.2</li>
    </ol>
  <li>Heading 3</li>
</ol>

About bugs and reports

If you find a bug, please send an issue on the Github with the nature of the bug and the Markdown text in which it occurred.

About license

ParsedownPlus is complies with the MIT license. Please refer to the LICENSE file for details.

About author

History

ParsedownPlus.php

  1. 2021.09.02 [ver.1.0.0]
    • Publish on Github
  2. 2021.09.02 [ver.1.0.1]
    • Fixed a bug that prevented ParsedownExtra from working properly.
    • Added the function of using prefix of the class of language name in the fenced code.
  3. 2021.11.28 [ver.1.0.2]
    • Modified to add class="block-math" to <p> tags output in block math formulas.
  4. 2025.04.14 [ver.1.0.3]
    • Modified to display inline LaTeX-like formulas containing inequality signs correctly.

This document

  1. 2021.09.02
    • Added description to match ParsedownPlus ver.1.0.1.
    • Publish on Github
  2. 2021.09.06
    • Modify sample code.

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-02