Skip to content

Commit ccfb908

Browse files
committed
- support php 7.1
- framework agnostic package - update readme.MD
1 parent 8f17b8c commit ccfb908

File tree

6 files changed

+35
-39
lines changed

6 files changed

+35
-39
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/vendor
2-
composer.lock
32
.idea

README.MD

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,26 @@ Table of contents support how strict headers nesting and free nesting, i.e. it c
2929
Table of contents work with only `<h*>` tags 1-10 levels (`h1` - `h10`).
3030
## Getting Started
3131
### Requirements
32-
[Laravel](https://laravel.com/) 5.1 or higher.
32+
PHP 7.1
3333
### Installation
3434
1. You can install the package using the [composer](https://getcomposer.org/).
3535
```
36-
"lutdev/table-contents": "^2.0"
36+
"lutdev/table-contents": "^2.1"
3737
```
3838
Or install it by running this command in your project root:
3939
```
4040
composer require lutdev/table-contents
4141
```
4242

43-
2. Add the facade to your aliases array in the `config/app.php`:
43+
2. PHP class
4444
```php
45-
'aliases' => [
46-
...
47-
'TableContents' => Lutdev\TOC\TableContentsFacade::class,
48-
],
45+
use Lutdev\TOC\TableContents
4946
```
47+
or you can download package and include it via ```require```
5048
### Usage
5149
```php
5250
//return string table contents
53-
TableContents::arrayTableContents($text);
51+
TableContents::tableContents($text);
5452
```
5553

5654
Table of contents have next structure:
@@ -95,12 +93,10 @@ Table of contents have next structure:
9593

9694
```php
9795
//Add ID attribute to the headers. Need for anchors.
98-
TableContents::setHeaderLinks($text)
96+
TableContents::headerLinks($text)
9997
```
10098

10199
## Feedback
102100
Thank you! If you have proposition or find error/bug write me, please.
103101
## License
104-
MIT
105-
## Links
106-
[HabraHabr](https://habrahabr.ru/post/325224/)
102+
MIT

composer.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"name": "lutdev/table-contents",
3-
"version": "2.0.0",
4-
"description": "Laravel 5 table of contents generation",
3+
"version": "2.1.0",
4+
"description": "Table of contents generation",
55
"keywords": [
6-
"laravel",
76
"text",
87
"table contents"
98
],
@@ -16,8 +15,7 @@
1615
}
1716
],
1817
"require": {
19-
"php": "5.6.*",
20-
"illuminate/support": "5.0.x|5.1.x"
18+
"php": "7.1.*"
2119
},
2220
"autoload": {
2321
"psr-4": {

composer.lock

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Lutdev/TOC/TableContents.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TableContents
1919
*
2020
* @return string
2121
*/
22-
public function headerLinks($description)
22+
public function headerLinks(string $description) : string
2323
{
2424
/**
2525
* Support h1-h10 headers. You can using wysiwyg editor and replace h7-h10 tags.
@@ -64,7 +64,7 @@ public function headerLinks($description)
6464
*
6565
* @return string
6666
*/
67-
public function tableContents($originText)
67+
public function tableContents(string $originText) : string
6868
{
6969
$originText = preg_replace("/<(p|[hH](10|[1-9]))>(<[hH](10|[1-9]).*?>(.*?)<\/[hH](10|[1-9])>)<\/(p|[hH](10|[1-9]))>/", "$3", $originText);
7070

@@ -161,7 +161,7 @@ public function tableContents($originText)
161161
*
162162
* @return string
163163
*/
164-
protected function replaceH1Symbols($text)
164+
protected function replaceH1Symbols(string $text) : string
165165
{
166166
$text = preg_replace("/\&nbsp\;/", " ", $text);
167167
$text = preg_replace("/\&lt\;/", "«", $text);
@@ -183,7 +183,7 @@ protected function replaceH1Symbols($text)
183183
*
184184
* @link http://stackoverflow.com/questions/1252693/using-str-replace-so-that-it-only-acts-on-the-first-match
185185
*/
186-
protected function replaceFirstOccurrence($from, $to, $subject)
186+
protected function replaceFirstOccurrence(string $from, string $to, string $subject) : string
187187
{
188188
$from = '/' . preg_quote($from, '/') . '/';
189189

src/TableContentsFacade.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)