mirror of https://github.com/rails/rails
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]
This commit is contained in:
parent
33c05363e2
commit
2735b9cf97
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue