@@ -48,17 +48,21 @@ use pulldown_cmark::{
48
48
mod tests;
49
49
50
50
/// Options for rendering Markdown in the main body of documentation.
51
- pub ( crate ) fn opts ( ) -> Options {
51
+ pub ( crate ) fn main_body_opts ( ) -> Options {
52
52
Options :: ENABLE_TABLES
53
53
| Options :: ENABLE_FOOTNOTES
54
54
| Options :: ENABLE_STRIKETHROUGH
55
55
| Options :: ENABLE_TASKLISTS
56
56
| Options :: ENABLE_SMART_PUNCTUATION
57
57
}
58
58
59
- /// A subset of [`opts()`] used for rendering summaries .
59
+ /// Options for rendering Markdown in summaries (e.g., in search results) .
60
60
pub ( crate ) fn summary_opts ( ) -> Options {
61
- Options :: ENABLE_STRIKETHROUGH | Options :: ENABLE_SMART_PUNCTUATION | Options :: ENABLE_TABLES
61
+ Options :: ENABLE_TABLES
62
+ | Options :: ENABLE_FOOTNOTES
63
+ | Options :: ENABLE_STRIKETHROUGH
64
+ | Options :: ENABLE_TASKLISTS
65
+ | Options :: ENABLE_SMART_PUNCTUATION
62
66
}
63
67
64
68
/// When `to_string` is called, this struct will emit the HTML corresponding to
@@ -981,7 +985,7 @@ impl Markdown<'_> {
981
985
}
982
986
} ;
983
987
984
- let p = Parser :: new_with_broken_link_callback ( md, opts ( ) , Some ( & mut replacer) ) ;
988
+ let p = Parser :: new_with_broken_link_callback ( md, main_body_opts ( ) , Some ( & mut replacer) ) ;
985
989
let p = p. into_offset_iter ( ) ;
986
990
987
991
let mut s = String :: with_capacity ( md. len ( ) * 3 / 2 ) ;
@@ -1000,7 +1004,7 @@ impl MarkdownWithToc<'_> {
1000
1004
crate fn into_string ( self ) -> String {
1001
1005
let MarkdownWithToc ( md, mut ids, codes, edition, playground) = self ;
1002
1006
1003
- let p = Parser :: new_ext ( md, opts ( ) ) . into_offset_iter ( ) ;
1007
+ let p = Parser :: new_ext ( md, main_body_opts ( ) ) . into_offset_iter ( ) ;
1004
1008
1005
1009
let mut s = String :: with_capacity ( md. len ( ) * 3 / 2 ) ;
1006
1010
@@ -1025,7 +1029,7 @@ impl MarkdownHtml<'_> {
1025
1029
if md. is_empty ( ) {
1026
1030
return String :: new ( ) ;
1027
1031
}
1028
- let p = Parser :: new_ext ( md, opts ( ) ) . into_offset_iter ( ) ;
1032
+ let p = Parser :: new_ext ( md, main_body_opts ( ) ) . into_offset_iter ( ) ;
1029
1033
1030
1034
// Treat inline HTML as plain text.
1031
1035
let p = p. map ( |event| match event. 0 {
@@ -1099,7 +1103,7 @@ fn markdown_summary_with_limit(
1099
1103
}
1100
1104
} ;
1101
1105
1102
- let p = Parser :: new_with_broken_link_callback ( md, opts ( ) , Some ( & mut replacer) ) ;
1106
+ let p = Parser :: new_with_broken_link_callback ( md, summary_opts ( ) , Some ( & mut replacer) ) ;
1103
1107
let mut p = LinkReplacer :: new ( p, link_names) ;
1104
1108
1105
1109
let mut buf = HtmlWithLimit :: new ( length_limit) ;
@@ -1246,7 +1250,8 @@ crate fn markdown_links(md: &str) -> Vec<MarkdownLink> {
1246
1250
} ) ;
1247
1251
None
1248
1252
} ;
1249
- let p = Parser :: new_with_broken_link_callback ( md, opts ( ) , Some ( & mut push) ) . into_offset_iter ( ) ;
1253
+ let p = Parser :: new_with_broken_link_callback ( md, main_body_opts ( ) , Some ( & mut push) )
1254
+ . into_offset_iter ( ) ;
1250
1255
1251
1256
// There's no need to thread an IdMap through to here because
1252
1257
// the IDs generated aren't going to be emitted anywhere.
@@ -1285,7 +1290,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
1285
1290
return code_blocks;
1286
1291
}
1287
1292
1288
- let mut p = Parser :: new_ext ( md, opts ( ) ) . into_offset_iter ( ) ;
1293
+ let mut p = Parser :: new_ext ( md, main_body_opts ( ) ) . into_offset_iter ( ) ;
1289
1294
1290
1295
while let Some ( ( event, offset) ) = p. next ( ) {
1291
1296
if let Event :: Start ( Tag :: CodeBlock ( syntax) ) = event {
0 commit comments