3 # name isn't really appropriate now ...
29 def read_latex_header (fn):
32 m = re.search(r'\\author{([^}]+)}', s)
34 header.author = m.group (1)
36 m = re.search (r'\\title{([^}]+)}',s )
38 header.title = m.group (1)
40 header.title = 'No title'
43 header.outfile = re.sub ('\.latex$', '.ps.gz', header.outfile)
44 header.outfile = re.sub ('\.tex$', '.ps.gz', header.outfile)
45 header.outfile = re.sub ('\.doc$', '.ps.gz', header.outfile)
46 header.format = 'gzipped postscript'
52 m = re.search ('% *AUTHOR *= *(.*)$',s)
55 header.author = m.group (1)
58 m = re.search ('% *TITLE *= *(.*)$',s )
60 header.title = m.group (1)
62 header.title = '(bibliography without title)'
64 header.outfile = re.sub ( '\.bib$', '.html' , fn)
65 header.format = 'HTML'
69 def read_pod_header (fn):
70 header = Latex_head ()
72 i = re.search( '[^\n \t]', s)
74 i = re.search( '\n\n', s)
77 sys.stderr.write ('gulped file: ' + fn + '\n')
79 i = re.search( '\n\n', s)
82 header.outfile = re.sub ('\.pod$', '.html', fn)
85 def read_texinfo_header (fn):
86 header = Latex_head ()
88 m = re.search( '@settitle (.*$)', s)
90 header.title = m.group (1)
92 header.outfile = re.sub ('\.tely', '.html', fn)
93 header.format = 'HTML'
96 def read_tely_header (fn):
97 header = Latex_head ()
99 m = re.search( '@settitle (.*$)', s)
101 header.title = m.group (1)
103 header.outfile = re.sub ('\.tely', '.html', fn)
104 header.format = 'HTML'
108 def print_html_head (l,o,h):
111 l.write ('<li><a href=%s>%s (%s)</a>' % (pre + h.outfile, h.title, h.format ))
113 l.write ('<p>by %s</p>' % h.author)
117 sys.stdout.write ("Usage: ls-latex [OPTION]... FILE...\n"
118 "Generate html index file for FILE...\n\n"
120 + " -h, --help print this help\n"
126 (options, files) = getopt.getopt(sys.argv[1:],
127 'e:h', ['help', 'prefix=', 'title='])
140 elif o == '-h' or o == '--help':
146 l.write ('<html><title>%s</title><h1> %s</h1><ul>\n' % (title, title))
150 if re.search ('\\.bib$', x) :
151 head = bib_header (x)
152 elif re.search ('\\.pod$', x) :
153 head = read_pod_header (x)
154 elif re.search ('\\.texinfo$', x) :
155 head = read_texinfo_header (x)
156 elif re.search ('\\.tely$', x):
157 head = read_tely_header (x)
159 head = read_latex_header (x)
161 head.title = head.filename
162 print_html_head (l, pre, head)
164 l.write ('</ul></html>')