From 3b48e38cba14ef955695a10344d91bea5792bdbe Mon Sep 17 00:00:00 2001 From: jdp Date: Tue, 16 Mar 2010 22:58:29 -0400 Subject: [PATCH] leading tabs in code are now replaced with two spaces! --- lib/rocco.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/rocco.rb b/lib/rocco.rb index f73425c..3ae9737 100644 --- a/lib/rocco.rb +++ b/lib/rocco.rb @@ -136,7 +136,10 @@ class Rocco docs_blocks, code_blocks = [], [] sections.each do |docs,code| docs_blocks << docs.map { |line| line.sub(@comment_pattern, '') }.join("\n") - code_blocks << code.join("\n") + code_blocks << code.map do |line| + tabs = line.match(/^(\t+)/) + tabs ? line.sub(/^\t+/, ' ' * tabs.captures[0].length) : line + end.join("\n") end [docs_blocks, code_blocks] end