fork download
  1. text = DATA.read
  2. block = "<blockquote>"
  3. text.each_line do |line|
  4. if line[/^&gt;/]
  5. block << line.sub(/^&gt;/,"")
  6. else
  7. unless block=="<blockquote>"
  8. puts "#{block.chomp}</blockquote>"
  9. block = "<blockquote>"
  10. end
  11. puts line
  12. end
  13. end
  14. puts block.chomp << "</blockquote>" unless block=="<blockquote>"
  15. __END__
  16. &gt; This is a blockquote line
  17. testing a new line
  18. &gt; 1- Another new blockquote section
  19. &gt; 2- And this is part of the same blockquote
  20. &gt; And this is the final line of this blockquote
  21. testing another
  22. &gt; 1- Another new blockquote
  23. &gt; 2- And the final line of the 3rd blockquote
Success #stdin #stdout 0.01s 6376KB
stdin
Standard input is empty
stdout
<blockquote> This is a blockquote line</blockquote>
testing a new line
<blockquote> 1- Another new blockquote section
 2- And this is part of the same blockquote
 And this is the final line of this blockquote</blockquote>
testing another
<blockquote> 1- Another new blockquote
 2- And the final line of the 3rd blockquote</blockquote>