https://github.com/cable8mm/toc
The TOC is an opinionated table of contents generator
https://github.com/cable8mm/toc
document2
Last synced: about 2 months ago
JSON representation
The TOC is an opinionated table of contents generator
- Host: GitHub
- URL: https://github.com/cable8mm/toc
- Owner: cable8mm
- License: mit
- Created: 2024-04-26T12:42:46.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-21T09:07:19.000Z (11 months ago)
- Last Synced: 2025-07-21T11:18:27.480Z (11 months ago)
- Topics: document2
- Language: PHP
- Homepage: http://www.palgle.com/toc/
- Size: 129 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# TOC - TOC library for document2
[](https://github.com/cable8mm/toc/actions/workflows/code-style.yml)
[](https://github.com/cable8mm/toc/actions/workflows/run-tests.yml)
[](https://packagist.org/packages/cable8mm/toc)
[](https://packagist.org/packages/cable8mm/toc/stats)
[](https://packagist.org/packages/cable8mm/toc)
[](https://github.com/cable8mm/toc/stargazers)
[](https://github.com/cable8mm/toc/blob/main/LICENSE.md)
The TOC is a library for the project [document2](https://github.com/cable8mm/document2).
## Features
- [x] Laravel toc
- [x] Samsung Tizen toc
- [x] Naver clova ai toc
- [x] Rhymix toc
## Installation
```shell
composer require cable8mm/toc
```
## Usage
```php
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
```shell
composer test
```
## Formatting
```shell
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](LICENSE).