Add `composer.json`
Closed this issue · 3 comments
sommer-gei commented
Dear KEINOS,
can you plz add a composer.json
file to your repo!? − Its seems this extension is great, but I don’t wanna do my local copy everytime I wanna use your code …
Thanks an best regards!
KEINOS commented
That's a good idea! Thanks! I'll add it soon!
KEINOS commented
I don’t wanna do my local copy everytime I wanna use your code …
Thank you for waiting. Now you can use it Parsedown-ToC
any time you wanna!
composer require keinos/parsedown-toc:1.0.0
$ mkdir my_project && cd $_
$ composer require keinos/parsedown-toc:1.0.0
...
$ vi main.php
...
$ cat main.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
$textMarkdown = file_get_contents('SAMPLE.md');
$Parsedown = new ParsedownToc();
$body = $Parsedown->text($textMarkdown);
$ToC = $Parsedown->contentsList();
echo $ToC . PHP_EOL;
echo $body . PHP_EOL;
$
$ vi SAMPLE.md
...
$ cat SAMPLE.md
# Head1
Sample text of head 1.
## Head1-1
Sample text of head 1-1.
# Head2
Sample text of head 2.
## 見出し2-1
Sample text of head2-1.
$
$ php main.php
<ul>
<li><a href="#Head1">Head1</a>
<ul>
<li><a href="#Head1-1">Head1-1</a></li>
</ul></li>
<li><a href="#Head2">Head2</a>
<ul>
<li><a href="#%E8%A6%8B%E5%87%BA%E3%81%972-1">見出し2-1</a></li>
</ul></li>
</ul>
<h1 id="Head1" name="Head1">Head1</h1>
<p>Sample text of head 1.</p>
<h2 id="Head1-1" name="Head1-1">Head1-1</h2>
<p>Sample text of head 1-1.</p>
<h1 id="Head2" name="Head2">Head2</h1>
<p>Sample text of head 2.</p>
<h2 id="%E8%A6%8B%E5%87%BA%E3%81%972-1" name="%E8%A6%8B%E5%87%BA%E3%81%972-1">見出し2-1</h2>
<p>Sample text of head2-1.</p>
If it works with no-problem with you, then please close this issue. If not, feel free to inform it here!
sommer-gei commented
@KEINOS Thanks a lot! 👍
Everything works like I expected …