(.*?)<\/h\1>/', $article_content, $headings, PREG_SET_ORDER); // Если заголовков нет – возвращаем исходный контент без изменений if (empty($headings)) { return [ 'toc' => '', 'content' => $article_content ]; } $toc_title = __('Table of Contents', 'ai-content-wizard'); // Базовые инлайновые стили $toc_styles = "style='margin: 20px 0; padding: 15px; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 5px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);'"; $toc_title_styles = "style='margin: 0 0 16px 0; padding-bottom: 8px; font-size: 1.4em; font-weight: 600; color: #1f2937; border-bottom: 1px solid #ddd;'"; $toc_list_styles = "style='list-style-type: \"– \"; padding-left: 20px; margin: 0; max-height: 400px; overflow-y: auto; position: relative; z-index: 1;'"; $toc_item_styles = "style='margin: 10px 0; line-height: 1.5;'"; $toc_link_styles = "style='text-decoration: none; color: #374151; display: block; padding-left: 8px; transition: color 0.3s ease, padding-left 0.3s ease;'"; // Формируем контейнер оглавления $toc = "\n"; $toc .= "\n"; return [ 'toc' => $toc, 'content' => $article_content ]; }