@@ -573,16 +573,21 @@ pub async fn get_sample_cases(
573573 let mut outputs: Vec < ( usize , String ) > = Vec :: new ( ) ;
574574
575575 for pre_element in pre_elements {
576- let pre_content = pre_element. text ( ) . next ( ) . context ( PARSE_ERROR ) ?;
577- let parent_element = pre_element
578- . parent ( )
579- . and_then ( ElementRef :: wrap)
580- . context ( PARSE_ERROR ) ?;
581- let h3_element = parent_element
582- . select ( & h3_selector)
583- . next ( )
584- . context ( PARSE_ERROR ) ?;
585- let h3_content = h3_element. text ( ) . next ( ) . context ( PARSE_ERROR ) ?;
576+ let pre_content = pre_element. text ( ) . collect :: < String > ( ) ;
577+ let mut h3_content: Option < String > = None ;
578+ let mut cursor = pre_element. parent ( ) ;
579+ while let Some ( node) = cursor {
580+ if let Some ( parent) = ElementRef :: wrap ( node) {
581+ if let Some ( h3_element) = parent. select ( & h3_selector) . next ( ) {
582+ if let Some ( text) = h3_element. text ( ) . next ( ) {
583+ h3_content = Some ( text. to_string ( ) ) ;
584+ break ;
585+ }
586+ }
587+ }
588+ cursor = node. parent ( ) ;
589+ }
590+ let h3_content = h3_content. context ( PARSE_ERROR ) ?;
586591 let is_input = h3_content. contains ( INPUT_HEADER ) ;
587592 let is_output = h3_content. contains ( OUTPUT_HEADER ) ;
588593 if is_input {
@@ -592,15 +597,15 @@ pub async fn get_sample_cases(
592597 . collect :: < String > ( )
593598 . parse ( )
594599 . unwrap ( ) ;
595- inputs. push ( ( index, pre_content. into ( ) ) ) ;
600+ inputs. push ( ( index, pre_content) ) ;
596601 } else if is_output {
597602 let index: usize = h3_content
598603 . chars ( )
599604 . filter ( |c| c. is_ascii_digit ( ) )
600605 . collect :: < String > ( )
601606 . parse ( )
602607 . unwrap ( ) ;
603- outputs. push ( ( index, pre_content. into ( ) ) ) ;
608+ outputs. push ( ( index, pre_content) ) ;
604609 }
605610 }
606611 if let Some ( target) = sample_case_id_arg {
0 commit comments