aboutsummaryrefslogtreecommitdiffstats
path: root/guides/rails_guides
diff options
context:
space:
mode:
authorJuanito Fatas <katehuang0320@gmail.com>2014-08-24 11:58:01 +0800
committerJuanito Fatas <katehuang0320@gmail.com>2014-08-24 11:58:01 +0800
commit2735b9cf97947cd0a59b0b72264d865598380879 (patch)
treebc39404eb578174cb562a1c110e9cf4a0442f550 /guides/rails_guides
parent33c05363e2ed52aa8bdbf5ebf9ee5226ab85ecbc (diff)
downloadrails-2735b9cf97947cd0a59b0b72264d865598380879.tar.gz
rails-2735b9cf97947cd0a59b0b72264d865598380879.tar.bz2
rails-2735b9cf97947cd0a59b0b72264d865598380879.zip
Fix guide anchor generation logic.
This could use in any translation because it's not limited to `[^a-z0-9]`. Verify after this change, all guides still have same anchors. [Robin Dupret & Juanito Fatas]
Diffstat (limited to 'guides/rails_guides')
-rw-r--r--guides/rails_guides/markdown.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/guides/rails_guides/markdown.rb b/guides/rails_guides/markdown.rb
index b422a80759..17035069d0 100644
--- a/guides/rails_guides/markdown.rb
+++ b/guides/rails_guides/markdown.rb
@@ -47,7 +47,12 @@ module RailsGuides
end
def dom_id_text(text)
- text.downcase.gsub(/\?/, '-questionmark').gsub(/!/, '-bang').gsub(/[^a-z0-9]+/, ' ').strip.gsub(/\s+/, '-')
+ escaped_chars = Regexp.escape('\\/`*_{}[]()#+-.!:,;|&<>^~=\'"')
+
+ text.downcase.gsub(/\?/, '-questionmark')
+ .gsub(/!/, '-bang')
+ .gsub(/[#{escaped_chars}]+/, ' ').strip
+ .gsub(/\s+/, '-')
end
def engine