aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2014-08-24 03:08:55 -0700
committerGodfrey Chan <godfreykfc@gmail.com>2014-08-24 03:08:55 -0700
commitba1d02d8333372ce55baa2e0d4ccb7d7da56400f (patch)
tree3318fe2521ad4b3763edbfc6149caba0b9588b22 /guides
parent4287f6d456518652bb1a2035c9ecf96f1be28f79 (diff)
parent2735b9cf97947cd0a59b0b72264d865598380879 (diff)
downloadrails-ba1d02d8333372ce55baa2e0d4ccb7d7da56400f.tar.gz
rails-ba1d02d8333372ce55baa2e0d4ccb7d7da56400f.tar.bz2
rails-ba1d02d8333372ce55baa2e0d4ccb7d7da56400f.zip
Merge pull request #16667 from JuanitoFatas/patch/anchor-generation
Fix guide anchor generation logic.
Diffstat (limited to '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