Documentation

Markdown
in package
Uses Emitter

Markdown helper class.

Calling Markdown::parse($text) returns the HTML corresponding to the Markdown input in $text.

OctoberCMS uses ParsedownExtra as its Markdown parser, but fires markdown.beforeParse and markdown.parse events allowing hooks into the default parsing,

The markdown.beforeParse event passes a MarkdownData instance, containing a public $text variable. Event listeners can modify $text, for example to filter out or protect snippets from being interpreted by ParseDown.

Similarly, markdown.parse is fired after ParseDown has interpreted the (possibly modified) input. This event passes an array [$text, $data], where $text is the original unmodified Markdown input, and $data is the HTML code generated by ParseDown.

Tags
author

Alexey Bobkov, Samuel Georges

Table of Contents

$emitterEventCollection  : array<string|int, mixed>
$emitterEventSorted  : array<string|int, mixed>
$emitterSingleEventCollection  : array<string|int, mixed>
$parser  : Parsedown
bindEvent()  : self
Create a new event binding.
bindEventOnce()  : self
Create a new event binding that fires once only
fireEvent()  : array<string|int, mixed>
Fire an event and call the listeners.
parse()  : string
Parse text using Markdown and Markdown-Extra
parseClean()  : string
Enables safe mode
parseLine()  : string
Parse a single line
parseSafe()  : string
Disables code blocks caused by indentation.
unbindEvent()  : self
Destroys an event binding.
emitterEventSortEvents()  : array<string|int, mixed>
Sort the listeners for a given event by priority.
getParser()  : mixed
parseInternal()  : mixed
Internal method for parsing

Properties

$emitterEventCollection

protected array<string|int, mixed> $emitterEventCollection = []

Collection of registered events.

$emitterEventSorted

protected array<string|int, mixed> $emitterEventSorted = []

Sorted collection of events.

$emitterSingleEventCollection

protected array<string|int, mixed> $emitterSingleEventCollection = []

Collection of registered events to be fired once only.

$parser

protected Parsedown $parser

Parsedown instance

Methods

bindEvent()

Create a new event binding.

public bindEvent(mixed $event, mixed $callback, mixed $priority) : self
Parameters
$event : mixed
$callback : mixed
$priority : mixed
Return values
self

bindEventOnce()

Create a new event binding that fires once only

public bindEventOnce(mixed $event, mixed $callback) : self
Parameters
$event : mixed
$callback : mixed
Return values
self

fireEvent()

Fire an event and call the listeners.

public fireEvent(string $event[, array<string|int, mixed> $params = [] ][, bool $halt = false ]) : array<string|int, mixed>
Parameters
$event : string

Event name

$params : array<string|int, mixed> = []

Event parameters

$halt : bool = false

Halt after first non-null result

Return values
array<string|int, mixed>

Collection of event results / Or single result (if halted)

parse()

Parse text using Markdown and Markdown-Extra

public parse(string $text) : string
Parameters
$text : string

Markdown text to parse

Return values
string

Resulting HTML

parseClean()

Enables safe mode

public parseClean(string $text) : string
Parameters
$text : string

Markdown text to parse

Return values
string

Resulting HTML

parseLine()

Parse a single line

public parseLine(string $text) : string
Parameters
$text : string

Markdown text to parse

Return values
string

Resulting HTML

parseSafe()

Disables code blocks caused by indentation.

public parseSafe(string $text) : string
Parameters
$text : string

Markdown text to parse

Return values
string

Resulting HTML

unbindEvent()

Destroys an event binding.

public unbindEvent([string $event = null ]) : self
Parameters
$event : string = null

Event to destroy

Return values
self

emitterEventSortEvents()

Sort the listeners for a given event by priority.

protected emitterEventSortEvents(string $eventName) : array<string|int, mixed>
Parameters
$eventName : string
Return values
array<string|int, mixed>

getParser()

protected getParser() : mixed
Return values
mixed

parseInternal()

Internal method for parsing

protected parseInternal(mixed $text[, mixed $method = 'text' ]) : mixed
Parameters
$text : mixed
$method : mixed = 'text'
Return values
mixed

Search results