comparison app/helpers/application_helper.rb @ 933:d36724ef856a

Merge from branch "cannam_integration"
author Chris Cannam
date Wed, 11 Jul 2012 13:30:13 +0100
parents ec1c49528f36
children 83866d58f2dd
comparison
equal deleted inserted replaced
927:9ee5fd0b9bd3 933:d36724ef856a
495 only_path = options.delete(:only_path) == false ? false : true 495 only_path = options.delete(:only_path) == false ? false : true
496 496
497 text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr) 497 text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr)
498 498
499 @parsed_headings = [] 499 @parsed_headings = []
500 @heading_anchors = {}
500 @current_section = 0 if options[:edit_section_links] 501 @current_section = 0 if options[:edit_section_links]
502
503 parse_sections(text, project, obj, attr, only_path, options)
501 text = parse_non_pre_blocks(text) do |text| 504 text = parse_non_pre_blocks(text) do |text|
502 [:parse_sections, :parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_macros, :parse_headings].each do |method_name| 505 [:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_macros].each do |method_name|
503 send method_name, text, project, obj, attr, only_path, options 506 send method_name, text, project, obj, attr, only_path, options
504 end 507 end
505 end 508 end
509 parse_headings(text, project, obj, attr, only_path, options)
506 510
507 if @parsed_headings.any? 511 if @parsed_headings.any?
508 replace_toc(text, @parsed_headings) 512 replace_toc(text, @parsed_headings)
509 end 513 end
510 514
783 level, attrs, content = $2.to_i, $3, $4 787 level, attrs, content = $2.to_i, $3, $4
784 item = strip_tags(content).strip 788 item = strip_tags(content).strip
785 anchor = sanitize_anchor_name(item) 789 anchor = sanitize_anchor_name(item)
786 # used for single-file wiki export 790 # used for single-file wiki export
787 anchor = "#{obj.page.title}_#{anchor}" if options[:wiki_links] == :anchor && (obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version)) 791 anchor = "#{obj.page.title}_#{anchor}" if options[:wiki_links] == :anchor && (obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version))
792 @heading_anchors[anchor] ||= 0
793 idx = (@heading_anchors[anchor] += 1)
794 if idx > 1
795 anchor = "#{anchor}-#{idx}"
796 end
788 @parsed_headings << [level, anchor, item] 797 @parsed_headings << [level, anchor, item]
789 "<a name=\"#{anchor}\"></a>\n<h#{level} #{attrs}>#{content}<a href=\"##{anchor}\" class=\"wiki-anchor\">&para;</a></h#{level}>" 798 "<a name=\"#{anchor}\"></a>\n<h#{level} #{attrs}>#{content}<a href=\"##{anchor}\" class=\"wiki-anchor\">&para;</a></h#{level}>"
790 end 799 end
791 end 800 end
792 801