diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 0e4b0a8c3..b42960ec0 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -682,7 +682,7 @@ module ApplicationHelper
def parse_headings(text, project, obj, attr, only_path, options)
headings = []
text.gsub!(HEADING_RE) do
- level, attrs, content = $1, $2, $3
+ level, attrs, content = $1.to_i, $2, $3
item = strip_tags(content).strip
anchor = item.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
headings << [level, anchor, item]
@@ -696,12 +696,24 @@ module ApplicationHelper
div_class = 'toc'
div_class << ' right' if $1 == '>'
div_class << ' left' if $1 == '<'
- out = "
"
+ out = "- "
+ root = headings.map(&:first).min
+ current = root
+ started = false
headings.each do |level, anchor, item|
- out << "
- #{item}
\n"
+ if level > current
+ out << '- ' * (level - current)
+ elsif level < current
+ out << "
\n" * (current - level) + "- "
+ elsif started
+ out << '
- '
+ end
+ out << "#{item}"
+ current = level
+ started = true
end
- out << '
'
- out
+ out << '
' * (current - root)
+ out << ''
end
end
end
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index f3bbf224e..8055c8796 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -715,9 +715,10 @@ div.wiki ul.toc {
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 ul { margin: 0; padding: 0; }
+div.wiki ul.toc li { list-style-type:none; margin: 0;}
+div.wiki ul.toc li li { margin-left: 1.5em; }
+div.wiki ul.toc li li li { font-size: 0.8em; }
div.wiki ul.toc a {
font-size: 0.9em;
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index be4c79582..02b15fbf5 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -423,25 +423,38 @@ h2. Subtitle with [[Wiki|another Wiki]] link
h2. Subtitle with %{color:red}red text%
-h2. Subtitle with *some* _modifiers_
+h3. Subtitle with *some* _modifiers_
h1. Another title
-h2. An "Internet link":http://www.redmine.org/ inside subtitle
+h3. An "Internet link":http://www.redmine.org/ inside subtitle
h2. "Project Name !/attachments/1234/logo_small.gif! !/attachments/5678/logo_2.png!":/projects/projectname/issues
RAW
- expected = '