-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it posible to make it work with [toc] #2
Comments
Sadly, so far at this latest commit 4e9af97, NO. 😭 Though, I agree and like your idea. It would be nice if we can have a
It might be a feasible idea if we can replace the |
A simple workaround with the current version would be: <?php
include_once('Pasedown.php');
include_once('Extension.php');
$textMarkdown =<<<EOL
[toc]
---
# Head1
Sample text of head 1.
## Head1-1
Sample text of head 1-1.
# Head2
Sample text of head 2.
## Head2-1
Sample text of head2-1.
EOL;
$Parsedown = new Extension();
$body = $Parsedown->text($textMarkdown);
$ToC = $Parsedown->contentsList();
// Replace `[toc]` to generated table of contents
$body = str_replace('[toc]', $ToC, $body);
echo $body . PHP_EOL;
|
[toc] now available!
As of f027f1f, now it works with
[toc]
---
# One
Something about One
## Two
Something about Two
# One2
Something about One2 The PHP file. (It uses composer. Do
require_once __DIR__ . '/vendor/autoload.php';
$Parsedown = new \ParsedownToC();
$text_markdown = file_get_contents('SAMPLE.md');
$html = $Parsedown->text($text_markdown);
echo $html . PHP_EOL; The result $ php main.php
<div id="toc"><ul>
<li><a href="#One">One</a><ul>
<li><a href="#Two">Two</a></li>
</ul>
</li>
<li><a href="#One2">One2</a></li>
</ul></div>
<hr />
<h1 id="One" name="One">One</h1>
<p>Something about One</p>
<h2 id="Two" name="Two">Two</h2>
<p>Something about Two</p>
<h1 id="One2" name="One2">One2</h1>
<p>Something about One2</p> Closing the issue. But feel free to re-open the issue if it's not working! |
Is it posible to make it work with [toc] ???
The text was updated successfully, but these errors were encountered: