Project

General

Profile

Patch #1857 ยป redmine_wiki_toc.patch

Jim Jones, 2008-09-04 16:34

View differences:

redmine/lib/redmine/wiki_formatting.rb (working copy)
alias :textile_h3 :textile_p_withtoc
def inline_toc(text)
text.gsub!(/<p>\{\{([<>]?)toc\}\}<\/p>/i) do
text.gsub!(/<p>\{\{([<>]?)toc(:(\d+))?\}\}<\/p>/i) do
div_class = 'toc'
div_class << ' right' if $1 == '>'
div_class << ' left' if $1 == '<'
skip = 0
skip = $3.to_i if not $3.nil?
out = "<ul class=\"#{div_class}\">"
lastlevel = 1
skipped = 0
@toc.each do |heading|
if skipped < skip
skipped += 1
next
end
level, anchor, toc_item = heading
if level > lastlevel
out << "<li><ul>"
end
if level < lastlevel
out << "</ul></li>"
end
lastlevel = level
out << "<li class=\"heading#{level}\"><a href=\"##{anchor}\">#{toc_item}</a></li>\n"
end
while 1 < lastlevel do
out << '</ul></li>'
lastlevel -= 1
end
out << '</ul>'
out
end
end
......
end
end
end
# vim: ts=2:expandtab:
redmine/public/stylesheets/application.css (working copy)
div.wiki ul.toc.right { float: right; margin-left: 12px; margin-right: 0; width: auto; }
div.wiki ul.toc.left { float: left; margin-right: 12px; margin-left: 0; width: auto; }
div.wiki ul.toc li { list-style-type:none;}
div.wiki ul.toc li.heading2 { margin-left: 6px; }
div.wiki ul.toc li.heading3 { margin-left: 12px; font-size: 0.8em; }
div.wiki ul.toc a {
font-size: 0.9em;
    (1-1/1)