From 808f9dd08be3f47f2c32d1027232e7ac086ebde5 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 19 Sep 2020 15:57:19 -0400 Subject: [PATCH] Fix rustdoc styles for very old docs Previously this used the selector link[type='text/css'][href*='normalize'] to inject the vendored HTML. Unfortunately, this selector did not exist in very old versions of rustdoc. Instead, this now adds the vendored.css stylesheet just before rustdoc.css. --- src/utils/html.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/html.rs b/src/utils/html.rs index b8d47f158..961b5eea3 100644 --- a/src/utils/html.rs +++ b/src/utils/html.rs @@ -64,7 +64,8 @@ pub(crate) fn rewrite_lol( Ok(()) }; - // Append `vendored.css` before the first stylesheet (rustdoc's first stylesheet is `normalize.css`). + // Append `vendored.css` before `rustdoc.css`, so that the duplicate copy of + // `normalize.css` will be overridden by the later version. let first_stylesheet_handler = |head: &mut Element| { head.before(&tera_vendored_css, ContentType::Html); @@ -74,7 +75,7 @@ pub(crate) fn rewrite_lol( let (head_selector, body_selector, first_stylesheet_selector) = ( "head".parse().unwrap(), "body".parse().unwrap(), - "link[type='text/css'][href*='normalize']".parse().unwrap(), + "link[type='text/css'][href*='rustdoc']".parse().unwrap(), ); let element_content_handlers = vec![ (