]> source.dussan.org Git - redmine.git/commitdiff
Use names instead of ids for wiki anchors (#6905).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 14 Mar 2011 22:01:43 +0000 (22:01 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 14 Mar 2011 22:01:43 +0000 (22:01 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5135 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/unit/helpers/application_helper_test.rb

index 44cb25ab8558d3edfd887e8c394b8282c03e5a44..914efd25a98f7f1a4c659410bb48c32fd2dab3cc 100644 (file)
@@ -713,7 +713,7 @@ module ApplicationHelper
       item = strip_tags(content).strip
       anchor = item.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
       @parsed_headings << [level, anchor, item]
-      "<h#{level} #{attrs} id=\"#{anchor}\">#{content}<a href=\"##{anchor}\" class=\"wiki-anchor\">&para;</a></h#{level}>"
+      "<a name=\"#{anchor}\"></a>\n<h#{level} #{attrs}>#{content}<a href=\"##{anchor}\" class=\"wiki-anchor\">&para;</a></h#{level}>"
     end
   end
           
index 6d46aedf06767c8fe9c14c2df365043d724959a6..5cb2c4cc12709bd1a27cb9fdc4acc0de3eebfc2e 100644 (file)
@@ -526,6 +526,13 @@ EXPECTED
     assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
   end
   
+  def test_headings
+    raw = 'h1. Some heading'
+    expected = %|<a name="Some-heading"></a>\n<h1 >Some heading<a href="#Some-heading" class="wiki-anchor">&para;</a></h1>|
+    
+    assert_equal expected, textilizable(raw)
+  end
+  
   def test_table_of_content
     raw = <<-RAW
 {{toc}}