chore: complete update

This commit is contained in:
2025-07-17 16:24:20 +02:00
parent 899227b0a4
commit 64a7051137
1300 changed files with 85570 additions and 2756 deletions

View File

@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
namespace App\Framework\Markdown;
final readonly class MarkdownConverter
{
public function toHtml(string $markdown): string
{
// Einfacher Markdown-zu-HTML Converter
$html = $markdown;
// Headers
$html = preg_replace('/^# (.+)$/m', '<h1>$1</h1>', $html);
$html = preg_replace('/^## (.+)$/m', '<h2>$1</h2>', $html);
$html = preg_replace('/^### (.+)$/m', '<h3>$1</h3>', $html);
// Bold und Italic
$html = preg_replace('/\*\*(.+?)\*\*/', '<strong>$1</strong>', $html);
$html = preg_replace('/\*(.+?)\*/', '<em>$1</em>', $html);
// Code Blöcke
$html = preg_replace('/```(\w+)?\n(.*?)\n```/s', '<pre><code class="language-$1">$2</code></pre>', $html);
$html = preg_replace('/`(.+?)`/', '<code>$1</code>', $html);
// Links
$html = preg_replace('/\[(.+?)\]\((.+?)\)/', '<a href="$2">$1</a>', $html);
// Listen
$html = preg_replace('/^- (.+)$/m', '<li>$1</li>', $html);
$html = preg_replace('/(<li>.*<\/li>)/s', '<ul>$1</ul>', $html);
// Blockquotes
$html = preg_replace('/^> (.+)$/m', '<blockquote>$1</blockquote>', $html);
// Paragraphen
$html = preg_replace('/\n\n/', '</p><p>', $html);
$html = '<p>' . $html . '</p>';
// Zeilenumbrüche
$html = preg_replace('/\n/', '<br>', $html);
return $html;
}
public function stripMarkdown(string $markdown): string
{
$text = $markdown;
// Entferne Markdown-Syntax
$text = preg_replace('/^#+\s/', '', $text); // Headers
$text = preg_replace('/\*\*(.+?)\*\*/', '$1', $text); // Bold
$text = preg_replace('/\*(.+?)\*/', '$1', $text); // Italic
$text = preg_replace('/```.*?\n(.*?)\n```/s', '$1', $text); // Code Blöcke
$text = preg_replace('/`(.+?)`/', '$1', $text); // Inline Code
$text = preg_replace('/\[(.+?)\]\((.+?)\)/', '$1 ($2)', $text); // Links
$text = preg_replace('/^[\-\*] /', '', $text); // Listen
$text = preg_replace('/^> /', '', $text); // Blockquotes
return trim($text);
}
}