Skip to content

Commit

Permalink
Add automatic hash generation with redcarpet dev, and change tocify s…
Browse files Browse the repository at this point in the history
…crollHistory to be compatible with the ids
  • Loading branch information
lord committed Sep 24, 2013
1 parent 7ba798c commit 28f442e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ gem 'middleman-gh-pages'
# Live-reloading plugin
gem "middleman-livereload", "~> 3.1.0"

gem "redcarpet"
gem 'redcarpet', git: 'https://github.com/vmg/redcarpet.git'

gem "github-linguist"

# For faster file watcher updates on Windows:
Expand Down
9 changes: 7 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
GIT
remote: https://github.com/vmg/redcarpet.git
revision: 2f27273c10cc2779d539c48d605c4a25eb8e34a3
specs:
redcarpet (3.0.0)

GEM
remote: http://rubygems.org/
specs:
Expand Down Expand Up @@ -92,7 +98,6 @@ GEM
ffi (>= 0.5.0)
rb-kqueue (0.2.0)
ffi (>= 0.5.0)
redcarpet (3.0.0)
rouge (0.3.10)
thor
ruby18_source_location (0.2)
Expand Down Expand Up @@ -123,6 +128,6 @@ DEPENDENCIES
middleman-gh-pages
middleman-livereload (~> 3.1.0)
middleman-syntax
redcarpet
redcarpet!
ruby18_source_location
wdm (~> 0.1.0)
2 changes: 1 addition & 1 deletion config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

set :markdown_engine, :redcarpet

set :markdown, :fenced_code_blocks => true, :smartypants => true, :disable_indented_code_blocks => true, :prettify => true, :tables => true
set :markdown, :fenced_code_blocks => true, :smartypants => true, :disable_indented_code_blocks => true, :prettify => true, :tables => true, :with_toc_data => true

# Activate the syntax highlighter
activate :syntax
Expand Down
13 changes: 11 additions & 2 deletions source/javascripts/jquery.tocify.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@

// ADDED BY ROBERT
// actually add the hash value to the element's id
self.attr("id", "link-" + hashValue);
// self.attr("id", "link-" + hashValue);

// Appends a list item HTML element to the last unordered list HTML element found within the HTML element calling the plugin
item = $("<li/>", {
Expand Down Expand Up @@ -710,7 +710,16 @@

if(window.location.hash !== "#" + anchorText) {

window.location.replace("#" + anchorText);
if(history.replaceState) {
history.replaceState({}, "", "#" + anchorText);
// provide a fallback
} else {
scrollV = document.body.scrollTop;
scrollH = document.body.scrollLeft;
location.hash = "#" + anchorText;
document.body.scrollTop = scrollV;
document.body.scrollLeft = scrollH;
}

}

Expand Down
5 changes: 4 additions & 1 deletion source/layouts/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
hashGenerator: 'pretty',
highlightOffset: 60,
scrollTo: -2,
scrollHistory: true
scrollHistory: true,
hashGenerator: function(text, element) {
return element[0].getAttribute('id');
}
});
setupLanguages([
<% current_page.data.languages.each do |lang| %>
Expand Down
13 changes: 6 additions & 7 deletions source/stylesheets/all.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ html, body {

th {
padding: 5px 10px;
border-bottom: 1px solid #666;
border-bottom: 1px solid #999;
vertical-align: bottom;
// @include background-image(linear-gradient(bottom, darken($main-bg, 3%), $main-bg));
@include embedded-text;
Expand All @@ -134,8 +134,12 @@ html, body {
padding: 10px;
}

tr:last-child {
border-bottom: 1px solid #999;
}

tr:nth-child(even) {
background-color: lighten($main-bg,4.2%);
background-color: lighten($main-bg,4.7%);
}
}

Expand Down Expand Up @@ -283,8 +287,3 @@ html, body {
@include fancy-inset-border-bottom;
}
}

/* Makes the font smaller for all subheader elements. */
.tocify-subheader li {
}

0 comments on commit 28f442e

Please sign in to comment.