From b2f834df440e1b1eaa648aae97f462d9ae96662a Mon Sep 17 00:00:00 2001 From: Lars Weiler Date: Tue, 6 Jan 2026 13:16:51 +0100 Subject: [PATCH] fix: update `section_url` for proper reference to the same file --- renderer/fifty_ohm_html_renderer.py | 5 +++++ src/build.py | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/renderer/fifty_ohm_html_renderer.py b/renderer/fifty_ohm_html_renderer.py index 9d3a746..b8c98ee 100644 --- a/renderer/fifty_ohm_html_renderer.py +++ b/renderer/fifty_ohm_html_renderer.py @@ -37,6 +37,7 @@ class FiftyOhmHtmlRenderer(HtmlRenderer): edition=None, chapter=None, section=None, + section_url=None, **kwargs, ): super().__init__( @@ -75,6 +76,10 @@ class FiftyOhmHtmlRenderer(HtmlRenderer): self.chapter = chapter self.section = section + # Set section URL if provided, otherwise use default + if section_url is not None: + self.section_url = section_url + # Figure map: stores ref -> hierarchical number mapping self.figure_map = {} diff --git a/src/build.py b/src/build.py index 327ade1..5cac294 100644 --- a/src/build.py +++ b/src/build.py @@ -179,6 +179,9 @@ class Build: chapter_num = str(chapter_number) if chapter_number is not None else chapter.get("number", "0") section_num = str(section_id) + # Set the section URL for references + section_filename = f"{edition}_{section['ident']}.html" + with FiftyOhmHtmlRenderer( question_renderer=self.__build_question, picture_handler=self.__picture_handler, @@ -187,6 +190,7 @@ class Build: edition=edition, chapter=chapter_num, section=section_num, + section_url=section_filename, ) as renderer: # First pass: collect all figures and assign hierarchical numbers doc = Document(section["content"]) @@ -223,8 +227,12 @@ class Build: help_template = self.env.get_template("slide/help.html") next_template = self.env.get_template("slide/next.html") - # Parse chapter number - chapter_num = chapter.get("number", "0") + # Use provided chapter_number or fall back to chapter dict + chapter_num = str(chapter_number) if chapter_number is not None else chapter.get("number", "0") + + # Set the slide URL for references (all sections in one file) + # Note: filename uses original edition (e.g., "N"), not modified edition with "S" (e.g., "NS") + slide_filename = f"{edition}_slide_{chapter['ident']}.html" with FiftyOhmHtmlSlideRenderer( question_renderer=self.__build_question_slide, @@ -234,6 +242,7 @@ class Build: edition=edition, chapter=chapter_num, section="0", # Will be updated per section + section_url=slide_filename, ) as renderer: result = "
\n" result += f'
\n

{chapter["title"]}

\n
\n'