Use special tag [[_TOC_]] to insert a table of contents
This commit is contained in:
+15
-1
@@ -61,6 +61,7 @@ module Gollum
|
|||||||
yield doc if block_given?
|
yield doc if block_given?
|
||||||
data = doc.to_html
|
data = doc.to_html
|
||||||
|
|
||||||
|
data = process_toc_tags(data)
|
||||||
data = process_tex(data)
|
data = process_tex(data)
|
||||||
data = process_wsd(data)
|
data = process_wsd(data)
|
||||||
data.gsub!(/<p><\/p>/, '')
|
data.gsub!(/<p><\/p>/, '')
|
||||||
@@ -201,7 +202,9 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns the String HTML version of the tag.
|
# Returns the String HTML version of the tag.
|
||||||
def process_tag(tag)
|
def process_tag(tag)
|
||||||
if html = process_image_tag(tag)
|
if tag =~ /^_TOC_$/
|
||||||
|
%{[[#{tag}]]}
|
||||||
|
elsif html = process_image_tag(tag)
|
||||||
html
|
html
|
||||||
elsif html = process_file_link_tag(tag)
|
elsif html = process_file_link_tag(tag)
|
||||||
html
|
html
|
||||||
@@ -358,6 +361,17 @@ module Gollum
|
|||||||
end
|
end
|
||||||
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.
|
# Find the given file in the repo.
|
||||||
#
|
#
|
||||||
# name - The String absolute or relative path of the file.
|
# name - The String absolute or relative path of the file.
|
||||||
|
|||||||
Reference in New Issue
Block a user