Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/kitabu/extensions/string.rb

Instance Method Summary collapse

Instance Method Details



4
5
6
7
8
9
10
11
12
# File 'lib/kitabu/extensions/string.rb', line 4

def to_permalink
  str = dup.unicode_normalize(:nfkd)
  str = str.gsub(/[^\x00-\x7F]/, "").to_s
  str.gsub!(/[^-\w]+/xim, "-")
  str.gsub!(/-+/xm, "-")
  str.gsub!(/^-?(.*?)-?$/, '\1')
  str.downcase!
  str
end