mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-08-10 07:11:18 +02:00
TOC: extract h1/h2/h3, indent sub-levels in charte/licence sidebar
This commit is contained in:
@@ -45,6 +45,7 @@
|
|||||||
- [x] Close TOC (licence/charte/apropos) and Filtres (search.php) <details> by default on mobile
|
- [x] Close TOC (licence/charte/apropos) and Filtres (search.php) <details> by default on mobile
|
||||||
- [x] Wider heading scale (h1/h2/h3) for apropos/licence/charte pages: step-5 / step-3 / step-1
|
- [x] Wider heading scale (h1/h2/h3) for apropos/licence/charte pages: step-5 / step-3 / step-1
|
||||||
- [x] Reduce heading sizes in content-page.css, use explicit clamp() values instead of step-system vars, tighter hierarchy
|
- [x] Reduce heading sizes in content-page.css, use explicit clamp() values instead of step-system vars, tighter hierarchy
|
||||||
|
- [x] Fix TOC: extractToc now captures h1/h2/h3 (was h1-only), templates render level classes, toc.css adds indentation per level
|
||||||
- [x] Masquer le bloc "Durée" sur la page TFE quand aucune durée n'est encodée (ni pages ni minutes)
|
- [x] Masquer le bloc "Durée" sur la page TFE quand aucune durée n'est encodée (ni pages ni minutes)
|
||||||
- [x] Fix: locked_year cleared on edit — edit dialog didn't populate the field, so any edit cleared the locked academic year
|
- [x] Fix: locked_year cleared on edit — edit dialog didn't populate the field, so any edit cleared the locked academic year
|
||||||
- [x] Fix repertoire Années column: sort reverse chronological (newest first) instead of ascending alpha
|
- [x] Fix repertoire Années column: sort reverse chronological (newest first) instead of ascending alpha
|
||||||
|
|||||||
@@ -38,6 +38,13 @@
|
|||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Indent sub-headings in TOC */
|
||||||
|
.toc-list .toc-level-2 { padding-left: var(--space-s); }
|
||||||
|
.toc-list .toc-level-3 { padding-left: var(--space-m); }
|
||||||
|
|
||||||
|
.toc-list .toc-level-2 a { font-size: var(--step--1); }
|
||||||
|
.toc-list .toc-level-3 a { font-size: var(--step--2); }
|
||||||
|
|
||||||
/* ── Public TOC (details/summary block) ─────────────────────────────────── */
|
/* ── Public TOC (details/summary block) ─────────────────────────────────── */
|
||||||
.toc {
|
.toc {
|
||||||
border: none;
|
border: none;
|
||||||
|
|||||||
@@ -6,12 +6,12 @@
|
|||||||
class MarkdownHelper
|
class MarkdownHelper
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Extract h1 headings from raw markdown content as TOC items.
|
* Extract h1–h3 headings from raw markdown content as TOC items.
|
||||||
*
|
*
|
||||||
* Each heading gets an anchor id matching CommonMark's default slugification
|
* Each heading gets an anchor id matching CommonMark's default slugification
|
||||||
* (lowercase, spaces → hyphens, punctuation stripped).
|
* (lowercase, spaces → hyphens, punctuation stripped).
|
||||||
*
|
*
|
||||||
* @return array<int, array{label: string, href: string}>
|
* @return array<int, array{label: string, href: string, level: int}>
|
||||||
*/
|
*/
|
||||||
public static function extractToc(string $content): array
|
public static function extractToc(string $content): array
|
||||||
{
|
{
|
||||||
@@ -22,10 +22,11 @@ class MarkdownHelper
|
|||||||
$normalizer = new \League\CommonMark\Normalizer\SlugNormalizer();
|
$normalizer = new \League\CommonMark\Normalizer\SlugNormalizer();
|
||||||
|
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
if (preg_match('/^#\s+(.+)$/', $line, $m)) {
|
if (preg_match('/^(#{1,3})\s+(.+)$/', $line, $m)) {
|
||||||
$label = trim($m[1]);
|
$level = strlen($m[1]);
|
||||||
|
$label = trim($m[2]);
|
||||||
$id = $normalizer->normalize($label);
|
$id = $normalizer->normalize($label);
|
||||||
$items[] = ['label' => $label, 'href' => '#' . $id];
|
$items[] = ['label' => $label, 'href' => '#' . $id, 'level' => $level];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $items;
|
return $items;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<summary><?= icon('caret-down', 0, 'toc-caret') ?> PARTIES</summary>
|
<summary><?= icon('caret-down', 0, 'toc-caret') ?> PARTIES</summary>
|
||||||
<ul class="toc-list">
|
<ul class="toc-list">
|
||||||
<?php foreach ($tocItems as $item): ?>
|
<?php foreach ($tocItems as $item): ?>
|
||||||
<li><a href="<?= htmlspecialchars($item['href']) ?>"><?= htmlspecialchars($item['label']) ?></a></li>
|
<li class="toc-level-<?= $item['level'] ?? 1 ?>"><a href="<?= htmlspecialchars($item['href']) ?>"><?= htmlspecialchars($item['label']) ?></a></li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
</details>
|
</details>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<summary><?= icon('caret-down', 0, 'toc-caret') ?> PARTIES</summary>
|
<summary><?= icon('caret-down', 0, 'toc-caret') ?> PARTIES</summary>
|
||||||
<ul class="toc-list">
|
<ul class="toc-list">
|
||||||
<?php foreach ($tocItems as $item): ?>
|
<?php foreach ($tocItems as $item): ?>
|
||||||
<li><a href="<?= htmlspecialchars($item['href']) ?>"><?= htmlspecialchars($item['label']) ?></a></li>
|
<li class="toc-level-<?= $item['level'] ?? 1 ?>"><a href="<?= htmlspecialchars($item['href']) ?>"><?= htmlspecialchars($item['label']) ?></a></li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
</details>
|
</details>
|
||||||
|
|||||||
Reference in New Issue
Block a user