You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+149-8Lines changed: 149 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,35 @@ Listing Table of Contents Extension for [Parsedown](http://parsedown.org/).
8
8
9
9
This [simple PHP file](https://github.com/KEINOS/parsedown-extension_table-of-contents/blob/master/Extension.php) extends [Parsedown (vanilla)](https://github.com/erusev/parsedown) to generate a list of table of contents, aka ToC, from a markdown text given.
10
10
11
+
```bash
12
+
composer require keinos/parsedown-toc
13
+
```
14
+
15
+
```php
16
+
<?php
17
+
require_once __DIR__ . '/vendor/autoload.php';
18
+
19
+
$TextMarkdown = file_get_contents('SAMPLE.md');
20
+
21
+
$Parsedown = new ParsedownToc();
22
+
23
+
$Body = $Parsedown->text($TextMarkdown);
24
+
$ToC = $Parsedown->contentsList();
25
+
26
+
echo $ToC . PHP_EOL;
27
+
echo $Body . PHP_EOL;
28
+
```
29
+
30
+
- Main Class: `ParsedownToc(string $Text)`
31
+
- Arguments:
32
+
-`$Text`: String of the Markdown text to be parsed.
33
+
- Methods:
34
+
-`text()`: Returns the Body. (Returns a string of the parsed HTML of the main contents.)
35
+
-`contentsList(string $Return_as)`: Returns the ToC. (Returns a string of the table of contents in HTML or JSON.)
36
+
-`$Return_as`: `string` or `json` can be specified. (`string`=HTML(default), `json`=JSON)
37
+
- Other Methods:
38
+
- All the methods of `Parsedown` are available to use.
-[ ]`[toc]` markdown tag/element replacing it to the table of contents. ([Issue #2](https://github.com/KEINOS/parsedown-extension_table-of-contents/issues/2))
-[Issues of this extension](https://github.com/KEINOS/parsedown-extension_table-of-contents/issues) @ GitHub
248
+
-[Issues of Parsedown](https://github.com/erusev/parsedown/issues) @ GitHub
249
+
250
+
## Upcoming feature
251
+
252
+
-[ ]`[toc]` markdown tag/element replacing it to the table of contents. ([Issue #2](https://github.com/KEINOS/parsedown-extension_table-of-contents/issues/2))
0 commit comments