@@ -457,6 +457,14 @@ class ResponseRepairer: |
| 457 | 457 | ) |
| 458 | 458 | if html_starter_line: |
| 459 | 459 | lines.append(html_starter_line) |
| 460 | + html_template_line = self._known_html_starter_template_line( |
| 461 | + concrete_target, |
| 462 | + require_first_substantive_output=True, |
| 463 | + retry_number=retry_number, |
| 464 | + outline_label=outline_label, |
| 465 | + ) |
| 466 | + if html_template_line: |
| 467 | + lines.append(html_template_line) |
| 460 | 468 | if ( |
| 461 | 469 | not compact_retry |
| 462 | 470 | and _should_encourage_initial_version( |
@@ -1572,6 +1580,31 @@ class ResponseRepairer: |
| 1572 | 1580 | "sections with short body text, and a back link to `../index.html`." |
| 1573 | 1581 | ) |
| 1574 | 1582 | |
| 1583 | + def _known_html_starter_template_line( |
| 1584 | + self, |
| 1585 | + target: Path, |
| 1586 | + *, |
| 1587 | + require_first_substantive_output: bool, |
| 1588 | + retry_number: int, |
| 1589 | + outline_label: str | None, |
| 1590 | + ) -> str | None: |
| 1591 | + if not require_first_substantive_output or retry_number < 4: |
| 1592 | + return None |
| 1593 | + if target.suffix.lower() not in {".html", ".htm"}: |
| 1594 | + return None |
| 1595 | + label = outline_label.strip() if outline_label and outline_label.strip() else "this chapter" |
| 1596 | + snippet = ( |
| 1597 | + "<!DOCTYPE html> <html lang=\"en\"> <head> <meta charset=\"UTF-8\"> " |
| 1598 | + f"<title>{label}</title> </head> <body> <div class=\"container\"> " |
| 1599 | + f"<h1>{label}</h1> <p>...</p> <h2>Overview</h2> <p>...</p> " |
| 1600 | + "<p><a href=\"../index.html\">← Back to Main Guide Index</a></p> " |
| 1601 | + "</div> </body> </html>" |
| 1602 | + ) |
| 1603 | + return ( |
| 1604 | + "If blanking continues, use this minimal HTML starter as the `content` value " |
| 1605 | + f"and adapt it: `{snippet}`." |
| 1606 | + ) |
| 1607 | + |
| 1575 | 1608 | def _best_known_root_html_scaffold(self, target: Path) -> Path | None: |
| 1576 | 1609 | normalized_target = target.expanduser().resolve(strict=False) |
| 1577 | 1610 | if normalized_target.suffix.lower() not in {".html", ".htm"}: |