@@ -32,11 +32,13 @@ use crate::{
32
32
/// Weblink to an item's documentation.
33
33
pub ( crate ) type DocumentationLink = String ;
34
34
35
+ const MARKDOWN_OPTIONS : Options =
36
+ Options :: ENABLE_FOOTNOTES . union ( Options :: ENABLE_TABLES ) . union ( Options :: ENABLE_TASKLISTS ) ;
37
+
35
38
/// Rewrite documentation links in markdown to point to an online host (e.g. docs.rs)
36
39
pub ( crate ) fn rewrite_links ( db : & RootDatabase , markdown : & str , definition : Definition ) -> String {
37
40
let mut cb = broken_link_clone_cb;
38
- let doc =
39
- Parser :: new_with_broken_link_callback ( markdown, Options :: ENABLE_TASKLISTS , Some ( & mut cb) ) ;
41
+ let doc = Parser :: new_with_broken_link_callback ( markdown, MARKDOWN_OPTIONS , Some ( & mut cb) ) ;
40
42
41
43
let doc = map_links ( doc, |target, title| {
42
44
// This check is imperfect, there's some overlap between valid intra-doc links
@@ -75,13 +77,11 @@ pub(crate) fn rewrite_links(db: &RootDatabase, markdown: &str, definition: Defin
75
77
pub ( crate ) fn remove_links ( markdown : & str ) -> String {
76
78
let mut drop_link = false ;
77
79
78
- let opts = Options :: ENABLE_TASKLISTS | Options :: ENABLE_FOOTNOTES ;
79
-
80
80
let mut cb = |_: BrokenLink | {
81
81
let empty = InlineStr :: try_from ( "" ) . unwrap ( ) ;
82
82
Some ( ( CowStr :: Inlined ( empty) , CowStr :: Inlined ( empty) ) )
83
83
} ;
84
- let doc = Parser :: new_with_broken_link_callback ( markdown, opts , Some ( & mut cb) ) ;
84
+ let doc = Parser :: new_with_broken_link_callback ( markdown, MARKDOWN_OPTIONS , Some ( & mut cb) ) ;
85
85
let doc = doc. filter_map ( move |evt| match evt {
86
86
Event :: Start ( Tag :: Link ( link_type, target, title) ) => {
87
87
if link_type == LinkType :: Inline && target. contains ( "://" ) {
@@ -151,7 +151,7 @@ pub(crate) fn extract_definitions_from_docs(
151
151
) -> Vec < ( TextRange , String , Option < hir:: Namespace > ) > {
152
152
Parser :: new_with_broken_link_callback (
153
153
docs. as_str ( ) ,
154
- Options :: ENABLE_TASKLISTS ,
154
+ MARKDOWN_OPTIONS ,
155
155
Some ( & mut broken_link_clone_cb) ,
156
156
)
157
157
. into_offset_iter ( )
0 commit comments