From 0ab8a73ba23534f77821781d13b0a4a24cffb50b Mon Sep 17 00:00:00 2001 From: asolove Date: Sun, 27 Dec 2015 15:17:59 -0700 Subject: [PATCH 1/2] Add anchors around all headers in the content. - Just uses the header's text as its anchor name. Spaces work. Scrolling to the anchor works even when the anchor is added after the dom loads. - Adjust theme css to only style links, not tags used as anchors. --- src/theme/book.css | 8 ++++---- src/theme/book.js | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/theme/book.css b/src/theme/book.css index 93d4c9f0..c73eb4a0 100644 --- a/src/theme/book.css +++ b/src/theme/book.css @@ -315,7 +315,7 @@ h3 { .light .mobile-nav-chapters { background-color: #fafafa; } -.light .content a { +.light .content a:link { color: #4183c4; } .light .theme-popup { @@ -371,7 +371,7 @@ h3 { .coal .mobile-nav-chapters { background-color: #292c2f; } -.coal .content a { +.coal .content a:link { color: #2b79a2; } .coal .theme-popup { @@ -427,7 +427,7 @@ h3 { .navy .mobile-nav-chapters { background-color: #282d3f; } -.navy .content a { +.navy .content a:link { color: #2b79a2; } .navy .theme-popup { @@ -483,7 +483,7 @@ h3 { .rust .mobile-nav-chapters { background-color: #3b2e2a; } -.rust .content a { +.rust .content a:link { color: #2b79a2; } .rust .theme-popup { diff --git a/src/theme/book.js b/src/theme/book.js index b07c9929..3a7ce712 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -28,6 +28,15 @@ $( document ).ready(function() { var html = $("html"); var sidebar = $("#sidebar"); var page_wrapper = $("#page-wrapper"); + var content = $("#content"); + + + // Add anchors for all content headers + content.find("h1, h2, h3, h4, h5").wrap(function(){ + var wrapper = $(""); + wrapper.attr("name", $(this).text()); + return wrapper; + }); // Toggle sidebar From 4dfa15cffa5ca8cb250a1e07a4dae47606960c79 Mon Sep 17 00:00:00 2001 From: asolove Date: Sun, 27 Dec 2015 21:13:31 -0700 Subject: [PATCH 2/2] Update .styl file. Ran the compile and it results in exactly what I did by hand, d'oh. --- src/theme/stylus/themes/base.styl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/theme/stylus/themes/base.styl b/src/theme/stylus/themes/base.styl index e222fe4a..b9a6d893 100644 --- a/src/theme/stylus/themes/base.styl +++ b/src/theme/stylus/themes/base.styl @@ -51,7 +51,7 @@ background-color: $sidebar-bg } - .content a { + .content a:link { color: $links }