Module: Jepeto::JekyllPostHelper

Included in:
JekyllPost
Defined in:
lib/jepeto/helpers/jekyll_post_helper.rb

Instance Method Summary collapse

Instance Method Details

#slugalize(string) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/jepeto/helpers/jekyll_post_helper.rb', line 3

def slugalize(string)
  string.gsub!(/[^\x00-\x7F]+/, '')   # Remove non-ASCII (e.g. diacritics).
  string.gsub!(/[^a-z0-9\-_\+]+/i, '-') # Turn non-slug chars into the separator.
  string.gsub!(/-{2,}/, '-')            # No more than one of the separator in a row.
  string.gsub!(/^-|-$/, '')           # Remove leading/trailing separator.
  string.downcase!
  string
end