defunkt / tomdoc

A TomDoc Ruby library.
http://tomdoc.org/
MIT License
114 stars 16 forks source link

Keep indent level in examples #28

Closed miyagawa closed 11 years ago

miyagawa commented 11 years ago

If you have a tomdoc like:

Examples

  def foo
    'bar'
  end

tomdoc.examples[0] would become

"def foo\n    'bar'\n  end"

which has a different level of indentation for the 1st line and the rest of the code.

This patch addresses the issue by reuseing the indent removal code in #tomdoc and strips the prefixed indent for each line and then recombine, so that the result will have the same indent leval you can run through as a code snippet.