diff --git a/app/public/assets/css/public.css b/app/public/assets/css/public.css index 5cffbd0..b742603 100644 --- a/app/public/assets/css/public.css +++ b/app/public/assets/css/public.css @@ -68,7 +68,8 @@ background: var(--bg-tertiary); position: relative; margin: 0; /* reset
default margin */ - border-radius: 7px 7px 0 0; + /* border-radius: 7px 7px 0 0; */ + border-radius: var(--radius); } .home-body figure img, diff --git a/app/src/Controllers/AboutController.php b/app/src/Controllers/AboutController.php index 4548913..032cf96 100644 --- a/app/src/Controllers/AboutController.php +++ b/app/src/Controllers/AboutController.php @@ -3,8 +3,10 @@ require_once APP_ROOT . '/src/Database.php'; require_once APP_ROOT . '/src/ErrorHandler.php'; require_once APP_ROOT . '/src/EmailObfuscator.php'; +require_once APP_ROOT . '/src/MarkdownHelper.php'; use League\CommonMark\CommonMarkConverter; +use League\CommonMark\Extension\HeadingPermalink\HeadingPermalinkExtension; class AboutController { @@ -21,8 +23,10 @@ class AboutController $db = Database::getInstance(); $aboutPage = $db->getPage('about'); $rawContent = $aboutPage ? $aboutPage['content'] : ''; + error_log('[TOC-DEBUG] Apropos: dbPage found=' . ($aboutPage ? 'yes' : 'NO') . ' content_len=' . strlen($rawContent)); if (empty(trim($rawContent)) || trim($rawContent) === 'Contenu à venir') { $rawContent = $this->defaultContent; + error_log('[TOC-DEBUG] Apropos: using defaultContent instead'); } $contacts = $db->getAproposContent('contacts'); $contacts = is_array($contacts) && !empty($contacts) ? $contacts : null; @@ -44,13 +48,28 @@ class AboutController $rawContent = $this->defaultContent; $contacts = null; $sidebarLinks = []; + error_log('[TOC-DEBUG] Apropos: EXCEPTION ' . $e->getMessage()); } - $converter = new CommonMarkConverter(['html_input' => 'strip']); + $converter = new CommonMarkConverter([ + 'html_input' => 'strip', + 'heading_permalink' => [ + 'apply_id_to_heading' => true, + 'id_prefix' => '', + 'insert' => 'before', + 'aria_hidden' => true, + ], + ]); + $converter->getEnvironment()->addExtension(new HeadingPermalinkExtension()); + $html = EmailObfuscator::obfuscateHtml($converter->convert($rawContent)->getContent()); + + $tocItems = MarkdownHelper::extractToc($rawContent); + error_log('[TOC-DEBUG] Apropos: extractToc returned ' . count($tocItems) . ' items'); return [ 'currentNav' => 'apropos', - 'aboutHtml' => EmailObfuscator::obfuscateHtml($converter->convert($rawContent)->getContent()), + 'aboutHtml' => $html, + 'tocItems' => $tocItems, 'contacts' => $contacts, 'sidebarLinks' => $sidebarLinks, 'pageTitle' => 'À Propos – XAMXAM', diff --git a/app/src/Controllers/CharteController.php b/app/src/Controllers/CharteController.php index 07b1621..6cf7972 100644 --- a/app/src/Controllers/CharteController.php +++ b/app/src/Controllers/CharteController.php @@ -22,10 +22,12 @@ class CharteController $dbPage = $db->getPage('charte'); $content = $dbPage ? $dbPage['content'] : ''; $pageTitle = $dbPage ? $dbPage['title'] : 'Charte'; + error_log('[TOC-DEBUG] Charte: dbPage found=' . ($dbPage ? 'yes' : 'NO') . ' content_len=' . strlen($content)); } catch (Exception $e) { ErrorHandler::log('charte_page', $e); $content = ''; $pageTitle = 'Charte'; + error_log('[TOC-DEBUG] Charte: EXCEPTION ' . $e->getMessage()); } $converter = new CommonMarkConverter([ @@ -40,7 +42,9 @@ class CharteController $converter->getEnvironment()->addExtension(new HeadingPermalinkExtension()); $html = EmailObfuscator::obfuscateHtml($converter->convert($content)->getContent()); + error_log('[TOC-DEBUG] Charte: calling extractToc with content_len=' . strlen($content)); $tocItems = MarkdownHelper::extractToc($content); + error_log('[TOC-DEBUG] Charte: extractToc returned ' . count($tocItems) . ' items'); return [ 'content' => $content, diff --git a/app/src/Controllers/LicenceController.php b/app/src/Controllers/LicenceController.php index 0efb3dd..c488ebb 100644 --- a/app/src/Controllers/LicenceController.php +++ b/app/src/Controllers/LicenceController.php @@ -22,10 +22,12 @@ class LicenceController $dbPage = $db->getPage('licenses'); $content = $dbPage ? $dbPage['content'] : ''; $pageTitle = $dbPage ? $dbPage['title'] : 'Licences'; + error_log('[TOC-DEBUG] Licence: dbPage found=' . ($dbPage ? 'yes' : 'NO') . ' content_len=' . strlen($content)); } catch (Exception $e) { ErrorHandler::log('licence_page', $e); $content = ''; $pageTitle = 'Licences'; + error_log('[TOC-DEBUG] Licence: EXCEPTION ' . $e->getMessage()); } $converter = new CommonMarkConverter([ @@ -40,7 +42,9 @@ class LicenceController $converter->getEnvironment()->addExtension(new HeadingPermalinkExtension()); $html = EmailObfuscator::obfuscateHtml($converter->convert($content)->getContent()); + error_log('[TOC-DEBUG] Licence: calling extractToc with content_len=' . strlen($content)); $tocItems = MarkdownHelper::extractToc($content); + error_log('[TOC-DEBUG] Licence: extractToc returned ' . count($tocItems) . ' items'); return [ 'content' => $content, diff --git a/app/src/MarkdownHelper.php b/app/src/MarkdownHelper.php index ba1f443..d4531e2 100644 --- a/app/src/MarkdownHelper.php +++ b/app/src/MarkdownHelper.php @@ -18,6 +18,20 @@ class MarkdownHelper $items = []; $lines = explode("\n", $content); + // ── DEBUG: temporary TOC diagnostics ────────────────────────── + error_log('[TOC-DEBUG] content length: ' . strlen($content)); + error_log('[TOC-DEBUG] line count: ' . count($lines)); + foreach (array_slice($lines, 0, 8) as $i => $line) { + if ($line === '') { + error_log('[TOC-DEBUG] line[' . $i . '] (empty)'); + } else { + $hex = bin2hex($line); + $preview = mb_substr($line, 0, 60); + error_log('[TOC-DEBUG] line[' . $i . '] hex=' . $hex . ' raw=' . $preview); + } + } + // ── END DEBUG ───────────────────────────────────────────────── + // Use CommonMark's own SlugNormalizer so TOC links match the rendered heading IDs exactly. $normalizer = new \League\CommonMark\Normalizer\SlugNormalizer(); @@ -27,8 +41,10 @@ class MarkdownHelper $label = trim($m[2]); $id = $normalizer->normalize($label); $items[] = ['label' => $label, 'href' => '#' . $id, 'level' => $level]; + error_log('[TOC-DEBUG] MATCH: h' . $level . ' "' . $label . '" -> #' . $id); } } + error_log('[TOC-DEBUG] total items found: ' . count($items)); return $items; } } diff --git a/app/templates/public/about.php b/app/templates/public/about.php index 8703bc9..753e843 100644 --- a/app/templates/public/about.php +++ b/app/templates/public/about.php @@ -34,14 +34,13 @@ function renderEntries(array $entries): string
+
PARTIES @@ -53,6 +52,7 @@ function renderEntries(array $entries): string
+