Permalink
Browse files

Make non English title indexable (such as Chinese or Japanese) using …

…MD5.
  • Loading branch information...
tonytonyjan committed Apr 29, 2012
1 parent d7532c1 commit 70e0edf000289b1907b8aee386daf23577f6bc08
Showing with 3 additions and 2 deletions.
  1. +3 −2 guides/rails_guides/indexer.rb
@@ -59,8 +59,9 @@ def process(string, current_level=3, counters=[1])
def title_to_idx(title)
idx = title.strip.parameterize.sub(/^\d+/, '')
- if warnings && idx.blank?
- puts "BLANK ID: please put an explicit ID for section #{title}, as in h5(#my-id)"
+ 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 70e0edf

Please sign in to comment.