module Jekyll module Filters def textilize(input) RedCloth.new(input).to_html end def date_to_string(date) date.strftime("%d %b %Y") end def date_to_long_string(date) date.strftime("%d %B %Y") end def date_to_xmlschema(date) date.xmlschema end def xml_escape(input) CGI.escapeHTML(input) end def cgi_escape(input) CGI::escape(input) end def number_of_words(input) input.split.length end def array_to_sentence_string(array) connector = "and" case array.length when 0 "" when 1 array[0].to_s when 2 "#{array[0]} #{connector} #{array[1]}" else "#{array[0...-1].join(', ')}, #{connector} #{array[-1]}" end end # Stolen from ActiveSupport def ordinalize(number) if (11..13).include?(number.to_i % 100) "#{number}th" else case number.to_i % 10 when 1; "#{number}st" when 2; "#{number}nd" when 3; "#{number}rd" else "#{number}th" end end end end end