@@ -62,22 +62,22 @@ def get_folder_path_for_element(element: Any) -> str:
6262 """Get folder path by finding all parent DLs and their associated H3 folders."""
6363 path_parts = []
6464 current_dl = element .find_parent ("dl" )
65-
65+
6666 # Walk up the tree through all parent DLs
6767 visited_dls = set ()
6868 while current_dl :
6969 if current_dl in visited_dls :
7070 break
7171 visited_dls .add (current_dl )
72-
72+
7373 # Find the H3 that is associated with this DL
7474 # The H3 can be:
7575 # 1. A direct previous sibling of the DL
7676 # 2. Inside a DT that is a previous sibling of the DL
7777 # 3. Inside a DT that is a child of the parent DL
78-
78+
7979 folder_name = None
80-
80+
8181 # Method 1: Check if H3 is a direct previous sibling
8282 for prev_sib in current_dl .previous_siblings :
8383 if not hasattr (prev_sib , "name" ):
@@ -91,7 +91,7 @@ def get_folder_path_for_element(element: Any) -> str:
9191 if h3 and hasattr (h3 , "get_text" ):
9292 folder_name = h3 .get_text (strip = True )
9393 break
94-
94+
9595 # Method 3: Check parent DL's children for DT with H3 before this DL
9696 if not folder_name and current_dl .parent :
9797 parent = current_dl .parent
@@ -120,25 +120,25 @@ def get_folder_path_for_element(element: Any) -> str:
120120 break
121121 if folder_name :
122122 break
123-
123+
124124 if folder_name :
125125 path_parts .insert (0 , folder_name )
126-
126+
127127 # Move to parent DL
128128 current_dl = current_dl .find_parent ("dl" )
129-
129+
130130 return "/" .join (path_parts )
131131
132132 # Find all bookmark links (A tags)
133133 all_links = soup .find_all ("a" , href = True )
134-
134+
135135 for link in all_links :
136136 url = link .get ("href" , "" ).strip ()
137137 if not url or url .startswith ("data:" ):
138138 continue
139-
139+
140140 title = link .get_text (strip = True ) or url
141-
141+
142142 # Parse ADD_DATE if present
143143 added = None
144144 add_date = link .get ("add_date" )
@@ -148,10 +148,10 @@ def get_folder_path_for_element(element: Any) -> str:
148148 added = datetime .fromtimestamp (timestamp )
149149 except (ValueError , OSError ):
150150 pass
151-
151+
152152 # Get folder path
153153 folder_path = get_folder_path_for_element (link )
154-
154+
155155 bookmark = Bookmark (
156156 url = url ,
157157 title = title ,
@@ -227,4 +227,3 @@ def parse_node(node: dict[str, Any], folder_path: str = "") -> None:
227227 parse_node (roots [root_key ], root_key .replace ("_" , " " ).title ())
228228
229229 return collection
230-
0 commit comments