anchors_with_transliteration.patch

Alexander Markelov, 2012-08-13 23:43

Download (2.13 KB)

View differences:

Gemfile (working copy)
6 6
gem "coderay", "~> 1.0.6"
7 7
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
8 8
gem "builder"
9
gem "stringex"
9 10

  
10 11
# Optional gem for LDAP authentication
11 12
group :ldap do
test/unit/helpers/application_helper_test.rb (working copy)
529 529
      '[[CookBook documentation#One-section]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation#One-section" class="wiki-page">CookBook documentation</a>',
530 530
      '[[Another page#anchor|Page]]' => '<a href="/projects/ecookbook/wiki/Another_page#anchor" class="wiki-page">Page</a>',
531 531
      # UTF8 anchor
532
      '[[Another_page#Тест|Тест]]' => %|<a href="/projects/ecookbook/wiki/Another_page##{CGI.escape 'Тест'}" class="wiki-page">Тест</a>|,
532
      '[[Another_page#Тест|Тест]]' => %|<a href="/projects/ecookbook/wiki/Another_page#Tiest" class="wiki-page">Тест</a>|,
533 533
      # page that doesn't exist
534 534
      '[[Unknown page]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">Unknown page</a>',
535 535
      '[[Unknown page|404]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">404</a>',
app/helpers/application_helper.rb (working copy)
1157 1157
  end
1158 1158

  
1159 1159
  def sanitize_anchor_name(anchor)
1160
    if ''.respond_to?(:encoding)
1161
      anchor.gsub(%r{[^\p{Word}\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
1162
    else
1163
      # TODO: remove when ruby1.8 is no longer supported
1164
      anchor.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
1165
    end
1160
    anchor.to_ascii.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
1166 1161
  end
1167 1162

  
1168 1163
  # Returns the javascript tags that are included in the html layout head