izadori / parsedown-plus
An Extension for Parsedown/ParsedownExtra
Installs: 712
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/izadori/parsedown-plus
Requires
- erusev/parsedown: ^1.7
Requires (Dev)
- phpunit/phpunit: ^9.5
README
An Extension for Parsedown/ParsedownExtra.
Features
- Auto-generation of table of contents
- By specifying the table of contents tag in the text,
ParsedownPlusinserts an automatically generated table of contents.
- By specifying the table of contents tag in the text,
- Support for mathematical expressions in LaTeX format
ParsedownPlusrecognize$ ... $or$$ ... $$as LaTeX-like formulas and do not parse in Markdown text.$ ... $is inline and$$ ... $$is block.
- Recognize file name in fenced code
ParsedownPlusrecognize```lang:file ... ```and set filename indata-filenameattribute 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
- 2021.09.02 [ver.1.0.0]
- Publish on Github
- 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.
- 2021.11.28 [ver.1.0.2]
- Modified to add
class="block-math"to<p>tags output in block math formulas.
- Modified to add
- 2025.04.14 [ver.1.0.3]
- Modified to display inline LaTeX-like formulas containing inequality signs correctly.
This document
- 2021.09.02
- Added description to match ParsedownPlus ver.1.0.1.
- Publish on Github
- 2021.09.06
- Modify sample code.