8 lilypath = os.environ['LILYPOND_SOURCEDIR'] + '/'
10 print 'Please set LILYPOND_SOURCEDIR to the toplevel source, eg LILYPOND_SOURCEDIR=/home/foobar/lilypond-1.2.3/'
13 lilypath = lilypath + '/bin/'
14 sys.path.append(lilypath)
16 from lilypython import *
22 latex_author_re = regex.compile('\\author{\([^}]+\)}')
23 latex_title_re = regex.compile('\\title{\([^}]+\)}')
33 def read_latex_header (fn):
35 i = regex.search( '\\\\begin{document}', s)
39 s = regsub.gsub('%.*$', '', s)
40 s = regsub.gsub('\n', ' ', s)
41 if latex_author_re.search (s) == -1 :
46 header.author = latex_author_re.group (1)
47 if latex_title_re.search (s) == -1:
49 header.title = latex_title_re.group (1)
50 header.outfile = regsub.gsub ('\.doc+$', '.ps.gz', fn)
54 bib_author_re = regex.compile('% *AUTHOR *= *\(.*\)$')
55 bib_title_re = regex.compile('% *TITLE *= *\(.*\)$')
59 if bib_author_re.search (s) == -1 :
64 header.author = bib_author_re.group (1)
65 if bib_title_re.search (s) == -1:
67 header.title = bib_title_re.group (1)
68 header.outfile = regsub.gsub ( '\.bib$', '.html' , fn)
72 def read_pod_header (fn):
73 header = Latex_head ()
75 i = regex.search( '[^\n \t]', s)
77 i = regex.search( '\n\n', s)
81 i = regex.search( '\n\n', s)
84 header.outfile = regsub.gsub ('\.pod$', '.html', fn)
88 def print_html_head (l,o,h):
91 l.write ('<li><a href=%s>%s</a>' % (pre + h.outfile, h.title ))
93 l.write ('<p>by %s</p>' % h.author)
99 (cl_options, files) = getopt.getopt(sys.argv[1:],
100 'e:h', ['help', 'prefix='
107 for opt in cl_options:
110 if o == '--prefix' or o == '-p':
112 if o == '--title' or o == '-t':
117 l.write ('<html><title>%s</title><h1> %s</h1><ul>\n' % (title, title))
121 if regex.search ('\\.bib$', x) <> -1:
122 head = bib_header (x)
123 elif regex.search ('\\.pod$', x) <> -1:
124 head = read_pod_header (x)
126 head = read_latex_header (x)
127 print_html_head (l, pre, head)
128 l.write ('</ul></html>')