class Toc implements Stringable

Properties

protected ConverterInterface[] $converters

The converter array

protected $data

The markdown string for the converter

protected Item[] $lines

The line array

protected $sections

The section array

Methods

__construct(string $markdown)

Constructor

Toc
normalize()

Converts markdown string using the converters provided

Toc
mapping()

Map lines to Item instance

Toc
grouping()

No description

string|null
getSectionTitle(string $title)

Get the section title

array
getLines()

Get the toc line array from a markdown string

getLine(int $lineNumber)

Get the toc nth line from a markdown string

Toc
addConverters(array $converters)

Add converters to the converter array

string
__toString()

Implement Stringable Interface

array
toArray()

Output the navigation data

static Toc
of(string $markdown)

Factory

Details

at line 44
__construct(string $markdown)

Constructor

Parameters

string $markdown

The original markdown string

at line 57
protected Toc normalize()

Converts markdown string using the converters provided

Return Value

Toc

at line 73
protected Toc mapping()

Map lines to Item instance

Return Value

Toc

at line 85
protected Toc grouping()

No description

Return Value

Toc

at line 109
string|null getSectionTitle(string $title)

Get the section title

Parameters

string $title

The title

Return Value

string|null

The method returns the section title if found, null otherwise

at line 127
array getLines()

Get the toc line array from a markdown string

Return Value

array

The method returns line array from a markdown string

at line 138
Item getLine(int $lineNumber)

Get the toc nth line from a markdown string

Parameters

int $lineNumber

The line number

Return Value

Item

The method returns nth line item from a markdown string

at line 148
Toc addConverters(array $converters)

Add converters to the converter array

Parameters

array $converters

The converter array

Return Value

Toc

at line 160
string __toString()

Implement Stringable Interface

Return Value

string

The method returns a string representation

at line 170
array toArray()

Output the navigation data

Return Value

array

The method returns the navigation data

at line 180
static Toc of(string $markdown)

Factory

Parameters

string $markdown

The markdown string

Return Value

Toc