162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
# File 'lib/build/text/substitutions.rb', line 162
def apply(text, level = 0)
open_pattern = line_pattern
close_pattern = line_pattern('/')
lines = text.each_line
output = StringIO.new
indent = lambda do |level, indentation|
while line = lines.next rescue nil
if line =~ open_pattern
write_open($1, $2, output, indentation)
indent[level + @open.count, indentation.by(@open.count)]
write_close($1, $2, output, indentation)
elsif line =~ close_pattern
break
else
output.write(indentation + line)
end
end
end
indent[0, Indentation.none]
return output.string
end
|