Download the PHP package keinos/parsedown-toc without Composer
On this page you can find all versions of the php package keinos/parsedown-toc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download keinos/parsedown-toc
More information about keinos/parsedown-toc
Files in keinos/parsedown-toc
Package parsedown-toc
Short Description Table of Contents Extension for Parsedown, the Parser for Markdown.
License MIT
Homepage https://github.com/KEINOS/parsedown-extension_table-of-contents/
Informations about the package parsedown-toc
Parsedown ToC Extension
Listing Table of Contents Extension for Parsedown.
This simple PHP file extends Parsedown Vanilla / Parsedown Extra to generate a list of header index (a.k.a. Table of Contents or ToC), from a markdown text given.
With the toc()
method, you can get just the "ToC".
- Main Class:
ParsedownToC()
- Arguments: none
- Methods:
text(string $text)
:- Returns the parsed content and
[toc]
tag(s) parsed as well. - Required argument
$text
: Markdown string to be parsed.
- Returns the parsed content and
body(string $text)
:- Returns the parsed content WITHOUT parsing
[toc]
tag. - Required argument
$text
: Markdown string to be parsed.
- Returns the parsed content WITHOUT parsing
toc([string $type_return='string'])
:- Returns the ToC, the table of contents, in HTML or JSON.
- Option argument:
$type_return
:string
orjson
can be specified.string
=HTML,json
=JSON.- Default
string
- Alias method:
contentsList(string $type_return)
setTagToc(string $tag='[tag]')
:- Sets user defined ToC markdown tag. Use this method before
text()
orbody()
method if you want to use the ToC tag rather than the "[toc]
". - Empty value sets the default ToC tag.
- Available since v1.1.2
- Sets user defined ToC markdown tag. Use this method before
- Other Methods:
- All the public methods of
Parsedown
and/orParsedown Extend
are available to use. - Note: As of v1.1.0 the old alias class:
Extension()
is deprecated.
Online Demo
Install
Via Composer
If you are familiar to composer, the package manager for PHP, then install it as below:
- Usage: See sample project
Manual Install (Download the script)
You can download the 'Extension.php' file from the below URL. Place it anywhere you like to include.
- NOTE: Since this is an extension of Parsedown, you need to download and include
Parsedown.php
as well. - Usage: See sample project
Sample Usage
- See: ./samples/
Advanced Usage (Using Parsedown Extra)
As of Parsedown ToC Extension v1.1.1, you can use the anchor identifiers for Parsedown Extra.
With this feature, you can specify the anchor name you like. Useful if the headings are in UTF-8 (not in ASCII) and to make it readable. Such as placing the "go back" links in a page.
With the above markdown the generated ToC will be as below. Note that the anchor is changed to the specified one.
- Note that you need to require/include the Parsedown Extra as well.
References
- Repo:
- Source Code: https://github.com/KEINOS/parsedown-extension_table-of-contents @ GitHub
- Archived Package: https://packagist.org/packages/keinos/parsedown-toc @ Packagist
- Support:
- Parsedown's Wiki @ GitHub
- Issues of this extension @ GitHub
- Issues of Parsedown @ GitHub
- Issues of Parsedown Extra @ GitHub
- Authors:
- KEINOS and the contributors @ GitHub
- Licence: