mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Rollup merge of #107725 - GuillaumeGomez:turn-markdownwithtoc-into-struct, r=notriddle
Turn MarkdownWithToc into a struct with named fields Extracted the commit from https://github.com/rust-lang/rust/pull/107640. r? `@notriddle`
This commit is contained in:
commit
4e163af1e5
@ -102,14 +102,14 @@ pub struct Markdown<'a> {
|
|||||||
/// E.g. if `heading_offset: HeadingOffset::H2`, then `# something` renders an `<h2>`.
|
/// E.g. if `heading_offset: HeadingOffset::H2`, then `# something` renders an `<h2>`.
|
||||||
pub heading_offset: HeadingOffset,
|
pub heading_offset: HeadingOffset,
|
||||||
}
|
}
|
||||||
/// A tuple struct like `Markdown` that renders the markdown with a table of contents.
|
/// A struct like `Markdown` that renders the markdown with a table of contents.
|
||||||
pub(crate) struct MarkdownWithToc<'a>(
|
pub(crate) struct MarkdownWithToc<'a> {
|
||||||
pub(crate) &'a str,
|
pub(crate) content: &'a str,
|
||||||
pub(crate) &'a mut IdMap,
|
pub(crate) ids: &'a mut IdMap,
|
||||||
pub(crate) ErrorCodes,
|
pub(crate) error_codes: ErrorCodes,
|
||||||
pub(crate) Edition,
|
pub(crate) edition: Edition,
|
||||||
pub(crate) &'a Option<Playground>,
|
pub(crate) playground: &'a Option<Playground>,
|
||||||
);
|
}
|
||||||
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags
|
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags
|
||||||
/// and includes no paragraph tags.
|
/// and includes no paragraph tags.
|
||||||
pub(crate) struct MarkdownItemInfo<'a>(pub(crate) &'a str, pub(crate) &'a mut IdMap);
|
pub(crate) struct MarkdownItemInfo<'a>(pub(crate) &'a str, pub(crate) &'a mut IdMap);
|
||||||
@ -1048,7 +1048,7 @@ impl Markdown<'_> {
|
|||||||
|
|
||||||
impl MarkdownWithToc<'_> {
|
impl MarkdownWithToc<'_> {
|
||||||
pub(crate) fn into_string(self) -> String {
|
pub(crate) fn into_string(self) -> String {
|
||||||
let MarkdownWithToc(md, ids, codes, edition, playground) = self;
|
let MarkdownWithToc { content: md, ids, error_codes: codes, edition, playground } = self;
|
||||||
|
|
||||||
let p = Parser::new_ext(md, main_body_opts()).into_offset_iter();
|
let p = Parser::new_ext(md, main_body_opts()).into_offset_iter();
|
||||||
|
|
||||||
|
@ -72,7 +72,14 @@ pub(crate) fn render<P: AsRef<Path>>(
|
|||||||
let mut ids = IdMap::new();
|
let mut ids = IdMap::new();
|
||||||
let error_codes = ErrorCodes::from(options.unstable_features.is_nightly_build());
|
let error_codes = ErrorCodes::from(options.unstable_features.is_nightly_build());
|
||||||
let text = if !options.markdown_no_toc {
|
let text = if !options.markdown_no_toc {
|
||||||
MarkdownWithToc(text, &mut ids, error_codes, edition, &playground).into_string()
|
MarkdownWithToc {
|
||||||
|
content: text,
|
||||||
|
ids: &mut ids,
|
||||||
|
error_codes,
|
||||||
|
edition,
|
||||||
|
playground: &playground,
|
||||||
|
}
|
||||||
|
.into_string()
|
||||||
} else {
|
} else {
|
||||||
Markdown {
|
Markdown {
|
||||||
content: text,
|
content: text,
|
||||||
|
Loading…
Reference in New Issue
Block a user