kitzberger/cakephp-markdown

Cakephp Markdown plugin for CakePHP 4.x

Installs: 30

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 5

Type:cakephp-plugin

4.0.0 2023-04-20 07:58 UTC

This package is auto-updated.

Last update: 2024-11-20 11:10:23 UTC


README

Build Status License Total Downloads

CakePHP 4 plugin to parse markdown syntax in your view templates.

Installation

composer require kitzberger/cakephp-markdown:dev-main

Configuration & Usage

To your config/bootstrap.php file add \App\Application::addPlugin('Tanuck/Markdown');

Then, load the helper where needed. For example, in your controller:

class FooController extends AppController
{
    public function initialize(): void
    {
        parent::initialize();
        $this->viewBuilder()->setHelpers(['Tanuck/Markdown.Markdown']);
    }
}

then in your templates, you can output markdown syntax like so:

echo $this->Markdown->transform($myMarkdownSyntax);

Advanced Configuration

Markdown is rendered using the cebe/markdown library which offers 3 different markdown parser classes.

By default, the plugin will use Markdown, the first of the 3 above. However you can specify which of the 3 you use wish to use when loading the helper. Like so:

class FooController extends AppController
{
    public function initialize(): void
    {
        parent::initialize();
        $this->viewBuilder()->setHelpers([
			'Tanuck/Markdown.Markdown' => [
				'parser' => 'GithubMarkdown',
			]
		]);
    }
}

License

cakephp-markdown is offered under an MIT license.