PHP code example of fxcjahid / laravel-table-of-content
1. Go to this page and download the library: Download fxcjahid/laravel-table-of-content library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fxcjahid / laravel-table-of-content example snippets
use fxcjahid\LaravelTableOfContent\Table;
use fxcjahid\LaravelTableOfContent\MarkupFixer;
$content = <<<END
<h2>This is heading H2</h2>
<h3>This is heading H3</h3>
<h4>This is heading H4</h4>
<h2>This is heading H1</h2>
END;
/**
* Get Markup tag fixies
*/
$getFixContent = $markup->fix($content);
/**
* Get Table Of content
* Levels 1-6 (It's will skip heading tag)
*/
$getTableOfContent = $toc->getTableContent($getFixContent, 2);
$htmlOut = "<div class='content'>" . $getFixContent . "</div>";
$htmlOut .= "<div class='toc'>" . $getTableOfContent . "</div>";
return $htmlOut;
use fxcjahid\LaravelTableOfContent\Table;
use fxcjahid\LaravelTableOfContent\MarkupFixer;
/**
* Show the articles page.
*/
public function show(Table $toc, MarkupFixer $markup){
$content = <<<END
<h2>This is heading H2</h2>
<h3>This is heading H3</h3>
<h4>This is heading H4</h4>
<h2>This is heading H1</h2>
END;
/**
* Get Markup tag fixies
*/
$getFixContent = $markup->fix($content);
/**
* Get Table Of content
* Note: without ID arttibutes Table can't generate
*/
$getTableOfContent = $toc->getTableContent($getFixContent);
$htmlOut = "<div class='content'>" . $getFixContent . "</div>";
$htmlOut .= "<div class='toc'>" . $getTableOfContent . "</div>";
echo $htmlOut;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.