summaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-14 08:09:23 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-14 08:09:23 +0000
commit4ccb8983606fbb1a5fcfd242fd15aa6275a42aaf (patch)
treeca8934ac43a0f035a85a5e159f1f45cb24069ed7 /app/helpers
parentad668f42775caf243eaa8124210e8f4377f071ef (diff)
downloadredmine-4ccb8983606fbb1a5fcfd242fd15aa6275a42aaf.tar.gz
redmine-4ccb8983606fbb1a5fcfd242fd15aa6275a42aaf.zip
Fixed: {{toc}} uses identical anchors for subsections with the same name (#8194).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8871 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index ac59ae87f..83a28bc01 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -503,6 +503,7 @@ module ApplicationHelper
text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr)
@parsed_headings = []
+ @heading_anchors = {}
@current_section = 0 if options[:edit_section_links]
parse_sections(text, project, obj, attr, only_path, options)
@@ -816,6 +817,11 @@ module ApplicationHelper
anchor = sanitize_anchor_name(item)
# used for single-file wiki export
anchor = "#{obj.page.title}_#{anchor}" if options[:wiki_links] == :anchor && (obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version))
+ @heading_anchors[anchor] ||= 0
+ idx = (@heading_anchors[anchor] += 1)
+ if idx > 1
+ anchor = "#{anchor}-#{idx}"
+ end
@parsed_headings << [level, anchor, item]
"<a name=\"#{anchor}\"></a>\n<h#{level} #{attrs}>#{content}<a href=\"##{anchor}\" class=\"wiki-anchor\">&para;</a></h#{level}>"
end