{
"event": "PostToolUse",
"tool_name": "Read",
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Formatting\/ChatMessageFormatter.php",
"content": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Infrastructure\\Formatting;\n\n\/\/ @responsibility: Formatiert Chat-Nachrichten (Markdown → HTML)\n\nclass ChatMessageFormatter\n{\n public function formatAnswer(string $text): string\n {\n \/\/ Escape HTML first\n $text = htmlspecialchars($text);\n\n \/\/ Headers\n $text = preg_replace('\/^### (.+)$\/m', '<h4>$1<\/h4>', $text);\n $text = preg_replace('\/^## (.+)$\/m', '<h3>$1<\/h3>', $text);\n $text = preg_replace('\/^# (.+)$\/m', '<h3>$1<\/h3>', $text);\n\n \/\/ Bold\n $text = preg_replace('\/\\*\\*(.+?)\\*\\*\/', '<strong>$1<\/strong>', $text);\n\n \/\/ Italic\n $text = preg_replace('\/\\*(.+?)\\*\/', '<em>$1<\/em>', $text);\n\n \/\/ Code\n $text = preg_replace('\/`(.+?)`\/', '<code>$1<\/code>', $text);\n\n \/\/ Blockquotes\n $text = preg_replace('\/^> (.+)$\/m', '<blockquote>$1<\/blockquote>', $text);\n\n \/\/ Lists: Process line by line to correctly wrap consecutive list items\n $text = $this->formatLists($text);\n\n \/\/ Line breaks\n $text = nl2br($text);\n\n \/\/ Clean up multiple <br> tags\n $text = preg_replace('\/(<br\\s*\\\/?>\\s*){3,}\/', '<br><br>', $text);\n\n return $text;\n }\n\n private function formatLists(string $text): string\n {\n $lines = explode(\"\\n\", $text);\n $result = [];\n $inList = false;\n\n foreach ($lines as $line) {\n \/\/ Check if line is a list item (- or * or numbered)\n if (preg_match('\/^[-*] (.+)$\/', $line, $matches)) {\n if (!$inList) {\n $result[] = '<ul>';\n $inList = true;\n }\n $result[] = '<li>' . $matches[1] . '<\/li>';\n } elseif (preg_match('\/^\\d+\\. (.+)$\/', $line, $matches)) {\n \/\/ Numbered list item\n if (!$inList) {\n $result[] = '<ul>';\n $inList = true;\n }\n $result[] = '<li>' . $matches[1] . '<\/li>';\n } else {\n \/\/ Not a list item\n if ($inList) {\n $result[] = '<\/ul>';\n $inList = false;\n }\n $result[] = $line;\n }\n }\n\n \/\/ Close any open list\n if ($inList) {\n $result[] = '<\/ul>';\n }\n\n return implode(\"\\n\", $result);\n }\n}\n",
"numLines": 84,
"startLine": 1,
"totalLines": 84
}
}
}