diff options
author | Juanito Fatas <katehuang0320@gmail.com> | 2014-08-24 11:58:01 +0800 |
---|---|---|
committer | Juanito Fatas <katehuang0320@gmail.com> | 2014-08-24 11:58:01 +0800 |
commit | 2735b9cf97947cd0a59b0b72264d865598380879 (patch) | |
tree | bc39404eb578174cb562a1c110e9cf4a0442f550 /guides | |
parent | 33c05363e2ed52aa8bdbf5ebf9ee5226ab85ecbc (diff) | |
download | rails-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')
-rw-r--r-- | guides/rails_guides/markdown.rb | 7 |
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 |