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,
|
edition=None,
|
||||||
chapter=None,
|
chapter=None,
|
||||||
section=None,
|
section=None,
|
||||||
|
section_url=None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
@@ -75,6 +76,10 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
|
|||||||
self.chapter = chapter
|
self.chapter = chapter
|
||||||
self.section = section
|
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
|
# Figure map: stores ref -> hierarchical number mapping
|
||||||
self.figure_map = {}
|
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")
|
chapter_num = str(chapter_number) if chapter_number is not None else chapter.get("number", "0")
|
||||||
section_num = str(section_id)
|
section_num = str(section_id)
|
||||||
|
|
||||||
|
# Set the section URL for references
|
||||||
|
section_filename = f"{edition}_{section['ident']}.html"
|
||||||
|
|
||||||
with FiftyOhmHtmlRenderer(
|
with FiftyOhmHtmlRenderer(
|
||||||
question_renderer=self.__build_question,
|
question_renderer=self.__build_question,
|
||||||
picture_handler=self.__picture_handler,
|
picture_handler=self.__picture_handler,
|
||||||
@@ -187,6 +190,7 @@ class Build:
|
|||||||
edition=edition,
|
edition=edition,
|
||||||
chapter=chapter_num,
|
chapter=chapter_num,
|
||||||
section=section_num,
|
section=section_num,
|
||||||
|
section_url=section_filename,
|
||||||
) as renderer:
|
) as renderer:
|
||||||
# First pass: collect all figures and assign hierarchical numbers
|
# First pass: collect all figures and assign hierarchical numbers
|
||||||
doc = Document(section["content"])
|
doc = Document(section["content"])
|
||||||
@@ -223,8 +227,12 @@ class Build:
|
|||||||
help_template = self.env.get_template("slide/help.html")
|
help_template = self.env.get_template("slide/help.html")
|
||||||
next_template = self.env.get_template("slide/next.html")
|
next_template = self.env.get_template("slide/next.html")
|
||||||
|
|
||||||
# Parse chapter number
|
# Use provided chapter_number or fall back to chapter dict
|
||||||
chapter_num = chapter.get("number", "0")
|
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(
|
with FiftyOhmHtmlSlideRenderer(
|
||||||
question_renderer=self.__build_question_slide,
|
question_renderer=self.__build_question_slide,
|
||||||
@@ -234,6 +242,7 @@ class Build:
|
|||||||
edition=edition,
|
edition=edition,
|
||||||
chapter=chapter_num,
|
chapter=chapter_num,
|
||||||
section="0", # Will be updated per section
|
section="0", # Will be updated per section
|
||||||
|
section_url=slide_filename,
|
||||||
) as renderer:
|
) as renderer:
|
||||||
result = "<section>\n"
|
result = "<section>\n"
|
||||||
result += f'<section data-background="#DAEEFA">\n<h1>{chapter["title"]}</h1>\n</section>\n'
|
result += f'<section data-background="#DAEEFA">\n<h1>{chapter["title"]}</h1>\n</section>\n'
|
||||||
|
|||||||
Reference in New Issue
Block a user