{$text}";
}
if (!empty($op['attributes']['italic'])) {
$text = "{$text}";
}
if (!empty($op['attributes']['underline'])) {
$text = "{$text}";
}
// Ajouter d'autres styles si nécessaire
}
// Convertir les retours à la ligne en paragraphes
if ($text === "\n") {
$html .= "
";
} else {
$html .= $text;
}
}
// Gérer les images
elseif (is_array($op['insert']) && isset($op['insert']['image'])) {
$imageUrl = $op['insert']['image'];
error_log('URL originale: ' . $imageUrl);
// Retirer tous les "../" au début de l'URL
$imageUrl = preg_replace('/^(?:\.\.\/)+/', '', $imageUrl);
error_log('URL nettoyée: ' . $imageUrl);
$html .= "";
}
}
// Envelopper le contenu dans des balises p si nécessaire
if (!empty($html)) {
$paragraphs = explode("\n\n", $html);
$html = '';
foreach ($paragraphs as $p) {
if (trim($p) !== '') {
$html .= "
{$p}
"; } } } return $html; } function isJson($string) { json_decode($string); return json_last_error() === JSON_ERROR_NONE; } $config = Config::load(); ?>