@@ -384,8 +384,8 @@ def export_attachments(self, export_path: StrPath) -> None:
384
384
def get_attachment_by_file_id (self , file_id : str ) -> Attachment :
385
385
return next (attachment for attachment in self .attachments if attachment .file_id == file_id )
386
386
387
- def get_attachment_by_title (self , title : str ) -> Attachment :
388
- return next ( attachment for attachment in self .attachments if attachment .title == title )
387
+ def get_attachments_by_title (self , title : str ) -> list [ Attachment ] :
388
+ return [ attachment for attachment in self .attachments if attachment .title == title ]
389
389
390
390
@classmethod
391
391
def from_json (cls , data : JsonResponse ) -> "Page" :
@@ -701,13 +701,17 @@ def convert_drawio(self, el: BeautifulSoup, text: str, parent_tags: list[str]) -
701
701
if match := re .search (r"\|diagramName=(.+?)\|" , str (el )):
702
702
drawio_name = match .group (1 )
703
703
preview_name = f"{ drawio_name } .png"
704
- drawio_attachment = self .page .get_attachment_by_title (drawio_name )
705
- preview_attachment = self .page .get_attachment_by_title (preview_name )
704
+ drawio_attachments = self .page .get_attachments_by_title (drawio_name )
705
+ preview_attachments = self .page .get_attachments_by_title (preview_name )
706
+
707
+ if not drawio_attachments or not preview_attachments :
708
+ return f"\n <!-- Drawio diagram `{ drawio_name } ` not found -->\n \n "
709
+
706
710
drawio_relpath = os .path .relpath (
707
- drawio_attachment .export_path .filepath , self .page .export_path .dirpath
711
+ drawio_attachments [ 0 ] .export_path .filepath , self .page .export_path .dirpath
708
712
)
709
713
preview_relpath = os .path .relpath (
710
- preview_attachment .export_path .filepath , self .page .export_path .dirpath
714
+ preview_attachments [ 0 ] .export_path .filepath , self .page .export_path .dirpath
711
715
)
712
716
713
717
drawio_image_embedding = f"} )"
0 commit comments