def convert(text)
text.lines.map do |line|
if line =~ /^\s*\*\s(.*)/
line = "<li>#{convert($1)}</li>\n"
end
line.gsub!(/\*([^\*]*)\*/, '<strong>\1</strong>')
line
end.join
end
puts convert(DATA)
__END__
*this is bold* *yup
* this is a list
* foo *bold*
* here
puts DATA.read.lines.map do |line|
if line =~ /^\s*\*\s(.*)/
line = "<li>#{convert($1)}</li>\n"
end
line.gsub!(/\*([^\*]*)\*/, '<strong>\1</strong>')
line
end.join
__END__
*this is bold* *yup
* this is a list
* foo *bold*
* here