changeset 35:982aeacba4c6

Finally added toc after speaking to Apache devs
author nick <nrclark@essex.ac.uk>
date Wed, 28 Nov 2012 20:25:13 +0000
parents afa692f64fbf
children e7b54a524f37
files _layouts/default.html _plugins/TocFilter.rb contact.textile
diffstat 3 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/_layouts/default.html	Sat Nov 24 11:46:53 2012 +0000
+++ b/_layouts/default.html	Wed Nov 28 20:25:13 2012 +0000
@@ -54,7 +54,7 @@
       </div>
       <div id='content'>
         <h1 id='{{ page.title | downcase | replace(' ', '_') }}'>{{ page.title }}</h1>
-        <!--{{ content | toc }}-->
+        {{ content | toc }}
         {{ content }}
       </div>
       <div id='footer'>Copyright &copy; 2012 Nick Clark</div>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/_plugins/TocFilter.rb	Wed Nov 28 20:25:13 2012 +0000
@@ -0,0 +1,17 @@
+module TocFilter
+  def toc(input)
+    output = "<ol class=\"toc\">"
+    input.scan(/<(h2)(?:>|\s+(.*?)>)([^<]*)<\/\1\s*>/mi).each do |entry|
+      id = (entry[1][/^id=(['"])(.*)\1$/, 2] rescue nil)
+      title = entry[2].gsub(/<(\w*).*?>(.*?)<\/\1\s*>/m, '\2').strip
+      if id
+        output << %{<li><a href="##{id}">#{title}</a></li>}
+      else
+        output << %{<li>#{title}</li>}
+      end
+    end
+    output << '</ol>'
+    output
+  end
+end
+Liquid::Template.register_filter(TocFilter)
\ No newline at end of file
--- a/contact.textile	Sat Nov 24 11:46:53 2012 +0000
+++ b/contact.textile	Wed Nov 28 20:25:13 2012 +0000
@@ -14,8 +14,6 @@
 This will ensure that your message is sent to all members of the BioAid team. We will soon establish a more formal data collection procedure.
 
 
-h2(#people).  People
-
 table{border:1px solid black}.
 |!{width: 100px;}images/port_nc.jpg!|*Nick Clark*
 BioAid mobile and lab-scale app development. Algorithm development and engineering.|