@@ -35,6 +35,7 @@ def run_with_defaults(self) -> list[nodes.Node]:
3535 )
3636 self .set_source_info (tab_set )
3737 self .state .nested_parse (self .content , self .content_offset , tab_set )
38+ valid_children = []
3839 for item in tab_set .children :
3940 if not is_component (item , "tab-item" ):
4041 LOGGER .warning (
@@ -44,9 +45,12 @@ def run_with_defaults(self) -> list[nodes.Node]:
4445 type = WARNING_TYPE ,
4546 subtype = "tab" ,
4647 )
47- break
48+ continue # Skip invalid children instead of breaking
4849 if "sync_id" in item .children [0 ]:
4950 item .children [0 ]["sync_group" ] = self .options .get ("sync-group" , "tab" )
51+ valid_children .append (item )
52+
53+ tab_set .children = valid_children
5054 return [tab_set ]
5155
5256
@@ -240,10 +244,17 @@ def run(self) -> None:
240244 selected_idx = 0 if selected_idx is None else selected_idx
241245
242246 for idx , tab_item in enumerate (tab_set .children ):
243- try :
244- tab_label , tab_content = tab_item .children
245- except ValueError :
246- raise
247+ if not is_component (tab_item , "tab-item" ):
248+ continue # Skip non tab-item children
249+ if len (tab_item .children ) != 2 :
250+ LOGGER .warning (
251+ f"Malformed 'tab-item' directive [{ WARNING_TYPE } .tab]" ,
252+ location = tab_item ,
253+ type = WARNING_TYPE ,
254+ subtype = "tab" ,
255+ )
256+ continue
257+ tab_label , tab_content = tab_item .children
247258 tab_item_identity = tab_item_id_base + str (tab_item_id_num )
248259 tab_item_id_num += 1
249260
0 commit comments