while datadir[-1] == os.sep:
datadir= datadir[:-1]
-# Try to cater for bad installations of LilyPond, that have
-# broken TeX setup. Just hope this doesn't hurt good TeX
-# setups. Maybe we should check if kpsewhich can find
-# feta16.{afm,mf,tex,tfm}, and only set env upon failure.
+kpse = os.popen ('kpsexpand \$TEXMF').read()
+kpse = re.sub('[ \t\n]+$','', kpse)
+type1_paths = os.popen ('kpsewhich -expand-path=\$T1FONTS').read ()
+
environment = {
- 'MFINPUTS' : datadir + '/mf:',
- 'TEXINPUTS': datadir + '/tex:' + datadir + '/ps:.:',
- 'TFMFONTS' : datadir + '/tfm:',
- 'GS_FONTPATH' : datadir + '/afm:' + datadir + '/pfa',
+ # TODO: * prevent multiple addition.
+ # * clean TEXINPUTS, MFINPUTS, TFMFONTS,
+ # as these take prevalence over $TEXMF
+ # and thus may break tex run?
+ 'TEXMF' : "{%s,%s}" % (datadir, kpse) ,
+ 'GS_FONTPATH' : type1_paths,
'GS_LIB' : datadir + '/ps',
}
}
def setup_environment ():
+ # $TEXMF is special, previous value is already taken care of
+ if os.environ.has_key ('TEXMF'):
+ del os.environ['TEXMF']
+
for key in environment.keys ():
val = environment[key]
if os.environ.has_key (key):
#warning: this uses extended regular expressions. Tread with care.
-# legenda (?P name parameter
-# *? match non-greedily.
+# legenda
+# (?P -- name parameter
+# *? -- match non-greedily.
+# (?m) -- ?
re_dict = {
'html': {
'include': no_match,
'landscape': no_match,
'verbatim': r'''(?s)(?P<code><pre>\s.*?</pre>\s)''',
'verb': r'''(?P<code><pre>.*?</pre>)''',
- 'lilypond-file': '(?m)(?P<match><lilypondfile(?P<options>[^>]*)?>\s*(?P<filename>.*?)\s*</lilypondfile>)',
+ 'lilypond-file': r'(?m)(?P<match><lilypondfile(?P<options>[^>]+)?>\s*(?P<filename>[^<]+)\s*</lilypondfile>)',
'lilypond' : '(?m)(?P<match><lilypond((?P<options>[^:]*):)(?P<code>.*?)/>)',
- 'lilypond-block': r'''(?ms)(?P<match><lilypond(?P<options>[^>]*)?>(?P<code>.*?)</lilypond>)''',
+ 'lilypond-block': r'''(?ms)(?P<match><lilypond(?P<options>[^>]+)?>(?P<code>.*?)</lilypond>)''',
'option-sep' : '\s*',
'intertext': r',?\s*intertext=\".*?\"',
'multiline-comment': r"(?sm)\s*(?!@c\s+)(?P<code><!--\s.*?!-->)\s",
texfiles = string.join (tex, ' ')
cmd = 'lilypond --header=texidoc %s %s %s' \
% (lilyopts, g_extra_opts, texfiles)
- quiet_system (cmd, 'LilyPond')
+
+ system (cmd)
#
# Ugh, fixing up dependencies for .tex generation
f.close ()
for e in eps:
- cmd = r"tex '\nonstopmode \input %s'" % e
+ cmd = r"echo $TEXMF; tex '\nonstopmode \input %s'" % e
quiet_system (cmd, 'TeX')
cmd = r"dvips -E -o %s %s" % (e + '.eps', e)
##docme: why global?
foutn=""
def do_file(input_filename):
- global foutn
- file_settings = {}
- if outname:
- my_outname = outname
- elif input_filename == '-' or input_filename == "/dev/stdin":
- my_outname = '-'
- else:
- my_outname = os.path.basename (os.path.splitext(input_filename)[0]) + '.' + format
- my_depname = my_outname + '.dep'
chunks = read_doc_file(input_filename)
chunks = chop_chunks(chunks, 'lilypond', make_lilypond, 1)
x = 0
chunks = completize_preamble (chunks)
+
+
+ global foutn
+
+ if outname:
+ my_outname = outname
+ elif input_filename == '-' or input_filename == "/dev/stdin":
+ my_outname = '-'
+ else:
+ my_outname = os.path.basename (os.path.splitext(input_filename)[0]) + '.' + format
+ my_depname = my_outname + '.dep'
+
if my_outname == '-' or my_outname == '/dev/stdout':
fout = sys.stdout
foutn = "<stdout>"