aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-04-02 18:10:52 +0930
committerGitHub <noreply@github.com>2017-04-02 18:10:52 +0930
commit2458e078187369c20957cf555902cf00b96aa4df (patch)
treedd595ed2cb213f88a2d7e011e6f4b5584f363b3d
parent6f3678ce36bcab6bfbe60f205d2e36615f4afba4 (diff)
parentb5c56090ee5f71134b85e3cdf7e3b89093649fac (diff)
downloadrails-2458e078187369c20957cf555902cf00b96aa4df.tar.gz
rails-2458e078187369c20957cf555902cf00b96aa4df.tar.bz2
rails-2458e078187369c20957cf555902cf00b96aa4df.zip
Merge pull request #28641 from diazruy/anchors
Add anchor links to all headers
-rw-r--r--guides/assets/stylesheets/main.css3
-rw-r--r--guides/rails_guides/markdown.rb4
2 files changed, 7 insertions, 0 deletions
diff --git a/guides/assets/stylesheets/main.css b/guides/assets/stylesheets/main.css
index b56699a0d0..a1e4851833 100644
--- a/guides/assets/stylesheets/main.css
+++ b/guides/assets/stylesheets/main.css
@@ -294,6 +294,9 @@ a, a:link, a:visited {
#mainCol a, #subCol a, #feature a {color: #980905;}
#mainCol a code, #subCol a code, #feature a code {color: #980905;}
+#mainCol a.anchorlink { text-decoration: none; }
+#mainCol a.anchorlink:hover { text-decoration: underline; }
+
/* Navigation
--------------------------------------- */
diff --git a/guides/rails_guides/markdown.rb b/guides/rails_guides/markdown.rb
index bf2cc82c7c..16aaa7d1eb 100644
--- a/guides/rails_guides/markdown.rb
+++ b/guides/rails_guides/markdown.rb
@@ -105,6 +105,10 @@ module RailsGuides
node.inner_html = "#{node_index(hierarchy)} #{node.inner_html}"
end
end
+
+ doc.css('h3, h4, h5, h6').each do |node|
+ node.inner_html = "<a class='anchorlink' href='##{node[:id]}'>#{node.inner_html}</a>"
+ end
end.to_html
end
end