fix: update section_url for proper reference to the same file
This commit is contained in:
@@ -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 = {}
|
||||
|
||||
|
||||
+11
-2
@@ -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 = "<section>\n"
|
||||
result += f'<section data-background="#DAEEFA">\n<h1>{chapter["title"]}</h1>\n</section>\n'
|
||||
|
||||
Reference in New Issue
Block a user