marquage/parsedownanchors
Composer 安装命令:
composer require marquage/parsedownanchors
包简介
extends Parsedown-extra to automatically add id anchors with unique slugs
README 文档
README
This tiny extension is part of the larger markdown-driven note-taking site. Although it is primarily aimed for building table of contents, this package accomplishes two things only:
- It automatically generates id-anchors for headers (h1-h6), using Cocur/Slugify. It does not require writing down header slugs ahead of time.
- It ensures that each id is unique. From the simple included test:
## The Site
## The Site
will turn to:
<h2 id="the-site">The Site</h2>
<h2 id="the-site-1">The Site</h2>
For the larger project that relies on the excellent Tocbot, that's all that was needed but I could not find an extension that addressed these simple concerns. There are other packages for Parsedown TOC, such as these two.
Install
Via Composer
$ composer require marquage/parsedownanchors
Usage
In the unlikely case that you would only need this tiny package, you can call it instead of Parsedown since it is an extension and you would have access to all the rich features of Parsedown-extra.
$parser = new ParsedownSlugified(); $file = file_get_contents('[...]'); return $parser->parse($file);
Testing
$ composer test
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-15