Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan committed Sep 14, 2004
1 parent 6ff7c93 commit 4b0c433
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions documentation/cut.rb
@@ -0,0 +1,43 @@
def cut(fileName, start, stop)
inHandle = File::open( fileName )

inText = inHandle.read()
result = "ERROR #{fileName}"
inText.scan(/\/\/.*?cut:#{start}.*?\n(.*?)\n\/\/[^\/]*cut:#{stop}/m) do |block|
lines = block[0].split("\n")
gobble = countSpace( lines )

beginBlock = "<source gobble=\"#{gobble}\">\n"
endBlock = "</source>"
result = block[0]
result = "%!SRC|#{fileName}|#{start}|#{stop}|\n" + "#{beginBlock}" + result + "\n#{endBlock}\n%!END"
end
result
end

def countSpace( lines )
count = 1000
lines.each do |line|
if line.length>0
currentCount = 0
while line[currentCount,1] == " "
currentCount = currentCount + 1
end
if count > currentCount
count = currentCount
end
end
end
count
end

fileName = ARGV[0]
fHandle = File::open( fileName )
inText = fHandle.read()
found = false

inText.gsub!(/\%\!SRC\|(.*?)\|(.*?)\|(.*?)\|.*?\n(.*?)%!END/m) do |match|
result = match.split("|")
cut(result[1], result[2], result[3])
end
print inText

0 comments on commit 4b0c433

Please sign in to comment.