@@ -505,7 +505,7 @@ fn map_links<'e>(
505
505
Event :: End ( Tag :: Link ( link_type, target, _) ) => {
506
506
in_link = false ;
507
507
Event :: End ( Tag :: Link (
508
- end_link_type. unwrap_or ( link_type) ,
508
+ end_link_type. take ( ) . unwrap_or ( link_type) ,
509
509
end_link_target. take ( ) . unwrap_or ( target) ,
510
510
CowStr :: Borrowed ( "" ) ,
511
511
) )
@@ -514,7 +514,7 @@ fn map_links<'e>(
514
514
let ( link_type, link_target_s, link_name) =
515
515
callback ( & end_link_target. take ( ) . unwrap ( ) , & s, range, end_link_type. unwrap ( ) ) ;
516
516
end_link_target = Some ( CowStr :: Boxed ( link_target_s. into ( ) ) ) ;
517
- if !matches ! ( end_link_type, Some ( LinkType :: Autolink ) ) {
517
+ if !matches ! ( end_link_type, Some ( LinkType :: Autolink ) ) && link_type . is_some ( ) {
518
518
end_link_type = link_type;
519
519
}
520
520
Event :: Text ( CowStr :: Boxed ( link_name. into ( ) ) )
@@ -523,7 +523,7 @@ fn map_links<'e>(
523
523
let ( link_type, link_target_s, link_name) =
524
524
callback ( & end_link_target. take ( ) . unwrap ( ) , & s, range, end_link_type. unwrap ( ) ) ;
525
525
end_link_target = Some ( CowStr :: Boxed ( link_target_s. into ( ) ) ) ;
526
- if !matches ! ( end_link_type, Some ( LinkType :: Autolink ) ) {
526
+ if !matches ! ( end_link_type, Some ( LinkType :: Autolink ) ) && link_type . is_some ( ) {
527
527
end_link_type = link_type;
528
528
}
529
529
Event :: Code ( CowStr :: Boxed ( link_name. into ( ) ) )
0 commit comments