Wrapping lines of indented text in XML tags


require 'line-tree'

s=<<EOF
line1
  line2
line3
EOF

doc = LineTree.new(s).to_doc(encapsulate: true)
puts doc.xml pretty: true


Output:

<root>
  <entry>
    line1
    <entry>line2</entry>
  </entry>
  <entry>line3</entry>
</root>