@@ -33,8 +33,7 @@ use crate::html::toc::TocBuilder;
33
33
use crate :: html:: highlight;
34
34
use crate :: test;
35
35
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 } ;
38
37
39
38
/// A unit struct which has the `fmt::Display` trait implemented. When
40
39
/// 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>
297
296
298
297
fn next ( & mut self ) -> Option < Self :: Item > {
299
298
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 {
301
300
if let Some ( & ( _, ref replace) ) = self . links . into_iter ( ) . find ( |link| & * link. 0 == & * dest)
302
301
{
303
- Some ( Event :: Start ( Tag :: Link ( replace. to_owned ( ) . into ( ) , text) ) )
302
+ Some ( Event :: Start ( Tag :: Link ( kind , replace. to_owned ( ) . into ( ) , text) ) )
304
303
} else {
305
- Some ( Event :: Start ( Tag :: Link ( dest, text) ) )
304
+ Some ( Event :: Start ( Tag :: Link ( kind , dest, text) ) )
306
305
}
307
306
} else {
308
307
event
@@ -393,7 +392,7 @@ fn check_if_allowed_tag(t: &Tag<'_>) -> bool {
393
392
| Tag :: Emphasis
394
393
| Tag :: Strong
395
394
| Tag :: Code
396
- | Tag :: Link ( _, _)
395
+ | Tag :: Link ( _, _, _ )
397
396
| Tag :: BlockQuote => true ,
398
397
_ => false ,
399
398
}
@@ -688,8 +687,8 @@ impl<'a> fmt::Display for Markdown<'a> {
688
687
// This is actually common enough to special-case
689
688
if md. is_empty ( ) { return Ok ( ( ) ) }
690
689
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 ) ;
693
692
694
693
let replacer = |_: & str , s : & str | {
695
694
if let Some ( & ( _, ref replace) ) = links. into_iter ( ) . find ( |link| & * link. 0 == s) {
@@ -719,8 +718,8 @@ impl<'a> fmt::Display for MarkdownWithToc<'a> {
719
718
let mut ids = ids. borrow_mut ( ) ;
720
719
721
720
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 ) ;
724
723
725
724
let p = Parser :: new_ext ( md, opts) ;
726
725
@@ -749,8 +748,8 @@ impl<'a> fmt::Display for MarkdownHtml<'a> {
749
748
// This is actually common enough to special-case
750
749
if md. is_empty ( ) { return Ok ( ( ) ) }
751
750
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 ) ;
754
753
755
754
let p = Parser :: new_ext ( md, opts) ;
756
755
@@ -869,8 +868,8 @@ pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
869
868
}
870
869
871
870
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 ) ;
874
873
875
874
let mut links = vec ! [ ] ;
876
875
let shortcut_links = RefCell :: new ( vec ! [ ] ) ;
@@ -903,12 +902,11 @@ pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
903
902
let iter = Footnotes :: new ( HeadingLinks :: new ( p, None , & mut ids) ) ;
904
903
905
904
for ev in iter {
906
- if let Event :: Start ( Tag :: Link ( dest, _) ) = ev {
905
+ if let Event :: Start ( Tag :: Link ( _ , dest, _) ) = ev {
907
906
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) ) ;
912
910
}
913
911
}
914
912
}
@@ -940,8 +938,8 @@ crate fn rust_code_blocks(md: &str) -> Vec<RustCodeBlock> {
940
938
}
941
939
942
940
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 ) ;
945
943
let mut p = Parser :: new_ext ( md, opts) ;
946
944
947
945
let mut code_block_start = 0 ;
@@ -1013,7 +1011,7 @@ crate fn rust_code_blocks(md: &str) -> Vec<RustCodeBlock> {
1013
1011
end : code_end,
1014
1012
} ,
1015
1013
syntax : if !syntax. is_empty ( ) {
1016
- Some ( syntax. into_owned ( ) )
1014
+ Some ( syntax. into_string ( ) )
1017
1015
} else {
1018
1016
None
1019
1017
} ,
0 commit comments