Make TOC pretty. Also put in "[[_TOC_]]" stub for viewing sub-page directly

This commit is contained in:
kristi
2012-05-14 10:23:12 -07:00
parent d7f4eeea2c
commit be93fa747b
2 changed files with 33 additions and 4 deletions
@@ -367,6 +367,35 @@ a.absent {
margin: 0;
padding: 0;
}
.markdown-body .toc {
border: 1px solid #ddd;
padding: 5px 10px;
margin: 0;
border-radius: 3px;
}
.markdown-body .toc-title {
color: #888;
padding: 2px;
border-bottom: 1px solid #ddd;
margin-bottom: 3px;
}
.markdown-body .toc ul {
padding-left: 10px;
margin: 0;
}
.markdown-body .toc>ul {
margin-left: 10px;
font-size: 17px;
}
.markdown-body .toc ul ul {
font-size: 15px;
}
.markdown-body .toc ul ul ul {
font-size: 14px;
}
.markdown-body .toc ul li{
margin: 0;
}
.highlight {
background: #fff;
}
+4 -4
View File
@@ -61,7 +61,7 @@ module Gollum
doc = Nokogiri::HTML::DocumentFragment.parse(data)
doc = sanitize.clean_node!(doc) if sanitize
doc,toc = process_headers(doc)
@toc = @sub_page ? @parent_page.toc_data : toc
@toc = @sub_page ? ( @parent_page ? @parent_page.toc_data : "[[_TOC_]]" ) : toc
yield doc if block_given?
data = doc.to_html
@@ -91,9 +91,9 @@ module Gollum
h.add_child(anchor)
# Build TOC
toc ||= Nokogiri::XML::Node.new('ul', doc)
tail ||= toc
tail_level ||= 1
toc ||= Nokogiri::XML::DocumentFragment.parse('<div class="toc"><div class="toc-title">Table of Contents</div></div>')
tail ||= toc.child
tail_level ||= 0
while tail_level < level
node = Nokogiri::XML::Node.new('ul', doc)