cable8mm / toc
The TOC is an opinionated table of contents generator.
v1.2.1
2024-05-01 11:23 UTC
Requires
- php: ^8.1
Requires (Dev)
- laravel/pint: ^1.0
- pestphp/pest: ^2.0
Suggests
- laravel/pint: Required to lint.
- pestphp/pest: Required to test.
README
The TOC is a library for the project document2.
Features
- Laravel toc
- Samsung Tizen toc
- Naver clova ai toc
- Rhymix toc
Installation
composer require cable8mm/toc
Usage
namespace Cable8mm\Toc; $markdown = ' - ## Prologue - [Release Notes](/docs/{{version}}/releases) - [Upgrade Guide](/docs/{{version}}/upgrade) - [Contribution Guide](/docs/{{version}}/contributions) - ## Getting Started - [Installation](/docs/{{version}}/installation) - [Configuration](/docs/{{version}}/configuration) '; $lines = Toc::of($markdown)->getLines(); foreach ($lines as $line) { // example "- ## Prologue" // example " - [Release Notes](/docs/{{version}}/releases)" print $line->getTitle().PHP_EOL; //=> "Prologue" //=> "Release Notes" print $line->getLink().PHP_EOL; //=> null //=> "/docs/{{version}}/releases" print $line->getType().PHP_EOL; //=> ItemEnum::section //=> ItemEnum::page print $line->getDepth().PHP_EOL; //=> 1 //=> 2 }
Testing
composer test
Formatting
composer lint # Modify all files to comply with the PSR-12. composer inspect # Inspect all files to ensure compliance with PSR-12.
License
The Document2 project is open-sourced software licensed under the MIT license.