File tree 1 file changed +19
-7
lines changed
1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -731,18 +731,30 @@ pub fn markdown_links(md: &str) -> Vec<String> {
731
731
opts. insert ( OPTION_ENABLE_TABLES ) ;
732
732
opts. insert ( OPTION_ENABLE_FOOTNOTES ) ;
733
733
734
- let p = Parser :: new_ext ( md, opts) ;
735
-
736
- let iter = Footnotes :: new ( HeadingLinks :: new ( p, None ) ) ;
737
734
let mut links = vec ! [ ] ;
735
+ let shortcut_links = RefCell :: new ( vec ! [ ] ) ;
736
+
737
+ {
738
+ let push = |_: & str , s : & str | {
739
+ shortcut_links. borrow_mut ( ) . push ( s. to_owned ( ) ) ;
740
+ None
741
+ } ;
742
+ let p = Parser :: new_with_broken_link_callback ( md, opts,
743
+ Some ( & push) ) ;
738
744
739
- for ev in iter {
740
- if let Event :: Start ( Tag :: Link ( dest, _) ) = ev {
741
- debug ! ( "found link: {}" , dest) ;
742
- links. push ( dest. into_owned ( ) ) ;
745
+ let iter = Footnotes :: new ( HeadingLinks :: new ( p, None ) ) ;
746
+
747
+ for ev in iter {
748
+ if let Event :: Start ( Tag :: Link ( dest, _) ) = ev {
749
+ debug ! ( "found link: {}" , dest) ;
750
+ links. push ( dest. into_owned ( ) ) ;
751
+ }
743
752
}
744
753
}
745
754
755
+ let mut shortcut_links = shortcut_links. into_inner ( ) ;
756
+ links. extend ( shortcut_links. drain ( ..) ) ;
757
+
746
758
links
747
759
}
748
760
You can’t perform that action at this time.
0 commit comments