From 1d3905bb71a16ce10c208c19c59a7dfcc8d86203 Mon Sep 17 00:00:00 2001 From: kristi Date: Sun, 13 May 2012 12:44:20 -0700 Subject: [PATCH] Use special tag [[_TOC_]] to insert a table of contents --- lib/gollum/markup.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index 6c1714ad..25e7b685 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -61,6 +61,7 @@ module Gollum yield doc if block_given? data = doc.to_html + data = process_toc_tags(data) data = process_tex(data) data = process_wsd(data) data.gsub!(/

<\/p>/, '') @@ -201,7 +202,9 @@ module Gollum # # Returns the String HTML version of the tag. def process_tag(tag) - if html = process_image_tag(tag) + if tag =~ /^_TOC_$/ + %{[[#{tag}]]} + elsif html = process_image_tag(tag) html elsif html = process_file_link_tag(tag) html @@ -358,6 +361,17 @@ module Gollum end end + + # Process the special table of contents tag [[_TOC_]] + # + # data - The String data (with placeholders). + # + # Returns the marked up String data. + def process_toc_tags(data) + data.gsub!("[[_TOC_]]", @toc.nil? ? '' : @toc.to_html) + data + end + # Find the given file in the repo. # # name - The String absolute or relative path of the file.