From 3f1370eda59bb53e9e94b12c848b808aae100932 Mon Sep 17 00:00:00 2001 From: ergosteur Date: Fri, 21 Aug 2026 17:05:01 -0400 Subject: [PATCH] Add h4 finding entries to the TOC nav Each finding's detail-list table is now its own indented nav item under "Finding Detail Lists", one click away instead of scroll-only. Also fixes a double-space artifact in h4 badge titles (regex wasn't consuming the whitespace after "[Severity]" before inserting the badge span), which was most visible once those titles started feeding the nav labels. --- src/md_to_html.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/md_to_html.py b/src/md_to_html.py index 3c5f0bc..bb87a8d 100644 --- a/src/md_to_html.py +++ b/src/md_to_html.py @@ -85,6 +85,7 @@ body { .toc a:hover { color: var(--text); } .toc a.active { color: var(--accent); border-left-color: var(--accent); } .toc a.toc-h3 { padding-left: 1.5rem; font-size: 0.94em; } +.toc a.toc-h4 { padding-left: 2.3rem; font-size: 0.88em; opacity: 0.85; } .wrap { flex: 1 1 auto; min-width: 0; @@ -347,7 +348,7 @@ def badge_findings_table(html_text): cell_html, ) cell_html = re.sub( - rf"(]*>)\[{severity}\]", + rf"(]*>)\[{severity}\]\s*", rf'\1{severity} ', cell_html, ) @@ -367,17 +368,17 @@ def wrap_timestamps(html_text): return RFC3339_UTC_RE.sub(r'\1', html_text) -HEADING_RE = re.compile(r'(.*?)', re.S) +HEADING_RE = re.compile(r'(.*?)', re.S) def build_toc(body_html): - """Sidebar nav linking to every h2/h3 in the report (h4 finding headers - are left out -- there can be many of those and they'd swamp the nav).""" + """Sidebar nav linking to every h2/h3/h4 in the report, including each + individual finding's detail-list table (h4) so they're one click away.""" items = [] for level, anchor_id, text in HEADING_RE.findall(body_html): - label = re.sub(r"<[^>]+>", "", text).strip() - css_class = " toc-h3" if level == "3" else "" - items.append(f'{label}') + label = re.sub(r"\s+", " ", re.sub(r"<[^>]+>", "", text)).strip() + css_class = {"3": "toc-h3", "4": "toc-h4"}.get(level, "") + items.append(f'{label}') if not items: return ""