From 79a378feeb250452a35b9f96ed03f964061ad63d Mon Sep 17 00:00:00 2001 From: Greg Wilson Date: Sun, 15 Sep 2024 17:01:54 -0400 Subject: [PATCH] feat: add error handling for missing H1 heading --- mccole/render.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mccole/render.py b/mccole/render.py index 5777c1d..d9e554e 100644 --- a/mccole/render.py +++ b/mccole/render.py @@ -5,6 +5,7 @@ from jinja2 import Environment, FileSystemLoader from markdown import markdown from pathlib import Path +import sys from .util import find_files, get_inclusion, load_config, write_file @@ -86,7 +87,11 @@ def do_tables(doc, source_path): def do_title(doc, source_path): """Make sure title element is filled in.""" - doc.title.string = doc.h1.get_text() + try: + doc.title.string = doc.h1.get_text() + except Exception as exc: + print(f"{source_path} lacks H1 heading", file=sys.stderr) + sys.exit(1) def do_root_path_prefix(doc, source_path):