#!/usr/bin/env ruby require 'date' TODAY = Date.today class Entry < Struct.new(:depth, :state, :desc, :children) end def parse(io, filename=nil) todos = [Entry.new(-1, "/", "", [])] while line = io.gets if line =~ /\A(?:\s*(?:#|\/\/)\s)?(\s*)([-xX?*])\s+(.*)/ i, state, desc = $1.size, $2, $3 while i <= todos.last.depth todos.pop end e = Entry.new(i, state, desc, []) todos.last.children << e todos << e end end todos.first end def render(e) puts "