# Last edited on 2025-10-24 20:35:00 by stolfi def fig_and_page_link(st:dict, fname:str) -> None: # Creates a subsidiary HTML page "images/{fname}/fig.html" that shows the figure # "images/{fname}/annotated.png", its title "images/{fname}/tite.txt", # and its caption "images/{fname}/legend.txt". # Then appends to {st} an enumeration item that has a link # to that subsidiary page image. global LastEdit assert not re.search(r"[?]", fname), "undefined figure" # File names relative to the current folder: imgfile = f"images/{fname}/annotated.png" # Image file. capfile = f"images/{fname}/legend.txt" # File with plain text caption.a titfile = f"images/{fname}/title.txt" # File with title of figure. subfile = f"images/{fname}/descr.html" # Sub-page file. # Obtain the figure's dimensions: imgsize = h.get_image_size(imgfile) title = h.get_text_from_file(titfile) title = h.protect_html(title) title = h.simple_markup(title) imglink = f"{fname}" h.enum_item(st, imglink) # Create the subsidiary page: st_sub = h.new_doc(title, "#eeffdd", 800) caption = h.get_text_from_file(capfile) caption = h.protect_html(caption) caption = h.simple_markup(caption) caption = h.make_parags(caption) imgfile_sub = f"annotated.png" # Name of image file rel to subpage. imgtag_sub = f"" h.figure(st_sub, imgtag_sub, caption, "100%", centered = True) wr_sub = open(subfile, "w") h.output_doc(st_sub, wr_sub, 0, LastEdit) wr_sub.close() return # ...................................................................... def fig_and_page_enum(st:dict, fnames:list[str]) -> None: h.begin_enum(st, "ul") for fname in fnames: fig_and_page_link(st, fname) h.end_enum(st, "ul") return # ----------------------------------------------------------------------