From 2ce11afbec1dc1279360063fee0135a09b7fc11b Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Fri, 16 Oct 2020 00:52:49 +0800 Subject: [PATCH 1/2] Use double quote for rustdoc html --- src/librustdoc/html/render/mod.rs | 259 +++++++++++++++--------------- 1 file changed, 133 insertions(+), 126 deletions(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 0608c4e32e00b..b43ae9a46af33 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -540,11 +540,11 @@ impl FormatRenderer for Context { }; let sidebar = if let Some(ref version) = cache.crate_version { format!( - "

Crate {}

\ -
\ + "

Crate {}

\ +
\

Version {}

\
\ -

Back to index

", +

Back to index

", crate_name, Escape(version), ) @@ -567,7 +567,7 @@ impl FormatRenderer for Context { page.root_path = "./"; let mut style_files = self.shared.style_files.clone(); - let sidebar = "

Settings

"; + let sidebar = "

Settings

"; style_files.push(StylePath { path: PathBuf::from("settings.css"), disabled: false }); let v = layout::render( &self.shared.layout, @@ -808,7 +808,7 @@ function handleThemeButtonsBlur(e) {{ themePicker.onclick = switchThemeButtonState; themePicker.onblur = handleThemeButtonsBlur; {}.forEach(function(item) {{ - var but = document.createElement('button'); + var but = document.createElement(\"button\"); but.textContent = item; but.onclick = function(el) {{ switchTheme(currentTheme, mainTheme, item, true); @@ -1031,11 +1031,11 @@ themePicker.onblur = handleThemeButtonsBlur; // with rustdoc running in parallel. all_indexes.sort(); { - let mut v = String::from("var searchIndex = JSON.parse('{\\\n"); + let mut v = String::from("var searchIndex = JSON.parse(\"{\\n"); v.push_str(&all_indexes.join(",\\\n")); // "addSearchOptions" has to be called first so the crate filtering can be set before the // search might start (if it's set into the URL for example). - v.push_str("\\\n}');\naddSearchOptions(searchIndex);initSearch(searchIndex);"); + v.push_str("\\\n}\");\naddSearchOptions(searchIndex);initSearch(searchIndex);"); cx.shared.fs.write(&dst, &v)?; } if options.enable_index_page { @@ -1064,10 +1064,9 @@ themePicker.onblur = handleThemeButtonsBlur; krates.dedup(); let content = format!( - "

\ - List of all crates\ -

\ - ", + "

\ + List of all crates\ +

", krates .iter() .map(|s| { @@ -1211,7 +1210,7 @@ impl ItemEntry { impl ItemEntry { crate fn print(&self) -> impl fmt::Display + '_ { crate::html::format::display_fn(move |f| { - write!(f, "{}", self.url, Escape(&self.name)) + write!(f, "{}", self.url, Escape(&self.name)) }) } } @@ -1302,7 +1301,7 @@ fn print_entries(f: &mut Buffer, e: &FxHashSet, title: &str, class: & e.sort(); write!( f, - "

{}

    {}
", + "

{}

    {}
", title, Escape(title), class, @@ -1315,16 +1314,16 @@ impl AllTypes { fn print(self, f: &mut Buffer) { write!( f, - "

\ - \ - \ + "

\ + \ + \ \ - []\ + []\ \ - List of all items\ + List of all items\

" ); print_entries(f, &self.structs, "Structs", "structs"); @@ -1367,18 +1366,18 @@ impl Setting { fn display(&self, root_path: &str, suffix: &str) -> String { match *self { Setting::Section { description, ref sub_settings } => format!( - "
\ -
{}
\ -
{}
+ "
\ +
{}
\ +
{}
", description, sub_settings.iter().map(|s| s.display(root_path, suffix)).collect::() ), Setting::Toggle { js_data_name, description, default_value } => format!( - "
\ -