From 301679861a2440a10c9eac746cec86459f445ef9 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Mon, 4 May 2015 14:55:10 -0700 Subject: remove all Octopress stuff --- plugins/titlecase.rb | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 plugins/titlecase.rb (limited to 'plugins/titlecase.rb') diff --git a/plugins/titlecase.rb b/plugins/titlecase.rb deleted file mode 100644 index 7648932c..00000000 --- a/plugins/titlecase.rb +++ /dev/null @@ -1,36 +0,0 @@ -class String - def titlecase - small_words = %w(a an and as at but by en for if in of on or the to v v. via vs vs.) - - x = split(" ").map do |word| - # note: word could contain non-word characters! - # downcase all small_words, capitalize the rest - small_words.include?(word.gsub(/\W/, "").downcase) ? word.downcase! : word.smart_capitalize! - word - end - # capitalize first and last words - x.first.to_s.smart_capitalize! - x.last.to_s.smart_capitalize! - # small words are capitalized after colon, period, exclamation mark, question mark - x.join(" ").gsub(/(:|\.|!|\?)\s?(\W*#{small_words.join("|")}\W*)\s/) { "#{$1} #{$2.smart_capitalize} " } - end - - def titlecase! - replace(titlecase) - end - - def smart_capitalize - # ignore any leading crazy characters and capitalize the first real character - if self =~ /^['"\(\[']*([a-z])/ - i = index($1) - x = self[i,self.length] - # word with capitals and periods mid-word are left alone - self[i,1] = self[i,1].upcase unless x =~ /[A-Z]/ or x =~ /\.\w+/ - end - self - end - - def smart_capitalize! - replace(smart_capitalize) - end -end -- cgit v1.2.1