def add_lightboxes(html: str, lightbox_class: str = "lightbox", wrapper_class: str = "lightbox-wrapper") -> str: counter: int = 0 img_start: int = html.find(" -1: counter += 1 img_end: int = html.find(">", img_start + 4) lightbox: str = f"\n" +\ f"
\n" +\ f" \n" +\ f" {html[img_start:img_end + 1]}\n" +\ f" \n" alt_start: int = html.find("alt=\"", img_start + 4) if alt_start > -1: alt_end: int = html.find("\"", alt_start + 5) lightbox = lightbox + f"
\n" +\ f" {html[alt_start + 5:alt_end]}\n" +\ f"
\n" lightbox = lightbox + f"
\n" +\ f"
\n" +\ f" \n" +\ f" [close]\n" +\ f" \n" +\ f" {html[img_start:img_end + 1]}\n" +\ f"
\n" +\ f"
\n" +\ f"
\n" if html[img_start - 3:img_start] == "

" and html[img_end + 1:img_end + 5] == "

": img_start -= 3 img_end += 4 html = html[:img_start] + lightbox + html[img_end + 1:] img_start = html.find(" str: counter: int = 0 start: int = html.find("[°") while start > -1: counter += 1 end: int = html.find("]", start) text: str = html[start + 2:end] sidenote: str = f"\n" +\ f"\n" +\ f"\n" +\ f" {text}\n" +\ f"\n" html = html[:start] + sidenote + html[end + 1:] start = html.find("[°", start + len(sidenote)) return html