S
Steve Litt
Hi all,
The script under my sig is a filter that takes a LyX file from stdin and spits
out the chapters. Right now it doesn't do parts, but it probably will later
on. Perhaps some day it will handle the whole hierchy of
Part/chapter/section/subsection/subsubsection/paragraph/subparagraph.
Consider this version public domain with no warranty.
Steve Litt
http://www.troubleshooters.com
(e-mail address removed)
#!/usr/bin/ruby
### SLURP STDIN
lines = []
while line = gets
lines.push(line.chomp)
end
#### FIND CHAPTER NAMES
temp_lineno = -9999
chapno = 0
chapname = ""
in_chapter = false
lines.each do |line|
if line =~ /^\s*\\layout Chapter/
in_chapter = true
chapname = ""
chapno += 1
# puts "dia startchapter " + line + in_chapter.to_s
elsif in_chapter and line =~ /^\s*\\layout/
printf("%2d: %s\n", chapno, chapname) if chapno > 0
#puts "dia endchapter " + line
in_chapter = false
elsif in_chapter
chapname += (" " + line) unless line =~ /^\s*\\/ or line =~ /^\s*$/
end
end
printf("%2d: %s\n", chapno, chapname) if chapname and chapname != ""
The script under my sig is a filter that takes a LyX file from stdin and spits
out the chapters. Right now it doesn't do parts, but it probably will later
on. Perhaps some day it will handle the whole hierchy of
Part/chapter/section/subsection/subsubsection/paragraph/subparagraph.
Consider this version public domain with no warranty.
Steve Litt
http://www.troubleshooters.com
(e-mail address removed)
#!/usr/bin/ruby
### SLURP STDIN
lines = []
while line = gets
lines.push(line.chomp)
end
#### FIND CHAPTER NAMES
temp_lineno = -9999
chapno = 0
chapname = ""
in_chapter = false
lines.each do |line|
if line =~ /^\s*\\layout Chapter/
in_chapter = true
chapname = ""
chapno += 1
# puts "dia startchapter " + line + in_chapter.to_s
elsif in_chapter and line =~ /^\s*\\layout/
printf("%2d: %s\n", chapno, chapname) if chapno > 0
#puts "dia endchapter " + line
in_chapter = false
elsif in_chapter
chapname += (" " + line) unless line =~ /^\s*\\/ or line =~ /^\s*$/
end
end
printf("%2d: %s\n", chapno, chapname) if chapname and chapname != ""