Skip to content
PHP Ecosystem
Explore

BaseMarkdown

API reference › yii › helpers › BaseMarkdown

classyii\helpers\BaseMarkdown
Since2.0
Sourceframework/helpers/BaseMarkdown.php
1 subclass

BaseMarkdown provides concrete implementation for Markdown.

Do not use BaseMarkdown. Use Markdown instead.

PropertyTypeDescriptionDefined by
$defaultFlavor staticstringThe markdown flavor to use when none is specified explicitly. Default: 'original'.BaseMarkdown
$flavors staticarrayA map of markdown flavor names to corresponding parser class configurations. Default: ['original' => ['class' => 'cebe\markdown\Markdown', 'html5' => true], 'gfm' => ['class' => 'cebe\markdown\GithubMarkdown', 'html5' => true], 'gfm-comment' => ['class' => 'cebe\markdown\GithubMarkdown', 'html5' => true, 'enableNewlines' => true], 'extra' => ['class' => 'cebe\markdown\MarkdownExtra', 'html5' => true]].BaseMarkdown
MethodDescriptionDefined by
process() staticConverts markdown into HTML.BaseMarkdown
processParagraph() staticConverts markdown into HTML but only parses inline elements.BaseMarkdown
getParser() protected staticBaseMarkdown
public static string $defaultFlavor = 'original'

The markdown flavor to use when none is specified explicitly.

Defaults to original.

public static function process(string $markdown, string|null $flavor = null): string

Converts markdown into HTML.

Parameters

ParameterTypeDescription
$markdownstringThe markdown text to parse
$flavorstring|nullThe markdown flavor to use. See $flavors for available values. Defaults to $defaultFlavor, if not set.

Returns

string: The parsed HTML output

Throws

public static function processParagraph(string $markdown, string|null $flavor = null): string

Converts markdown into HTML but only parses inline elements.

This can be useful for parsing small comments or description lines.

Parameters

ParameterTypeDescription
$markdownstringThe markdown text to parse
$flavorstring|nullThe markdown flavor to use. See $flavors for available values. Defaults to $defaultFlavor, if not set.

Returns

string: The parsed HTML output

Throws

protected static function getParser(string|null $flavor): cebe\markdown\Parser

Parameters

ParameterTypeDescription
$flavorstring|nullThe markdown flavor to use. See $flavors for available values. Defaults to $defaultFlavor, if not set.

Returns

cebe\markdown\Parser

Throws