inwebo/markdown-bundle

Installs: 4

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/inwebo/markdown-bundle

1.0.0 2025-11-10 16:07 UTC

This package is auto-updated.

Last update: 2025-11-10 16:09:02 UTC


README

Packagist Version Packagist Downloads Packagist License

Introduction

The Inwebo Markdown Bundle integrates Inwebo\Markdown\Factory into Symfony applications, providing a simple and configurable way to convert Markdown to safe HTML. It registers the factory as a service for dependency injection, supports parser configuration and extensions, and is installed via Composer. Inject Inwebo\Markdown\Factory and call parse() to render Markdown content.

See Inwebo\Markdown for more information.

Installation

composer require inwebo/markdown-bundle

Usage

<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Inwebo\Markdown\Factory;

class MarkdownController extends AbstractController
{
    // DI
    public function __construct(private readonly Factory $factory)
    {
    }

    #[Route('/markdown/preview', name: 'markdown_preview')]
    public function preview(): Response
    {
        $markdown = <<<'MD'
# Bonjour

Ceci est un exemple de *Markdown* converti en HTML via `Inwebo\Markdown\Factory`.
MD;
        // Call the parser and you are done!
        $html = $this->factory->parse($markdown);

        return new Response($html, Response::HTTP_OK, ['Content-Type' => 'text/html; charset=utf-8']);
    }
}