I was looking at the source code to BlueCloth and came across the following lines of code:
# Table of MD5 sums for escaped characters EscapeTable = {} '\\`*_{}()#.!'.split(//).each {|char| hash = Digest::MD5::hexdigest( char )
EscapeTable[ char ] = { :md5 => hash, :md5re => Regexp::new( hash ), :re => Regexp::new( '\\\\' + Regexp::escape(char) ), } }
One particular use of the EscapeTable is in this function: ### Escape special characters in the given +str+ def escape_special_chars( str ) @log.debug " Escaping special characters" text = ''
# The original Markdown source has something called '$tags_to_skip' # declared here, but it's never used, so I don't define it.
tokenize_html( str ) {|token, str| @log.debug " Adding %p token %p" % [ token, str ] case token
# Within tags, encode * and _ when :tag text += str. gsub( /\*/, EscapeTable['*'][:md5] ). gsub( /_/, EscapeTable['_'][:md5] )
# Encode backslashed stuff in regular text when :text text += encode_backslash_escapes( str ) else raise TypeError, "Unknown token type %p" % token end }
@log.debug " Text with escapes is now: %p" % text return text end
Now can someone please tell me why you would want to escape this particular set of characters? In addition, why use an md5 hash? Why not an entity character reference?