@@ -33,8 +33,7 @@ use crate::html::toc::TocBuilder;
3333use crate :: html:: highlight;
3434use crate :: test;
3535
36- use pulldown_cmark:: { html, Event , Tag , Parser } ;
37- use pulldown_cmark:: { Options , OPTION_ENABLE_FOOTNOTES , OPTION_ENABLE_TABLES } ;
36+ use pulldown_cmark:: { html, Event , Options , Parser , Tag } ;
3837
3938/// A unit struct which has the `fmt::Display` trait implemented. When
4039/// formatted, this struct will emit the HTML corresponding to the rendered
@@ -297,12 +296,12 @@ impl<'a, 'b, I: Iterator<Item = Event<'a>>> Iterator for LinkReplacer<'a, 'b, I>
297296
298297 fn next ( & mut self ) -> Option < Self :: Item > {
299298 let event = self . inner . next ( ) ;
300- if let Some ( Event :: Start ( Tag :: Link ( dest, text) ) ) = event {
299+ if let Some ( Event :: Start ( Tag :: Link ( kind , dest, text) ) ) = event {
301300 if let Some ( & ( _, ref replace) ) = self . links . into_iter ( ) . find ( |link| & * link. 0 == & * dest)
302301 {
303- Some ( Event :: Start ( Tag :: Link ( replace. to_owned ( ) . into ( ) , text) ) )
302+ Some ( Event :: Start ( Tag :: Link ( kind , replace. to_owned ( ) . into ( ) , text) ) )
304303 } else {
305- Some ( Event :: Start ( Tag :: Link ( dest, text) ) )
304+ Some ( Event :: Start ( Tag :: Link ( kind , dest, text) ) )
306305 }
307306 } else {
308307 event
@@ -393,7 +392,7 @@ fn check_if_allowed_tag(t: &Tag<'_>) -> bool {
393392 | Tag :: Emphasis
394393 | Tag :: Strong
395394 | Tag :: Code
396- | Tag :: Link ( _, _)
395+ | Tag :: Link ( _, _, _ )
397396 | Tag :: BlockQuote => true ,
398397 _ => false ,
399398 }
@@ -688,8 +687,8 @@ impl<'a> fmt::Display for Markdown<'a> {
688687 // This is actually common enough to special-case
689688 if md. is_empty ( ) { return Ok ( ( ) ) }
690689 let mut opts = Options :: empty ( ) ;
691- opts. insert ( OPTION_ENABLE_TABLES ) ;
692- opts. insert ( OPTION_ENABLE_FOOTNOTES ) ;
690+ opts. insert ( Options :: ENABLE_TABLES ) ;
691+ opts. insert ( Options :: ENABLE_FOOTNOTES ) ;
693692
694693 let replacer = |_: & str , s : & str | {
695694 if let Some ( & ( _, ref replace) ) = links. into_iter ( ) . find ( |link| & * link. 0 == s) {
@@ -719,8 +718,8 @@ impl<'a> fmt::Display for MarkdownWithToc<'a> {
719718 let mut ids = ids. borrow_mut ( ) ;
720719
721720 let mut opts = Options :: empty ( ) ;
722- opts. insert ( OPTION_ENABLE_TABLES ) ;
723- opts. insert ( OPTION_ENABLE_FOOTNOTES ) ;
721+ opts. insert ( Options :: ENABLE_TABLES ) ;
722+ opts. insert ( Options :: ENABLE_FOOTNOTES ) ;
724723
725724 let p = Parser :: new_ext ( md, opts) ;
726725
@@ -749,8 +748,8 @@ impl<'a> fmt::Display for MarkdownHtml<'a> {
749748 // This is actually common enough to special-case
750749 if md. is_empty ( ) { return Ok ( ( ) ) }
751750 let mut opts = Options :: empty ( ) ;
752- opts. insert ( OPTION_ENABLE_TABLES ) ;
753- opts. insert ( OPTION_ENABLE_FOOTNOTES ) ;
751+ opts. insert ( Options :: ENABLE_TABLES ) ;
752+ opts. insert ( Options :: ENABLE_FOOTNOTES ) ;
754753
755754 let p = Parser :: new_ext ( md, opts) ;
756755
@@ -869,8 +868,8 @@ pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
869868 }
870869
871870 let mut opts = Options :: empty ( ) ;
872- opts. insert ( OPTION_ENABLE_TABLES ) ;
873- opts. insert ( OPTION_ENABLE_FOOTNOTES ) ;
871+ opts. insert ( Options :: ENABLE_TABLES ) ;
872+ opts. insert ( Options :: ENABLE_FOOTNOTES ) ;
874873
875874 let mut links = vec ! [ ] ;
876875 let shortcut_links = RefCell :: new ( vec ! [ ] ) ;
@@ -903,12 +902,11 @@ pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
903902 let iter = Footnotes :: new ( HeadingLinks :: new ( p, None , & mut ids) ) ;
904903
905904 for ev in iter {
906- if let Event :: Start ( Tag :: Link ( dest, _) ) = ev {
905+ if let Event :: Start ( Tag :: Link ( _ , dest, _) ) = ev {
907906 debug ! ( "found link: {}" , dest) ;
908- links. push ( match dest {
909- Cow :: Borrowed ( s) => ( s. to_owned ( ) , locate ( s) ) ,
910- Cow :: Owned ( s) => ( s, None ) ,
911- } ) ;
907+ let dest = dest. into_string ( ) ;
908+ let loc = locate ( & dest) ;
909+ links. push ( ( dest, loc) ) ;
912910 }
913911 }
914912 }
@@ -940,8 +938,8 @@ crate fn rust_code_blocks(md: &str) -> Vec<RustCodeBlock> {
940938 }
941939
942940 let mut opts = Options :: empty ( ) ;
943- opts. insert ( OPTION_ENABLE_TABLES ) ;
944- opts. insert ( OPTION_ENABLE_FOOTNOTES ) ;
941+ opts. insert ( Options :: ENABLE_TABLES ) ;
942+ opts. insert ( Options :: ENABLE_FOOTNOTES ) ;
945943 let mut p = Parser :: new_ext ( md, opts) ;
946944
947945 let mut code_block_start = 0 ;
@@ -1013,7 +1011,7 @@ crate fn rust_code_blocks(md: &str) -> Vec<RustCodeBlock> {
10131011 end : code_end,
10141012 } ,
10151013 syntax : if !syntax. is_empty ( ) {
1016- Some ( syntax. into_owned ( ) )
1014+ Some ( syntax. into_string ( ) )
10171015 } else {
10181016 None
10191017 } ,
0 commit comments