Mercurial > hg > soundsoftware-site
diff app/helpers/application_helper.rb @ 931:ec1c49528f36 cannam_integration
Merge from branch "redmine-1.3"
author | Chris Cannam |
---|---|
date | Wed, 27 Jun 2012 15:04:58 +0100 |
parents | 5e80956cc792 5f33065ddc4b |
children | 83866d58f2dd |
line wrap: on
line diff
--- a/app/helpers/application_helper.rb Wed Jun 27 14:56:14 2012 +0100 +++ b/app/helpers/application_helper.rb Wed Jun 27 15:04:58 2012 +0100 @@ -497,12 +497,16 @@ 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) text = parse_non_pre_blocks(text) do |text| - [:parse_sections, :parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_macros, :parse_headings].each do |method_name| + [:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_macros].each do |method_name| send method_name, text, project, obj, attr, only_path, options end end + parse_headings(text, project, obj, attr, only_path, options) if @parsed_headings.any? replace_toc(text, @parsed_headings) @@ -785,6 +789,11 @@ 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\">¶</a></h#{level}>" end