From: Jan Nieuwenhuizen Date: Wed, 24 Apr 2002 14:44:53 +0000 (+0000) Subject: * Documentation/user/lilypond-book.itely: X-Git-Tag: release/1.5.55~12 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f568aa2074c09c341277f78f15bd1cf5f770c094;p=lilypond.git * Documentation/user/lilypond-book.itely: * scripts/lilypond-book.py: Add options [no]indent, linewidth and noinline. --- diff --git a/ChangeLog b/ChangeLog index f42cd102de..15159b6ee5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2002-04-24 Jan Nieuwenhuizen + * Documentation/user/lilypond-book.itely: + * scripts/lilypond-book.py: Add options [no]indent, linewidth and + noinline. + * input/mozart-hrn3-defs.ly (startGraceContext): Customize grace init. * scm/grob-property-description.scm (beam-space): Junk. diff --git a/Documentation/user/lilypond-book.itely b/Documentation/user/lilypond-book.itely index 0250be7066..d3ad0259dd 100644 --- a/Documentation/user/lilypond-book.itely +++ b/Documentation/user/lilypond-book.itely @@ -173,8 +173,8 @@ smaller music font size (eg. 11 pt or 13 pt) @item intertext="@var{text}" Used in conjunction with @code{verbatim} option: this puts @var{text} between the code and the music. -@item filename=@var{FILENAME} - Save the lilypond code to @var{FILENAME}. By default, a hash value +@item filename="@var{filename}" + Save the lilypond code to @var{filename}. By default, a hash value of the code is used. @item @code{11pt} @@ -216,10 +216,16 @@ of the code is used. Produce a single naturally spaced, unjustified line. (i.e.: linewidth = -1). @item multiline The opposite of @code{singleline}: justify and break lines. +@item linewidth=@var{size}@var{unit} + Set linewidth to @var{size}, where @var{unit} = cm, mm, in or pt. @item fragment @item nofragment Override @command{lilypond-book} auto detection of what type of code is in the lilypond block, voice contents or complete code. +@item indent=@var{size}@var{unit} + Set first line indent to @var{size}, where @var{unit} = cm, mm, in or pt. +@item noindent + Set first line indent to zero. @item printfilename Prints the file name before the music example. Useful in conjunction with @code{\lilypondfile}. diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 7167d637b7..9c3d863adf 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -431,6 +431,9 @@ output_dict= { 'output-default-pre': "\\def\preLilypondExample{}\n", 'usepackage-graphics': '\\usepackage{graphics}\n', 'output-eps': '\\noindent\\parbox{\\lilypondepswidth{%(fn)s.eps}}{\includegraphics{%(fn)s.eps}}', + 'output-noinline': r''' +%% generated: %(fn)s.eps +''', 'output-tex': '{\\preLilypondExample \\input %(fn)s.tex \\postLilypondExample\n}', 'pagebreak': r'\pagebreak', }, @@ -445,6 +448,9 @@ output_dict= { 'output-lilypond-fragment': """@lilypond[%s] \context Staff\context Voice{ %s } @end lilypond """, + 'output-noinline': r''' +@c generated: %(fn)s.png +''', 'pagebreak': None, 'output-verbatim': r"""@example %s @@ -590,6 +596,8 @@ def compose_full_body (body, opts): Add stuff to BODY using OPTS as options.""" music_size = default_music_fontsize latex_size = default_text_fontsize + indent = '' + linewidth = '' for o in opts: if g_force_lilypond_fontsize: music_size = g_force_lilypond_fontsize @@ -601,6 +609,16 @@ def compose_full_body (body, opts): m = re.match ('latexfontsize=([0-9]+)pt', o) if m: latex_size = string.atoi (m.group (1)) + + m = re.match ('indent=([-.0-9]+)(cm|in|mm|pt)', o) + if m: + f = float (m.group (1)) + indent = 'indent = %f\\%s' % (f, m.group (2)) + + m = re.match ('linewidth=([-.0-9]+)(cm|in|mm|pt)', o) + if m: + f = float (m.group (1)) + linewidth = 'linewidth = %f\\%s' % (f, m.group (2)) if re.search ('\\\\score', body): is_fragment = 0 @@ -613,10 +631,15 @@ def compose_full_body (body, opts): if is_fragment and not 'multiline' in opts: opts.append('singleline') + if 'singleline' in opts: - l = -1.0; - else: - l = __main__.paperguru.get_linewidth() + linewidth = 'linewidth = -1.0' + elif not linewidth: + l = __main__.paperguru.get_linewidth () + linewidth = 'linewidth = %f\pt' % l + + if 'noindent' in opts: + indent = 'indent = 0.0\mm' for o in opts: m= re.search ('relative(.*)', o) @@ -637,20 +660,23 @@ def compose_full_body (body, opts): body = '\\relative %s { %s }' %(pitch, body) if is_fragment: - body = r"""\score { + body = r'''\score { \notes { %s } \paper { } -}""" % body +}''' % body opts = uniq (opts) optstring = string.join (opts, ' ') optstring = re.sub ('\n', ' ', optstring) - body = r""" + body = r''' %% Generated automatically by: lilypond-book.py %% options are %s \include "paper%d.ly" -\paper { linewidth = %f \pt } -""" % (optstring, music_size, l) + body +\paper { + %s + %s +} +''' % (optstring, music_size, linewidth, indent) + body # ughUGH not original options return body @@ -986,7 +1012,10 @@ def schedule_lilypond_block (chunk): m = re.search ('intertext="(.*?)"', o) if m: newbody = newbody + m.group (1) + "\n\n" - if format == 'latex': + + if 'noinline' in opts: + s = 'output-noinline' + elif format == 'latex': if 'eps' in opts: s = 'output-eps' else: