Skip to content

Commit 6230a77

Browse files
mvadariCopilot
andauthored
add ToC, fix broken links (#449)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 91e10e8 commit 6230a77

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

scripts/assets/style.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ main {
420420
.document-content h3,
421421
.document-content h4,
422422
.document-content h5,
423-
.document-content h6 {
423+
.document-content h6,
424+
.document-content .toctitle {
424425
margin-top: 32px;
425426
margin-bottom: 16px;
426427
color: var(--text-color);
@@ -433,6 +434,11 @@ main {
433434
font-size: 32px;
434435
}
435436

437+
.document-content .toctitle {
438+
padding-bottom: 16px;
439+
font-size: 32px;
440+
}
441+
436442
.document-content h1 .headerlink,
437443
.document-content h2 .headerlink,
438444
.document-content h3 .headerlink,

scripts/build_site.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import shutil
99
from pathlib import Path
10+
import re
1011

1112
import markdown
1213
from jinja2 import Environment, FileSystemLoader
@@ -17,11 +18,16 @@
1718

1819
def convert_markdown_to_html(content: str) -> str:
1920
"""Convert markdown content to HTML."""
21+
# Insert a TOC marker after the first metadata block, unless one already exists.
22+
if "[TOC]" not in content:
23+
content = re.sub(r"</pre>", "</pre>\n\n[TOC]\n\n", content, count=1)
24+
content = re.sub(r"\.\./(XLS-[0-9A-Za-z-]+)/README\.md", r"./\1.html", content)
25+
2026
md = markdown.Markdown(
2127
extensions=["extra", "codehilite", "toc", "tables"],
2228
extension_configs={
2329
"codehilite": {"css_class": "highlight"},
24-
"toc": {"permalink": True},
30+
"toc": {"permalink": True, "baselevel": 2, "toc_depth": 3, "title": "Table of Contents"},
2531
},
2632
)
2733
return md.convert(content)

0 commit comments

Comments
 (0)