Skip to content

Commit

Permalink
feat: add error handling for missing H1 heading
Browse files Browse the repository at this point in the history
  • Loading branch information
gvwilson committed Sep 15, 2024
1 parent 1af4182 commit 79a378f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mccole/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 79a378f

Please sign in to comment.