@@ -2349,7 +2349,7 @@ impl Context {
23492349 } ;
23502350 let short = short. to_string ( ) ;
23512351 map. entry ( short) . or_default ( )
2352- . push ( ( myname, Some ( plain_summary_line ( item. doc_value ( ) ) ) ) ) ;
2352+ . push ( ( myname, Some ( plain_summary_line ( item. doc_value ( ) ) . 0 ) ) ) ;
23532353 }
23542354
23552355 if self . shared . sort_modules_alphabetically {
@@ -2563,9 +2563,24 @@ fn shorter(s: Option<&str>) -> String {
25632563}
25642564
25652565#[ inline]
2566- fn plain_summary_line ( s : Option < & str > ) -> String {
2566+ fn get_links < ' a , T : Iterator < Item = & ' a str > > ( it : T ) -> Vec < ( String , String ) > {
2567+ it. filter ( |line| line. starts_with ( '[' ) && line. split ( "]: " ) . count ( ) == 2 )
2568+ . map ( |line| {
2569+ let parts = line. split ( "]: " ) . collect :: < Vec < _ > > ( ) ;
2570+ ( ( & parts[ 0 ] [ 1 ..] ) . to_owned ( ) , parts[ 1 ] . trim ( ) . to_owned ( ) )
2571+ } )
2572+ . collect :: < Vec < _ > > ( )
2573+ }
2574+
2575+ #[ inline]
2576+ fn plain_summary_line ( s : Option < & str > ) -> ( String , Vec < ( String , String ) > ) {
25672577 let line = shorter ( s) . replace ( "\n " , " " ) ;
2568- markdown:: plain_summary_line_full ( & line[ ..] , false )
2578+ let links = if let Some ( ref s) = s {
2579+ get_links ( s. split ( '\n' ) . skip ( 1 ) )
2580+ } else {
2581+ Vec :: new ( )
2582+ } ;
2583+ ( markdown:: plain_summary_line_full ( & line[ ..] , false ) , links)
25692584}
25702585
25712586#[ inline]
@@ -2607,13 +2622,16 @@ fn document_short(
26072622 prefix : & str , is_hidden : bool
26082623) -> fmt:: Result {
26092624 if let Some ( s) = item. doc_value ( ) {
2610- let markdown = if s. contains ( '\n' ) {
2611- format ! ( "{} [Read more]({})" ,
2612- & plain_summary_line ( Some ( s ) ) , naive_assoc_href( item, link) )
2625+ let ( markdown, mut links ) = if s. contains ( '\n' ) {
2626+ let ( text , links ) = plain_summary_line ( Some ( s ) ) ;
2627+ ( format ! ( "{} [Read more]({})" , & text , naive_assoc_href( item, link) ) , links )
26132628 } else {
26142629 plain_summary_line ( Some ( s) )
26152630 } ;
2616- render_markdown ( w, cx, & markdown, item. links ( ) , prefix, is_hidden) ?;
2631+ for link in item. links ( ) {
2632+ links. push ( link. clone ( ) ) ;
2633+ }
2634+ render_markdown ( w, cx, & markdown, links, prefix, is_hidden) ?;
26172635 } else if !prefix. is_empty ( ) {
26182636 write ! ( w, "<div class='docblock{}'>{}</div>" ,
26192637 if is_hidden { " hidden" } else { "" } ,
0 commit comments