diff -bcr rog-0.1.5.tgz.out/rog-0.1.5/lib/rog/rogtasks.rb rog-0.1.5+1160265726/lib/rog/rogtasks.rb
*** rog-0.1.5.tgz.out/rog-0.1.5/lib/rog/rogtasks.rb	2006-05-29 05:52:27.000000000 -0700
--- rog-0.1.5+1160265726/lib/rog/rogtasks.rb	2006-10-07 19:46:25.000000000 -0700
***************
*** 67,72 ****
--- 67,113 ----
        @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
+         text = text.dup
+         headings = []
+ 
+         # classify the contents into a table
+           anchor = 0
+ 
+           text.gsub! /^(\s*h(\d))(.*?\.)(.*)$/ do
+             match = $~.dup
+ 
+             h = Heading.new($2.to_i, nil, $4.strip)
+ 
+             if $3 =~ /#([^#]+)\)/ # already has anchor
+               h.anchor = $1
+               headings << h
+ 
+               match.to_s
+             else
+               anchor += 1
+               h.anchor = anchor
+               headings << h
+ 
+               "#{match[1]}(##{anchor})#{match[3]}#{match[4]}"
+             end
+           end
+ 
+         # print table of contents at top of text
+           toc = headings.map do |h|
+             %{#{'*' * h.depth} "#{h.title}":##{h.anchor}}
+           end.join("\n")
+ 
+           text.insert 0, toc << "\n\n\n"
+ 
+         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|
--- 124,130 ----
  
          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
