]> projects.mako.cc - beamer-mako/blob - extract-notes
fixed some bugs and improved the quality of the code to build/extract data
[beamer-mako] / extract-notes
1 #!/usr/bin/perl -w
2
3 foreach $filename (@ARGV) {
4     chomp $filename;
5     open(TEXFILE, "<$filename");
6
7     $notes_filename = $filename;
8     $notes_filename =~ s/\.tex$/.pdfpc/;
9
10     $pdf_filename = $filename;
11     $pdf_filename =~ s/\.tex$/.pdf/;
12
13     open(NOTESFILE, "\>$notes_filename");
14     print NOTESFILE "[file]\n$pdf_filename\n[notes]\n";
15
16     $note_record = 0;
17     $slide_counter = 1;
18     while ($line = <TEXFILE>) {
19         # if this is a new frame
20         if ($line =~ /^\\begin\{frame\}/) {
21             $slide_counter++;
22         }
23         
24         if ($line =~ /^\% pdfpc\:end/) {
25             $note_record = 0;
26             $note_text =~ s/^\s*(.*?)\s*$/$1/;
27             print NOTESFILE "\#\#\# $slide_counter\n$note_text\n";
28         }
29         
30         # record if we're between a begin and an end
31         if ($note_record) {
32             $line_tmp = $line;
33             $line_tmp =~ s/^\%\s*//; 
34             $note_text = $note_text . $line_tmp;
35         }
36
37         # if this a new note
38         if ($line =~ /^\% pdfpc\:begin/) {
39             $note_text = "";
40             $note_record = 1;
41         }
42     }
43
44     close(TEXFILE);
45     close(NOTESFILE);
46
47 }
48

Benjamin Mako Hill || Want to submit a patch?