Skip to content

Commit

Permalink
Use summary_opts() for Markdown summaries
Browse files Browse the repository at this point in the history
It was accidentally changed to use `opts()` in rust-lang#86451.

I also renamed `opts()` to `main_body_opts()` to make this kind of
accidental change less likely.
  • Loading branch information
camelid committed Sep 4, 2021
1 parent fcce644 commit 208a5fd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
17 changes: 9 additions & 8 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ use pulldown_cmark::{
mod tests;

/// Options for rendering Markdown in the main body of documentation.
pub(crate) fn opts() -> Options {
pub(crate) fn main_body_opts() -> Options {
Options::ENABLE_TABLES
| Options::ENABLE_FOOTNOTES
| Options::ENABLE_STRIKETHROUGH
| Options::ENABLE_TASKLISTS
| Options::ENABLE_SMART_PUNCTUATION
}

/// A subset of [`opts()`] used for rendering summaries.
/// A subset of [`main_body_opts()`] used for rendering summaries.
pub(crate) fn summary_opts() -> Options {
Options::ENABLE_STRIKETHROUGH | Options::ENABLE_SMART_PUNCTUATION | Options::ENABLE_TABLES
}
Expand Down Expand Up @@ -975,7 +975,7 @@ impl Markdown<'_> {
}
};

let p = Parser::new_with_broken_link_callback(md, opts(), Some(&mut replacer));
let p = Parser::new_with_broken_link_callback(md, main_body_opts(), Some(&mut replacer));
let p = p.into_offset_iter();

let mut s = String::with_capacity(md.len() * 3 / 2);
Expand All @@ -994,7 +994,7 @@ impl MarkdownWithToc<'_> {
crate fn into_string(self) -> String {
let MarkdownWithToc(md, mut ids, codes, edition, playground) = self;

let p = Parser::new_ext(md, opts()).into_offset_iter();
let p = Parser::new_ext(md, main_body_opts()).into_offset_iter();

let mut s = String::with_capacity(md.len() * 3 / 2);

Expand All @@ -1019,7 +1019,7 @@ impl MarkdownHtml<'_> {
if md.is_empty() {
return String::new();
}
let p = Parser::new_ext(md, opts()).into_offset_iter();
let p = Parser::new_ext(md, main_body_opts()).into_offset_iter();

// Treat inline HTML as plain text.
let p = p.map(|event| match event.0 {
Expand Down Expand Up @@ -1093,7 +1093,7 @@ fn markdown_summary_with_limit(
}
};

let p = Parser::new_with_broken_link_callback(md, opts(), Some(&mut replacer));
let p = Parser::new_with_broken_link_callback(md, summary_opts(), Some(&mut replacer));
let mut p = LinkReplacer::new(p, link_names);

let mut buf = HtmlWithLimit::new(length_limit);
Expand Down Expand Up @@ -1240,7 +1240,8 @@ crate fn markdown_links(md: &str) -> Vec<MarkdownLink> {
});
None
};
let p = Parser::new_with_broken_link_callback(md, opts(), Some(&mut push)).into_offset_iter();
let p = Parser::new_with_broken_link_callback(md, main_body_opts(), Some(&mut push))
.into_offset_iter();

// There's no need to thread an IdMap through to here because
// the IDs generated aren't going to be emitted anywhere.
Expand Down Expand Up @@ -1279,7 +1280,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
return code_blocks;
}

let mut p = Parser::new_ext(md, opts()).into_offset_iter();
let mut p = Parser::new_ext(md, main_body_opts()).into_offset_iter();

while let Some((event, offset)) = p.next() {
if let Event::Start(Tag::CodeBlock(syntax)) = event {
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/passes/bare_urls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::Pass;
use crate::clean::*;
use crate::core::DocContext;
use crate::fold::DocFolder;
use crate::html::markdown::opts;
use crate::html::markdown::main_body_opts;
use core::ops::Range;
use pulldown_cmark::{Event, Parser, Tag};
use regex::Regex;
Expand Down Expand Up @@ -83,7 +83,7 @@ impl<'a, 'tcx> DocFolder for BareUrlsLinter<'a, 'tcx> {
});
};

let mut p = Parser::new_ext(&dox, opts()).into_offset_iter();
let mut p = Parser::new_ext(&dox, main_body_opts()).into_offset_iter();

while let Some((event, range)) = p.next() {
match event {
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/passes/html_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::Pass;
use crate::clean::*;
use crate::core::DocContext;
use crate::fold::DocFolder;
use crate::html::markdown::opts;
use crate::html::markdown::main_body_opts;
use core::ops::Range;
use pulldown_cmark::{Event, Parser, Tag};
use std::iter::Peekable;
Expand Down Expand Up @@ -192,7 +192,7 @@ impl<'a, 'tcx> DocFolder for InvalidHtmlTagsLinter<'a, 'tcx> {
let mut is_in_comment = None;
let mut in_code_block = false;

let p = Parser::new_ext(&dox, opts()).into_offset_iter();
let p = Parser::new_ext(&dox, main_body_opts()).into_offset_iter();

for (event, range) in p {
match event {
Expand Down

0 comments on commit 208a5fd

Please sign in to comment.