Converts Markdown to safe HTML for emails and wraps it in a document structure.
// Source: https://github.com/metadist/synaplan | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
<?php
declare(strict_types=1);
namespace App\Service\Email;
/**
* Shared Markdown → HTML conversion for outbound mail.
*
* Safe-mode Parsedown (no raw HTML from the model). Callers that still need
* to append a footer use {@see toFragment()} then {@see wrapDocument()}.
*/
final readonly class MarkdownEmailFormatter
{
public function toFragment(string $markdown): string
{
$parsedown = new \Parsedown();
$parsedown->setSafeMode(true);
return $parsedown->text($markdown);
}
public function wrapDocument(string $html): string
{
retu
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key