# BaseMarkdown

> BaseMarkdown provides concrete implementation for yii\helpers\Markdown.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [helpers](/docs/api/yii/helpers/index.md) › BaseMarkdown

| class | `yii\helpers\BaseMarkdown` |
| --- | --- |
| Since | 2.0 |
| Source | [`framework/helpers/BaseMarkdown.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/helpers/BaseMarkdown.php#L22) |

1 subclass:

- [`Markdown`](/docs/api/yii/helpers/markdown/index.md)

BaseMarkdown provides concrete implementation for [`Markdown`](/docs/api/yii/helpers/markdown/index.md).

Do not use BaseMarkdown. Use [`Markdown`](/docs/api/yii/helpers/markdown/index.md) instead.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| [`$defaultFlavor`](#property-defaultFlavor) static | `string` | The markdown flavor to use when none is specified explicitly. Default: `'original'`. | `BaseMarkdown` |
| <span id="property-flavors"></span>`$flavors` static | `array` | A 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` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`process()`](#method-process) static | Converts markdown into HTML. | `BaseMarkdown` |
| [`processParagraph()`](#method-processParagraph) static | Converts markdown into HTML but only parses inline elements. | `BaseMarkdown` |
| [`getParser()`](#method-getParser) protected static |  | `BaseMarkdown` |

## Property details

### $defaultFlavor <span id="property-defaultFlavor"></span>

```php
public static string $defaultFlavor = 'original'
```

The markdown flavor to use when none is specified explicitly.

Defaults to `original`.

## Method details

### process() <span id="method-process"></span>

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

Converts markdown into HTML.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$markdown` | `string` | The markdown text to parse |
| `$flavor` | `string\|null` | The markdown flavor to use. See [`$flavors`](/docs/api/yii/helpers/basemarkdown/index.md#property-flavors) for available values. Defaults to [`$defaultFlavor`](/docs/api/yii/helpers/basemarkdown/index.md#property-defaultFlavor), if not set. |

**Returns**

`string`: The parsed HTML output

**Throws**

- [`yii\base\InvalidArgumentException`](/docs/api/yii/base/invalidargumentexception/index.md): when an undefined flavor is given.

### processParagraph() <span id="method-processParagraph"></span>

```php
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**

| Parameter | Type | Description |
| --- | --- | --- |
| `$markdown` | `string` | The markdown text to parse |
| `$flavor` | `string\|null` | The markdown flavor to use. See [`$flavors`](/docs/api/yii/helpers/basemarkdown/index.md#property-flavors) for available values. Defaults to [`$defaultFlavor`](/docs/api/yii/helpers/basemarkdown/index.md#property-defaultFlavor), if not set. |

**Returns**

`string`: The parsed HTML output

**Throws**

- [`yii\base\InvalidArgumentException`](/docs/api/yii/base/invalidargumentexception/index.md): when an undefined flavor is given.

### getParser() <span id="method-getParser"></span>

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

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$flavor` | `string\|null` | The markdown flavor to use. See [`$flavors`](/docs/api/yii/helpers/basemarkdown/index.md#property-flavors) for available values. Defaults to [`$defaultFlavor`](/docs/api/yii/helpers/basemarkdown/index.md#property-defaultFlavor), if not set. |

**Returns**

`cebe\markdown\Parser`

**Throws**

- [`yii\base\InvalidArgumentException`](/docs/api/yii/base/invalidargumentexception/index.md): when an undefined flavor is given.