@@ -1345,6 +1345,55 @@ impl<'a> Markdown<'a> {
13451345        let  p = TableWrapper :: new ( p) ; 
13461346        CodeBlocks :: new ( p,  codes,  edition,  playground) 
13471347    } 
1348+ 
1349+     /// Convert markdown to (summary, remaining) HTML. 
1350+      /// 
1351+      /// - The summary is the first top-level Markdown element (usually a paragraph, but potentially 
1352+      ///   any block). 
1353+      /// - The remaining docs contain everything after the summary. 
1354+      pub ( crate )  fn  split_summary_and_content ( self )  -> ( Option < String > ,  Option < String > )  { 
1355+         if  self . content . is_empty ( )  { 
1356+             return  ( None ,  None ) ; 
1357+         } 
1358+         let  mut  p = self . into_iter ( ) ; 
1359+ 
1360+         let  mut  event_level = 0 ; 
1361+         let  mut  summary_events = Vec :: new ( ) ; 
1362+         let  mut  get_next_tag = false ; 
1363+ 
1364+         let  mut  end_of_summary = false ; 
1365+         while  let  Some ( event)  = p. next ( )  { 
1366+             match  event { 
1367+                 Event :: Start ( _)  => event_level += 1 , 
1368+                 Event :: End ( kind)  => { 
1369+                     event_level -= 1 ; 
1370+                     if  event_level == 0  { 
1371+                         // We're back at the "top" so it means we're done with the summary. 
1372+                         end_of_summary = true ; 
1373+                         // We surround tables with `<div>` HTML tags so this is a special case. 
1374+                         get_next_tag = kind == TagEnd :: Table ; 
1375+                     } 
1376+                 } 
1377+                 _ => { } 
1378+             } 
1379+             summary_events. push ( event) ; 
1380+             if  end_of_summary { 
1381+                 if  get_next_tag && let  Some ( event)  = p. next ( )  { 
1382+                     summary_events. push ( event) ; 
1383+                 } 
1384+                 break ; 
1385+             } 
1386+         } 
1387+         let  mut  summary = String :: new ( ) ; 
1388+         html:: push_html ( & mut  summary,  summary_events. into_iter ( ) ) ; 
1389+         if  summary. is_empty ( )  { 
1390+             return  ( None ,  None ) ; 
1391+         } 
1392+         let  mut  content = String :: new ( ) ; 
1393+         html:: push_html ( & mut  content,  p) ; 
1394+ 
1395+         if  content. is_empty ( )  {  ( Some ( summary) ,  None )  }  else  {  ( Some ( summary) ,  Some ( content) )  } 
1396+     } 
13481397} 
13491398
13501399impl  MarkdownWithToc < ' _ >  { 
@@ -1416,52 +1465,6 @@ impl MarkdownItemInfo<'_> {
14161465    } 
14171466} 
14181467
1419- pub ( crate )  fn  markdown_split_summary_and_content ( 
1420-     md :  Markdown < ' _ > , 
1421- )  -> ( Option < String > ,  Option < String > )  { 
1422-     if  md. content . is_empty ( )  { 
1423-         return  ( None ,  None ) ; 
1424-     } 
1425-     let  mut  p = md. into_iter ( ) ; 
1426- 
1427-     let  mut  event_level = 0 ; 
1428-     let  mut  summary_events = Vec :: new ( ) ; 
1429-     let  mut  get_next_tag = false ; 
1430- 
1431-     let  mut  end_of_summary = false ; 
1432-     while  let  Some ( event)  = p. next ( )  { 
1433-         match  event { 
1434-             Event :: Start ( _)  => event_level += 1 , 
1435-             Event :: End ( kind)  => { 
1436-                 event_level -= 1 ; 
1437-                 if  event_level == 0  { 
1438-                     // We're back at the "top" so it means we're done with the summary. 
1439-                     end_of_summary = true ; 
1440-                     // We surround tables with `<div>` HTML tags so this is a special case. 
1441-                     get_next_tag = kind == TagEnd :: Table ; 
1442-                 } 
1443-             } 
1444-             _ => { } 
1445-         } 
1446-         summary_events. push ( event) ; 
1447-         if  end_of_summary { 
1448-             if  get_next_tag && let  Some ( event)  = p. next ( )  { 
1449-                 summary_events. push ( event) ; 
1450-             } 
1451-             break ; 
1452-         } 
1453-     } 
1454-     let  mut  summary = String :: new ( ) ; 
1455-     html:: push_html ( & mut  summary,  summary_events. into_iter ( ) ) ; 
1456-     if  summary. is_empty ( )  { 
1457-         return  ( None ,  None ) ; 
1458-     } 
1459-     let  mut  content = String :: new ( ) ; 
1460-     html:: push_html ( & mut  content,  p) ; 
1461- 
1462-     if  content. is_empty ( )  {  ( Some ( summary) ,  None )  }  else  {  ( Some ( summary) ,  Some ( content) )  } 
1463- } 
1464- 
14651468impl  MarkdownSummaryLine < ' _ >  { 
14661469    pub ( crate )  fn  into_string_with_has_more_content ( self )  -> ( String ,  bool )  { 
14671470        let  MarkdownSummaryLine ( md,  links)  = self ; 
0 commit comments