|
| 1 | +from pathlib import Path |
| 2 | +import re |
| 3 | +import sys |
| 4 | + |
| 5 | +html_path = Path("site/products/ex-commandstation/exrail/cookbooks/driving-trains/passing-loop/index.html") |
| 6 | +css_path = Path("site/_static/css/dccex_theme.css") |
| 7 | + |
| 8 | +if not html_path.exists(): |
| 9 | + print(f"Missing expected page: {html_path}") |
| 10 | + sys.exit(1) |
| 11 | +if not css_path.exists(): |
| 12 | + print(f"Missing expected stylesheet: {css_path}") |
| 13 | + sys.exit(1) |
| 14 | + |
| 15 | +html = html_path.read_text(encoding="utf-8") |
| 16 | +css = css_path.read_text(encoding="utf-8") |
| 17 | + |
| 18 | +# Ensure the first rendered code block is still multiline in generated HTML. |
| 19 | +match = re.search(r'<div class="language-\w+ highlight"><pre><span></span><code>(.*?)</code></pre></div>', html, re.DOTALL) |
| 20 | +if not match: |
| 21 | + print("Could not locate a rendered fenced code block in passing-loop page") |
| 22 | + # Let's look for what we actually have |
| 23 | + highlight_match = re.search(r'<div class="highlight">(.*?)</div>', html, re.DOTALL) |
| 24 | + if highlight_match: |
| 25 | + print("\nFound highlight div with content (first 500 chars):") |
| 26 | + content = highlight_match.group(1)[:500] |
| 27 | + print(content) |
| 28 | + print("\n...") |
| 29 | + else: |
| 30 | + print("\nNo highlight divs found at all") |
| 31 | + sys.exit(1) |
| 32 | +if "\n" not in match.group(1): |
| 33 | + print("Rendered fenced code block no longer contains line breaks") |
| 34 | + sys.exit(1) |
| 35 | + |
| 36 | +# Ensure our CSS safeguard that preserves preformatted line breaks is present. |
| 37 | +if "white-space: pre !important;" not in css: |
| 38 | + print("Missing white-space safeguard for code blocks in compiled CSS") |
| 39 | + sys.exit(1) |
| 40 | + |
| 41 | +print("Regression checks passed: multiline code block and CSS safeguard present") |
0 commit comments