diff -bcr rog-0.1.5.orig/lib/rog/rogtasks.rb rog-0.1.5+1160265726/lib/rog/rogtasks.rb
*** rog-0.1.5.orig/lib/rog/rogtasks.rb	2006-05-29 05:52:27.000000000 -0700
--- rog-0.1.5+1160265726/lib/rog/rogtasks.rb	2006-10-09 18:55:37.000000000 -0700
***************
*** 67,72 ****
--- 67,107 ----
        @posts_path = "#{@pages_path}/posts"
      end
  
+     # Adds a table of contents at the top of the given text and sufficent hyperlinks to access the various headings in the text.
+     class RedCloth_WithToc < Rote::Filters::RedCloth
+       Heading = Struct.new(:depth, :anchor, :title)
+ 
+       def handler text, *args
+         # determine structure of content and insert anchors where necessary
+           headings = []
+ 
+           text = text.gsub /^(\s*h(\d))(.*?)(\.(.*))$/ do
+             target = $~.dup
+ 
+             if target[3] =~ /#([^#]+)\)/
+               anchor = $1
+               result = target.to_s
+             else
+               anchor = headings.length
+               result = "#{target[1]}#{target[3]}(##{anchor})#{target[4]}"
+             end
+ 
+             headings << Heading.new( target[2].to_i, anchor, target[5] )
+             result
+           end
+ 
+         # add table of contents at top of text
+           toc = headings.map do |h|
+             %{#{'*' * h.depth} "#{h.title}":##{h.anchor}}
+           end.join("\n")
+ 
+           text.insert 0, "\n\n\n"
+           text.insert 0, toc
+ 
+         super text, *args
+       end
+     end
+ 
      private
      def define_subtasks
        $blog = Blog.new(@blog_path, @pages_path, @archives_path, @posts_path)
***************
*** 83,89 ****
    
          site.ext_mapping(/thtml|textile/, 'html') do |page|
            page.extend Rote::Format::HTML
!           page.page_filter Rote::Filters::RedCloth.new
          end    
    
          site.ext_mapping(/mhtml|markdown/, 'html') do |page|
--- 118,124 ----
  
          site.ext_mapping(/thtml|textile/, 'html') do |page|
            page.extend Rote::Format::HTML
!           page.page_filter RedCloth_WithToc.new
          end
  
          site.ext_mapping(/mhtml|markdown/, 'html') do |page|
Only in rog-0.1.5+1160265726/lib/rog: .rogtasks.rb.marks
