# ruby script to make an unordered list from indented data.
require 'open-uri' ;
data = nil ;
open("http://listing360.com/temp/outline.txt") {|f| data = f.readlines } ;
indent = 0 ; # current indent level
data.each {|d|
# split the line at the first blank, and count how many dots there are in the left side.
left , right = d.split(/ /,2) ; # isolate the "1.2.3.4." part of the line
# count dots, indent or un-indent as needed.
dots = 0 ;
left.split(//).each {|char| # count periods.
dots += 1 if char=='.' } ;
if dots < indent then
(indent-dots).times do ; puts "</ul>" ; end ; # terminate a list
elsif dots > indent then
(dots-indent).times do ; puts "<ul>" ; end ; # start a new list
end ;
puts "<li>#{right.chomp}</li>" ; # add an item to the list. chomp=Remove CRLF from the end.
indent = dots ;
}
indent.times do ; puts "</ul>" ; end ; # do any final termination.