Permalink
Browse files

If a non ASCII character is detected, using MD5.

  • Loading branch information...
1 parent 20a7518 commit f576a7b812fc61e1b5732860f7091653dc0bc978 @tonytonyjan committed Apr 30, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 guides/rails_guides/indexer.rb
View
6 guides/rails_guides/indexer.rb
@@ -57,11 +57,11 @@ def process(string, current_level=3, counters=[1])
level_hash
end
- def title_to_idx(title)
- idx = title.strip.parameterize.sub(/^\d+/, '')
+ def title_to_idx(title)
+ idx = title=~/[^\u0000-\u007F]/ ? ("id-"+Digest::MD5.hexdigest(title.strip)) : title.strip
+ idx = idx.parameterize.sub(/^\d+/, '')
if idx.blank?
puts "BLANK ID: please put an explicit ID for section #{title}, as in h5(#my-id)" if warnings
- idx = ("id-"+Digest::MD5.hexdigest(title.strip)).parameterize.sub(/^\d+/, '')
end
idx
end

0 comments on commit f576a7b

Please sign in to comment.