# * Figure out clean set of options. Hmm, isn't it pretty ok now?
# * add support for .lilyrc
# * EndLilyPondOutput is def'd as vfil. Causes large white gaps.
+# * texinfo: add support for @pagesize
-# todo: dimension handling (all the x2y) is clumsy.
+# todo: dimension handling (all the x2y) is clumsy. (tca: Thats
+# because the values are taken directly from texinfo.tex,
+# geometry.sty and article.cls. Give me a hint, and I'll
+# fix it.)
# This is was the idea for handling of comments:
# Multiline comments, @ignore .. @end ignore is scanned for
program_version = '@TOPLEVEL_VERSION@'
if program_version == '@' + 'TOPLEVEL_VERSION' + '@':
- program_version = '1.3.106'
+ program_version = '1.3.113'
include_path = [os.getcwd()]
class TexiPaper:
def __init__(self):
- self.m_papersize = 'a4'
+ self.m_papersize = 'letterpaper'
self.m_fontsize = 12
def get_linewidth(self):
return texi_linewidths[self.m_papersize][self.m_fontsize]
'executivepaper':{10: 345, 11: 360, 12: 379}}
texi_linewidths = {
- 'a4': {12: 455},
- 'a4wide': {12: 470},
- 'smallbook': {12: 361},
- 'texidefault': {12: 433}}
+ 'afourpaper': {12: mm2pt(160)},
+ 'afourwide': {12: in2pt(6.5)},
+ 'afourlatex': {12: mm2pt(150)},
+ 'smallbook': {12: in2pt(5)},
+ 'letterpaper': {12: in2pt(6)}}
option_definitions = [
('EXT', 'f', 'format', 'set format. EXT is one of texi and latex.'),
# should also support fragment in
- 'output-all': r"""@tex
+ 'output-all': r"""
+@tex
\catcode`\@=12
\input lilyponddefs
\def\EndLilyPondOutput{}
return re_dict[format][name]
def bounding_box_dimensions(fname):
+ if g_outdir:
+ fname = os.path.join(g_outdir, fname)
try:
fd = open(fname)
except IOError:
idx = 0
while 1:
if chunks[idx][0] == 'input':
- if string.find(chunks[idx][1], "@afourpaper") != -1:
- paperguru.m_papersize = 'a4'
- elif string.find(chunks[idx][1], "@afourwide") != -1:
- paperguru.m_papersize = 'a4wide'
- elif string.find(chunks[idx][1], "@smallbook") != -1:
- paperguru.m_papersize = 'smallbook'
+ for s in ('afourpaper', 'afourwide', 'letterpaper',
+ 'afourlatex', 'smallbook'):
+ if string.find(chunks[idx][1], "@%s" % s) != -1:
+ paperguru.m_papersize = s
idx = idx + 1
if idx == 10 or idx == len(chunks):
break
needed_filetypes.append('png')
if 'eps' in opts and not ('eps' in needed_filetypes):
needed_filetypes.append('eps')
- outname = os.path.join(g_outdir, basename)
+ pathbase = os.path.join (g_outdir, basename)
def f(base, ext1, ext2):
a = os.path.isfile(base + ext2)
if (os.path.isfile(base + ext1) and
not os.path.isfile(base + ext2):
return 1
todo = []
- if 'tex' in needed_filetypes and f(outname, '.ly', '.tex'):
+ if 'tex' in needed_filetypes and f(pathbase, '.ly', '.tex'):
todo.append('tex')
- if 'eps' in needed_filetypes and f(outname, '.tex', '.eps'):
+ if 'eps' in needed_filetypes and f(pathbase, '.tex', '.eps'):
todo.append('eps')
- if 'png' in needed_filetypes and f(outname, '.eps', '.png'):
+ if 'png' in needed_filetypes and f(pathbase, '.eps', '.png'):
todo.append('png')
newbody = ''
if 'verbatim' in opts:
else:
s = 'output-tex'
else: # format == 'texi'
- s = 'output-all'
- newbody = newbody + get_output(s) % {'fn': basename }
+ s = 'output-all'
+ newbody = newbody + get_output (s) % {'fn': basename }
return ('lilypond', newbody, opts, todo, basename)
def process_lilypond_blocks(outname, chunks):#ugh rename
incs = map (incl_opt, include_path)
lilyopts = string.join (incs, ' ' )
texfiles = string.join (tex, ' ')
- system ('lilypond %s %s' % (lilyopts, texfiles))
+ system ('lilypond --header=texidoc %s %s' % (lilyopts, texfiles))
for e in eps:
system(r"tex '\nonstopmode \input %s'" % e)
system(r"dvips -E -o %s %s" % (e + '.eps', e))
NO WARRANTY.
""")
+
+def check_texidoc (chunks):
+ n = []
+ for c in chunks:
+ if c[0] == 'lilypond':
+ (type, body, opts, todo, basename) = c;
+ pathbase = os.path.join (g_outdir, basename)
+ if os.path.isfile (pathbase + '.texidoc'):
+ body = '\n@include %s.texidoc' % basename + body
+ c = (type, body, opts, todo, basename)
+ n.append (c)
+ return n
+
+def fix_epswidth (chunks):
+ newchunks = []
+ for c in chunks:
+ if c[0] == 'lilypond' and 'eps' in c[2]:
+ body = re.sub (r"""\\lilypondepswidth{(.*?)}""", find_eps_dims, c[1])
+ newchunks.append(('lilypond', body, c[2], c[3], c[4]))
+ else:
+ newchunks.append (c)
+ return newchunks
+
+
def do_file(input_filename):
file_settings = {}
if outname:
#sys.exit()
scan_preamble(chunks)
chunks = process_lilypond_blocks(my_outname, chunks)
+
# Do It.
if __main__.g_run_lilypond:
compile_all_files (chunks)
- newchunks = []
- # finishing touch.
- for c in chunks:
- if c[0] == 'lilypond' and 'eps' in c[2]:
- body = re.sub (r"""\\lilypondepswidth{(.*?)}""", find_eps_dims, c[1])
- newchunks.append (('lilypond', body))
- else:
- newchunks.append (c)
- chunks = newchunks
+ chunks = fix_epswidth (chunks)
+
+ if __main__.format == 'texi':
+ chunks = check_texidoc (chunks)
+
x = 0
chunks = completize_preamble (chunks)
foutn = os.path.join(g_outdir, my_outname + '.' + format)
for c in chunks:
fout.write (c[1])
fout.close ()
+ # should chmod -w
if do_deps:
write_deps (my_depname, foutn)