Skip to content

fix(compiler): render markdown details and summary blocks into interactive accordions and add Gate 13 audit - #4

Merged
vadde merged 2 commits into
mainfrom
feat/fix-nested-details-raw-html-rendering
Oct 29, 2026
Merged

vadde merged 2 commits into
mainfrom
feat/fix-nested-details-raw-html-rendering

Conversation

@vadde

@vadde vadde commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Summary

This PR addresses user feedback regarding markdown <details> and <summary> blocks (such as Researcher's Corner and Self-Test Questions) leaking raw escaped text (&lt;details&gt;, &lt;summary&gt;) and leaving the content spilled open on the live static documentation page.

Root Cause Analysis

  1. In scripts/build-docs.py, the custom markdown compiler render_markdown() had no block-level parser for <details> or <summary>.
  2. As a result, each line was treated as a regular paragraph wrapped in <p class="md-p">.
  3. In inline_formatting(), the regex re.sub(r'<(?=[0-9a-zA-Z\s\-])', '&lt;', text) indiscriminately escaped all valid HTML opening tags, turning <details> and <summary> into literal &lt;details&gt; and &lt;summary&gt; entity text.
  4. Consequently, browsers displayed the raw tags on screen without establishing interactive collapsible behavior, leaving the inner content permanently expanded.

Key Changes

  1. Markdown Compiler Upgrade (scripts/build-docs.py):
    • Added block-level state tracking (details_stack) in render_markdown() to emit semantic <details class="md-details">, <summary class="md-summary">, and <div class="md-details-body">.
    • Introduced HTML_TAG_PATTERN in inline_formatting() to protect all standard HTML tags (details, summary, b, strong, code, br, etc.) while safely converting mathematical comparison operators (<, >, <=, >=) to HTML entities/unicode symbols.
  2. Year 2500 Cosmic Glass Styling & Mica Theme Support (docs/site/style.css):
    • Styled .md-details with subtle borders, glassmorphic backgrounds, and smooth hover glow.
    • Designed .md-summary with flex layout, custom chevrons (.md-summary-chevron), and 90-degree expansion animations.
    • Added full light-mode overrides under [data-theme="mica"].
  3. Audio Haptics & Reading Mode Integration (docs/site/app.js):
    • Wired .md-summary to HapticAudio.expand() and HapticAudio.collapse() on user click.
    • Updated Expand All and Collapse All reading modes to control all .md-details elements.
  4. Elevated Verification Suite to 13 Quality Gates (scripts/test-docs.sh, scripts/audit_collapsible_elements.py):
    • Built standalone invariant audit engine scripts/audit_collapsible_elements.py.
    • Added Gate 13 into scripts/test-docs.sh, validating tag balance across all 42 source markdown files and asserting 0 raw/escaped HTML leaks in _site/index.html.
    • Integrated test-details target into Makefile and .github/workflows/ci.yml.

Verification

  • make ci: Passed all 13 gates deterministically (100% compliance).
  • Headless Playwright: Verified that fund-mod-002-hash-table displays Perfect Hashing & FKS Two-Level Scheme as a closed, interactive accordion that opens and closes on click.

@vadde
vadde merged commit 99f9de2 into main Oct 29, 2026
10 checks passed
@vadde
vadde deleted the feat/fix-nested-details-raw-html-rendering branch October 29, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant