require 'chunks/wiki' require 'date' require 'parsedate' # ToDo items. class Todo < Chunk::Abstract def self.pattern() /todo(@[\w,]+)?: (.*?)(?= 31 # get the [year,month,date] with sane values if you miss the day/year. # this should allow users to specify stuff like 'Dec 2005' or 'Dec 21'. d = [ d[0] || Date.today.year, d[1], d[2] || 1 ] @due_date = Date.new(*d) end rescue => detail @due_date = nil end end def escaped_text() nil end def unmask(content) return self if content.gsub!( Regexp.new(mask(content)), # the style 'todo' is bright-red to be eye catching. It is not expected that # there will be too many items on one page, but each is supposed to stand out. # The ToDo special page differentiates between the 'todo' and 'todoFuture' styles. "TODO#{ " @ #{@context.join(', ')}" unless @context.empty?}: #{@text}" ) end end