From: Han-Wen Nienhuys Date: Thu, 26 Sep 2002 11:10:05 +0000 (+0000) Subject: werner's patch. X-Git-Tag: release/1.6.5~6 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=deed618967e0035a043eab0cd1e82b141d944ce1;p=lilypond.git werner's patch. --- diff --git a/ChangeLog b/ChangeLog index 25fb55be6d..ed0c9ea142 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,42 @@ +2002-09-23 Werner Lemberg + + * scripts/lilypond-book.py (output_dict): Fix handling of + various environments by avoid extraneous newlines. + Rename `output-all' regexp for html to `output-html'. + Replace `output-all' regexp for texi with `output-texi-quote' + and `output-texi-noquote'. + (compose_full_body): Don't override `linewidth' user option + for `singleline'. + (schedule_lilypond_block): Don't indent text specified with + `intertext' option. + Add new option `noquote'. + (compile_all_files): Use latex instead of tex to compile ly + files directly. + + * Documentation/user/lilypond-book.itely: Updated and revised. + Improve layout. + + * Documentation/user/glossary.tely, + Documentation/user/introduction.itely, + Documentation/user/tutorial.itely, + Documentation/user/refman.itely, + Documentation/user/appendices.itely: Fix overfull LilyPond + boxes caused by the new lilypond-book code. Other minor + fixes. + + * Documentation/user/macros.itexi (@texiflat): Don't emit + trailing space. + + * scm/tex.scm (end-output, header-end): Add preamble and + postamble to make lilypond output directly compilable with + latex. + + +2002-09-23 Han-Wen Nienhuys + + * Documentation/topdocs/INSTALL.texi (Top): bugfix for RH RPM + instructions. + 2002-09-25 Jan Nieuwenhuizen * Documentation/user/glossary.tely: Add titling and hyperlinks. @@ -21,6 +60,7 @@ scm/grob-property-description.scm, scripts/convert-ly.py: renamed Stem properties: flag-style -> stroke-style, style -> flag-style. + 2002-09-22 Werner Lemberg * scripts/lilypond-book.py: Add option `notime' to suppress diff --git a/Documentation/user/appendices.itely b/Documentation/user/appendices.itely index fc1e7726f5..b42c474358 100644 --- a/Documentation/user/appendices.itely +++ b/Documentation/user/appendices.itely @@ -38,8 +38,7 @@ rules. @section American Chords -@quotation -@lilypond[verbatim] +@lilypond[verbatim, noquote, noindent, notime] \include "english.ly" scheme = \chords { @@ -75,6 +74,7 @@ scheme = \chords { \context Staff \transpose c'' \scheme > \paper { + linewidth = 5.7\in \translator { \ChordNamesContext ChordName \override #'word-space = #1 @@ -83,15 +83,14 @@ scheme = \chords { } } @end lilypond -@end quotation @node Jazz chords @section Jazz chords Similarly, Jazz style chord names are implemented as a variation on American style names: -@quotation -@lilypond[verbatim] + +@lilypond[verbatim, noquote, noindent, notime] scheme = \chords { % major chords c @@ -139,6 +138,7 @@ scheme = \chords { \context Staff \transpose c'' \scheme > \paper { + linewidth = 5.7\in \translator { \ChordNamesContext ChordName \override #'word-space = #1 @@ -147,7 +147,6 @@ scheme = \chords { } } @end lilypond -@end quotation @c [barnumbers look silly, fixme.] @@ -208,7 +207,7 @@ The following symbols are available in the Feta font and may be accessed directly using text markup such as @code{g^#'(music "scripts-segno")}, see @ref{Text markup}. -@lilypondfile{feta16list.ly} +@lilypondfile[noquote,noindent]{feta16list.ly} @c parmesan is too big. Apparently pythons re's choke on this. @c @lil ypondfile{parmesan16list.ly} diff --git a/Documentation/user/glossary.tely b/Documentation/user/glossary.tely index 9bccc4c945..62d9adae9b 100644 --- a/Documentation/user/glossary.tely +++ b/Documentation/user/glossary.tely @@ -873,7 +873,7 @@ also the contrapunctal technique used in the @emph{fugue} which, since the music of the baroque era, has been one of the most popular polyphonic composition methods. -@lilypond[11pt] +@lilypond[11pt,noquote] \property Score.TimeSignature \override #'style = #'() \notes\context PianoStaff < \context Staff = SA \relative c' { @@ -1188,7 +1188,7 @@ harmonic minor scale type an augmented second (A) occurs between the 6th and } @end lilypond -@lilypond[13pt,notime] +@lilypond[13pt,notime,linewidth=110mm] \property Score.barNonAuto = ##t \property Score.LyricText \set #'font-style = #'large \property Score.TextScript \set #'font-style = #'large diff --git a/Documentation/user/introduction.itely b/Documentation/user/introduction.itely index 0c22d5f2d4..d66166256d 100644 --- a/Documentation/user/introduction.itely +++ b/Documentation/user/introduction.itely @@ -3,16 +3,15 @@ @node Introduction @chapter Introduction - -LilyPond is a program to print sheet music. If you have used notation +LilyPond is a program to print sheet music. If you have used notation programs before, then the way to use this program might be surprising -at first sight. To print music with lilypond, you have to enter -musical codes in a file. Then you run LilyPond on the file, and the -music is produced without any further intervention. For example, +at first sight. To print music with lilypond, you have to enter +musical codes in a file. Then you run LilyPond on the file, and the +music is produced without any further intervention. For example, something like this: @lilypond[fragment,verbatim, relative 1, intertext="produces this"] -\key c \minor r8 c16 b c8 g as c16 b c8 d | g,4 +\key c \minor r8 c16 b c8 g as c16 b c8 d | g,4 @end lilypond @cindex encoding music @@ -30,10 +29,10 @@ In this chapter, we will explain the reasoning behind this unusual design, and how this approach affects you as a user. @menu -* Batch processing:: -* Music engraving:: -* Music representation:: -* About this manual:: +* Batch processing:: +* Music engraving:: +* Music representation:: +* About this manual:: @end menu @node Batch processing @@ -41,7 +40,7 @@ design, and how this approach affects you as a user. @cindex GUI @cindex Batch -@cindex UNIX +@cindex UNIX When we started developing LilyPond, we were still studying at the university. We were interested in music notation, not as publishers @@ -111,22 +110,22 @@ experience, we would not have realized how ugly the fonts were that we admired at first. -@lilypond +@lilypond[noindent] #(define magfact 3.0) \score { \notes { as'2 r4 } - \paper { - linewidth = -1. - \translator { - \ScoreContext - AccidentalPlacement \override #'right-padding = #3.0 - StaffSymbol \override #'transparent = ##t - Clef \override #'transparent = ##t - TimeSignature \override #'transparent = ##t - Accidental \override #'font-magnification = #magfact - Rest \override #'font-magnification = #magfact - NoteHead \override #'font-magnification = #magfact - Stem \override #'transparent = ##t - } } } + \paper { + linewidth = -1. + \translator { + \ScoreContext + AccidentalPlacement \override #'right-padding = #3.0 + StaffSymbol \override #'transparent = ##t + Clef \override #'transparent = ##t + TimeSignature \override #'transparent = ##t + Accidental \override #'font-magnification = #magfact + Rest \override #'font-magnification = #magfact + NoteHead \override #'font-magnification = #magfact + Stem \override #'transparent = ##t + } } } @end lilypond @cindex musical symbols @@ -157,7 +156,7 @@ which? @c I can only see the motive printed two times!!! /Mats @cindex optical spacing -@lilypond +@lilypond[noindent] \score { \notes { \property Staff.NoteSpacing \set #'stem-spacing-correction = #0.6 @@ -168,7 +167,7 @@ which? \property Staff.StaffSpacing \override #'stem-spacing-correction = #0.0 c'4 e''4 e'4 b'4 | - \stemDown b'4 e''4 a'4 e''4| + \stemDown b'4 e''4 a'4 e''4| } \paper { linewidth = -1. } } @end lilypond @@ -298,7 +297,7 @@ in the lilypond-internals manual much easier. @cindex variables @cindex properties @cindex lilypond-internals -@cindex internal documentation +@cindex internal documentation For those who really want to get their hands dirty: it is even possible to add your own functionality, by extending LilyPond in the diff --git a/Documentation/user/lilypond-book.itely b/Documentation/user/lilypond-book.itely index b8ae67f188..5023fc7f15 100644 --- a/Documentation/user/lilypond-book.itely +++ b/Documentation/user/lilypond-book.itely @@ -21,20 +21,20 @@ LilyPond code, process it separately to embedded PostScript or @code{html} source. @command{lilypond-book} provides you with a way to automate this -process: this program extracts snippets of music from your document, -runs lilypond on them, and substitutes the resulting pictures back. -The line width and font size definitions for the music are adjusted so -they match the layout of your document. +process: This program extracts snippets of music from your document, +runs LilyPond on them, and substitutes the resulting pictures back. +The line width and font size definitions for the music are adjusted +to match the layout of your document. It can work on La@TeX{}, @code{html} or texinfo documents. A tutorial on using lilypond-book is in @ref{Integrating text and music}. @menu -* Integrating Texinfo and music:: -* Integrating La@TeX{} and music:: -* Integrating HTML and music:: -* Music fragment options:: -* Invoking lilypond-book:: +* Integrating Texinfo and music:: +* Integrating La@TeX{} and music:: +* Integrating HTML and music:: +* Music fragment options:: +* Invoking lilypond-book:: @end menu @@ -50,62 +50,76 @@ on using lilypond-book is in @ref{Integrating text and music}. @section Integrating Texinfo and music You specify the LilyPond code like this: + @example @@lilypond[options, go, here] YOUR LILYPOND CODE @@end lilypond -@@lilypond[option, go, here]@{ YOUR LILYPOND CODE @} -@@lilypondfile[options, go,here]@{@var{filename}@} +@@lilypond[options, go, here]@{ YOUR LILYPOND CODE @} +@@lilypondfile[options, go, here]@{@var{filename}@} @end example -We show two simple examples here. First a complete block: +We show two simple examples here. First a complete block: + @example @@lilypond[26pt] -c' d' e' f' g'2 g' + c' d' e' f' g'2 g' @@end lilypond @end example +@noindent produces this music: + @lilypond -c' d' e' f' g'2 g' + c' d' e' f' g'2 g' @end lilypond Then the short version: + @example @@lilypond[11pt]@{@} @end example +@noindent and its music: @lilypond[11pt]{} -@command{lilypond-book} knows the default margins, and a few paper -sizes. One of these commands should be in the beginning of the document: +@command{lilypond-book} knows the default margins and a few paper +sizes. One of these commands should be in the beginning of the document: + @itemize @bullet @item @code{@@afourpaper} @item @code{@@afourlatex} @item @code{@@afourwide} @item @code{@@smallbook} @end itemize + +@noindent @code{@@pagesizes} are not yet supported. When producing texinfo, lilypond-book also generates bitmaps of the music, so you can make a HTML document with embedded music. + @node Integrating La@TeX{} and music @section Integrating La@TeX{} and music -You specify the LilyPond code like this: +You specify LilyPond code like this: + @example -\begin[option, go, here]@{lilypond@} - YOUR LILYPOND CODE +\begin[options, go, here]@{lilypond@} + YOUR LILYPOND CODE \end@{lilypond@} @end example @example \lilypondfile[options, go,here]@{@var{filename}@} @end example -or + +@noindent +or + @example \lilypond@{ YOUR LILYPOND CODE @} @end example @@ -114,40 +128,42 @@ We show some examples here. @example \begin[26pt]@{lilypond@} -c' d' e' f' g'2 g'2 + c' d' e' f' g'2 g'2 \end@{lilypond@} @end example +@noindent produces this music: @lilypond[26pt] -c' d' e' f' g'2 g'2 + c' d' e' f' g'2 g'2 @end lilypond Then the short version: + @example \lilypond[11pt]@{@} @end example +@noindent and its music: @lilypond[11pt]{} - You can use whatever commands you like in the document preamble, -that is the part of the document before @code{\begin@{document@}}. +the part of the document before @code{\begin@{document@}}. @command{lilypond-book} will send it to La@TeX{} to find out how wide the text is and adjust the linewidth variable in the paper definition of -you music according to that. +your music according to that. After @code{\begin@{document@}} you must be a little more careful when you use commands that change the width of the text and how -many columns there are. @command{lilypond-book} know about the +many columns there are. @command{lilypond-book} knows about the @code{\onecolumn} and @code{\twocolumn} commands and the @code{multicols} environment from the multicol package. The music will be surrounded by @code{\preLilypondExample} and -@code{\postLilypondExample}. The variables are +@code{\postLilypondExample}. The variables are defined to nothing by default, and the user can redefine them to whatever he wants. @@ -155,229 +171,261 @@ to whatever he wants. @node Integrating HTML and music @section Integrating HTML and music -You specify the LilyPond code like this: +You specify LilyPond code like this: -@quotation @example \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4 - + @end example -@end quotation +@noindent produces -@quotation @example \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4 - + @end example + @lilypond[relative1] \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4 @end lilypond -@end quotation Inline picture: -@quotation @example Some music in a line of text. @end example -@end quotation + @node Music fragment options @section Music fragment options -The commands for lilypond-book have room to specify options. These are +The commands for lilypond-book have room to specify options. These are all of the options: @table @code @item eps This will create the music as eps graphics and include it into the -document with the @code{\includegraphics} command. It works in +document with the @code{\includegraphics} command. It works in La@TeX{} only. This enables you to place music examples in the running text (and not in -a separate paragraph). To avoid that La@TeX{} places the music on a line +a separate paragraph). To avoid that La@TeX{} places the music on a line of its own, there should be no empty lines between the normal text and the LilyPond environment. For inline music, you probably also need a -smaller music font size (eg. 11 pt or 13 pt) - +smaller music font size (e.g.@: 11@dmn{pt} or 13@dmn{pt}) @item verbatim - CONTENTS is copied into the source enclosed in a verbatim block, - followed by any text given with the @code{intertext} option, then - the actual music is displayed. This option does not work with - the short version of the LilyPond blocks: +CONTENTS is copied into the source enclosed in a verbatim block, +followed by any text given with the @code{intertext} option, then +the actual music is displayed. This option does not work with +the short version of the LilyPond blocks: - @code{ @@lilypond@{ CONTENTS @} } and @code{ \lilypond@{ CONTENTS @} } +@code{ @@lilypond@{ CONTENTS @} } and @code{ \lilypond@{ CONTENTS @} } @item smallverbatim - like @code{verbatim}, but in a smaller font. +Like @code{verbatim}, but in a smaller font. @item intertext="@var{text}" - Used in conjunction with @code{verbatim} option: this puts -@var{text} between the code and the music. +Used in conjunction with @code{verbatim} option: This puts +@var{text} between the code and the music (without indentation). + @item filename="@var{filename}" - Save the LilyPond code to @var{filename}. By default, a hash value +Save the LilyPond code to @var{filename}. By default, a hash value of the code is used. -@item @code{11pt} +@item 11pt @lilypond[11pt, eps] - \relative c'{ - r16 [c d e][f d e c] [g'8 c][b-\prall c] | - [d16 g, a b][c a b g][d'8 g f-\prall g] - } +\relative c' { + r16 [c d e][f d e c] [g'8 c][b-\prall c] | + [d16 g, a b][c a b g][d'8 g f-\prall g] +} @end lilypond -@item @code{13pt} + +@item 13pt @lilypond[13pt, eps] - \relative c'{ - r16 [c d e][f d e c] [g'8 c][b-\prall c] | - [d16 g, a b][c a b g][d'8 g f-\prall g] - } +\relative c' { + r16 [c d e][f d e c] [g'8 c][b-\prall c] | + [d16 g, a b][c a b g][d'8 g f-\prall g] +} @end lilypond -@item @code{16pt} + +@item 16pt @lilypond[16pt, eps] - \relative c'{ - r16 [c d e][f d e c] [g'8 c][b-\prall c] | - [d16 g, a b][c a b g][d'8 g f-\prall g] - } +\relative c' { + r16 [c d e][f d e c] [g'8 c][b-\prall c] | +} @end lilypond -@item @code{20pt} + +@item 20pt @lilypond[20pt, eps] - \relative c'{ - r16 [c d e][f d e c] [g'8 c][b-\prall c] | - [d16 g, a b][c a b g][d'8 g f-\prall g] - } +\relative c' { + r16 [c d e][f d e c] [g'8 c][b-\prall c] | +} @end lilypond -@item @code{26pt} + +@item 26pt @lilypond[26pt, eps] - \relative c'{ - r16 [c d e][f d e c] [g'8 c][b-\prall c] | - } +\relative c' { + r16 [c d e][f d e c] [g'8 c][b-\prall c] | +} @end lilypond @item singleline - Produce a single naturally spaced, unjustified line. (i.e.: linewidth = -1). +Produce a single, naturally spaced, unjustified line +(i.e., linewidth = @minus{}1). + @item multiline - The opposite of @code{singleline}: justify and break lines. +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. +Set linewidth to @var{size}, where @var{unit} = cm, mm, in, or pt. +This option affects LilyPond output, not the text layout. + @item notime - Don't print time signature. +Don't print time signature. + @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. +@itemx 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. +Set indentation of the first music system to @var{size}, +where @var{unit} = cm, mm, in, or pt. This option affects LilyPond, +not the text layout. For single-line fragments the default is to +use no indentation. + @item noindent - Set first line indent to zero. +Set indentation of the first music system to zero. This option +affects LilyPond, not the text layout. + +@item noquote +By default, @command{lilypond-book} puts both La@TeX{} and texinfo output +into a quotation block. Using this option prevents this; no indentation +will be used. + @item printfilename - Prints the file name before the music example. Useful in conjunction +Prints the file name before the music example. Useful in conjunction with @code{\lilypondfile}. + @item relative, relative @var{N} - Use relative octave mode. By default, notes are specified relative - central C. The optional integer argument specifies how many octaves - higher (positive number) or lower (negative number) to place the - starting note. +Use relative octave mode. By default, notes are specified relative +central C. The optional integer argument specifies how many octaves +higher (positive number) or lower (negative number) to place the +starting note. @end table + @node Invoking lilypond-book @section Invoking lilypond-book When you run @command{lilypond-book} it will generate lots of small -files that LilyPond will process. So to avoid all the garbage in +files that LilyPond will process. To avoid all the garbage in your source directory, you should either change to a temporary -directory, or use the @code{--outdir} command line options: +directory, or use the @option{--outdir} command line options: @code{cd out && lilypond-book ../yourfile.tex} @code{lilypond-book --outdir=out yourfile.tex} - -For latex input, the file to give to latex has extension @file{.latex}. +For La@TeX{} input, the file to give to La@TeX{} has extension @file{.latex}. Texinfo input will be written to a file with extension @file{.texi}. -If you use @code{--outdir}, you should also @code{cd} to that directory -before running LaTeX or makeinfo. This may seem a little kludgey, but -both Latex and makeinfo expect picture files (the music) to be in the -current working directory. Moreover, if you do this, LaTeX will not -clutter you normal working directory with output files. +If you use @option{--outdir}, you should also @code{cd} to that directory +before running La@TeX{} or @command{makeinfo}. This may seem a little +kludgy, but both La@TeX{} and @command{makeinfo} expect picture files +(the music) to be in the current working directory. Moreover, if you do +this, La@TeX{} will not clutter your normal working directory with output +files. @cindex titling and lilypond-book @cindex lilypond-book and titling -@cindex \header in LaTeX documents +@cindex @code{\header} in La@TeX{} documents If you want to add titling from the @code{\header} section of the -files, you should add the following to the top of your LaTeX +files, you should add the following to the top of your La@TeX{} file: + @example \input titledefs.tex \def\preLilypondExample@{\def\mustmakelilypondtitle@{@}@} @end example -lilypond-book accepts the following command-line options: +@command{lilypond-book} accepts the following command line options: + @table @code -@item @option{-f}, @option{--format=} - Specify the document type to process: @code{html}, @code{latex} or -@code{texi} (default). @command{lilypond-book} usually figures this +@item @option{-f @var{format}}, @option{--format=@var{format}} +Specify the document type to process: @code{html}, @code{latex} or +@code{texi} (the default). @command{lilypond-book} usually figures this out automatically. -@item --default-music-fontsize=@var{sz}pt - Set the fontsize to use for LilyPond if no fontsize is given - as option. -@item --force-music-fontsize=@var{sz}pt - Force all LilyPond to use this fontsize, overriding options - given to @code{\begin@{lilypond@}} -@item -I @var{DIR}, --include=@var{DIR} - Add @var{DIR} to the include path. -@item -M, --dependencies - Write dependencies to @file{filename.dep} -@item --dep-prefix=@code{PREF} - prepend @code{PREF} before each @code{-M} dependency -@item -n, --no-lily - don't run LilyPond, but do generate the @code{.ly} files -@item --no-music - strip all LilyPond blocks from the file. -@item --no-pictures - don't generate pictures when processing Texinfo. -@item --read-lys - don't write ly files. This way you can do +@item @option{--default-music-fontsize=@var{sz}pt} +Set the fontsize to use for LilyPond if no fontsize is given +as option. + +@item @option{--force-music-fontsize=@var{sz}pt} +Force all LilyPond code to use this fontsize, overriding options +given to @code{\begin@{lilypond@}}. + +@item @option{-I @var{dir}}, @option{--include=@var{dir}} +Add @var{DIR} to the include path. + +@item @option{-M}, @option{--dependencies} +Write dependencies to @file{filename.dep}. + +@item @option{--dep-prefix=@var{pref}} +Prepend @var{pref} before each @option{-M} dependency. + +@item @option{-n}, @option{--no-lily} +Don't run LilyPond, but do generate the @code{.ly} files. + +@item @option{--no-music} +Strip all LilyPond blocks from the file. + +@item @option{--no-pictures} +Don't generate pictures when processing Texinfo. + +@item @option{--read-lys} +Don't write ly files. This way you can do + @example - lilypond-book file.tely - convert-ly - lilypond-book --read-lys +lilypond-book file.tely +convert-ly +lilypond-book --read-lys @end example -@item --outname=@var{FILE} - The name of La@TeX{} file to output. If this option is not given, - the output name is derived from the input name. -@item --outdir=@var{DIR} - place generated files in @var{DIR}. -@item --version - print version information -@item --help - Print a short help message +@item @option{--outname=@var{file}} +The name of La@TeX{} file to output. If this option is not given, +the output name is derived from the input name. + +@item @option{--outdir=@var{dir}} +Place generated files in @var{dir}. + +@item @option{--version} +Print version information. + +@item @option{--help} +Print a short help message. @end table @section Bugs - -The La@TeX{} \includeonly@{...@} command is ignored. + +The La@TeX{} @code{\includeonly@{...@}} command is ignored. The Texinfo command @code{pagesize} is on the TODO list for LilyPond -1.6, but changing the linewidth in other ways will not give you a +1.8, but changing the linewidth in other ways will not give you a straight right margin. Almost all La@TeX{} commands that change margins and line widths are ignored. -There is no way to automatically apply convert-ly only to fragments +There is no way to automatically apply @command{convert-ly} only to fragments inside a lilypond-book file. -@file{lilypond-book} processes all music fragments in one big run. The +@command{lilypond-book} processes all music fragments in one big run. The state of the GUILE interpreter is not reset between fragments; this -means that global GUILE definitions, eg. done with @code{#(define -.. )} and @code{#(set! .. )} can leak from one fragment into a next -fragment. +means that global GUILE definitions, e.g., done with @code{#(define @dots{})} +and @code{#(set! @dots{})} can leak from one fragment into the next fragment. diff --git a/Documentation/user/macros.itexi b/Documentation/user/macros.itexi index 64c289553b..a2a5ccab68 100644 --- a/Documentation/user/macros.itexi +++ b/Documentation/user/macros.itexi @@ -62,7 +62,7 @@ b @iftex @macro texiflat {word} @tex -$\\flat$ +$\\flat$% @end tex @end macro @end iftex diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index 24ce16ed5a..83447b1eea 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -244,14 +244,13 @@ and dots: durations are entered as their reciprocal values. For notes longer than a whole you must use identifiers. @example - c'\breve +c'\breve c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64 r\longa r\breve r1 r2 r4 r8 r16 r32 r64 r64 @end example - -@lilypond[] +@lilypond[noindent,noquote] \score { \notes \relative c'' { a\breve \autoBeamOff @@ -361,7 +360,7 @@ There is a facility for automatically converting long notes to tied notes. This is done by replacing the @code{Note_heads_engraver} by the @code{Completion_heads_engraver}. -@lilypond[verbatim,center] +@lilypond[verbatim,noindent,noquote] \score{ \notes\relative c'{ \time 2/4 c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2 @@ -1205,7 +1204,7 @@ same effect as twiddling with @code{stemLeftBeamCount} and \property Score.beatLength = #(make-moment 1 8) [c32 c c c c c c c c c c c c c c c] @end example -@lilypond[] +@lilypond[noindent,noquote] \score { \notes \relative c' { [c16 c c c c c c c] @@ -1871,8 +1870,8 @@ using @code{^} and @code{_}. } > \paper { - linewidth = 5.875\in - indent = 0.0 + linewidth = 5.1\in + indent = 0.0\mm } } @end lilypond @@ -2465,8 +2464,9 @@ In the above example the music was transformed using the list @code{'drums}. Currently the following lists are defined in @file{scm/drums.scm}: @table @code @item 'drums -To typeset a typical drum kit on a five line staff. -@lilypond[] +To typeset a typical drum kit on a five-line staff. + +@lilypond[noindent] \include "drumpitch-init.ly" nam = \lyrics { cymc cyms cymr hh hhc hho hhho hhp cb hc bd sn ss tomh tommh tomml toml tomfh tomfl } @@ -2481,6 +2481,7 @@ mus = \notes { cymc cyms cymr hh hhc hho hhho hhp cb hc \context Lyrics \nam > \paper { + linewidth = 100.0\mm \translator { \StaffContext \remove Bar_engraver @@ -2494,6 +2495,7 @@ mus = \notes { cymc cyms cymr hh hhc hho hhho hhp cb hc } } @end lilypond + Notice that the scheme supports six different toms. If you are using fewer toms then you simply select the toms that produce the desired result - i.e. to get toms on the three middle lines you @@ -2990,7 +2992,7 @@ e8 fis gis a b cis' dis' e' \property TabStaff.minimumFret = #8 e8 fis gis a b cis' dis' e' @end example -@lilypond +@lilypond[noindent,noquote] frag = \notes { \key e \major e8 fis gis a b cis' dis' e' @@ -3303,7 +3305,7 @@ chord name styles: @c too long? @c maybe just junk verbatim option? -@lilypond[verbatim,singleline] +@lilypond[verbatim,singleline,noquote] scheme = \chords { c1 c:5^3 c:4^3 c:5+ c:m7+ c:m5-.7 @@ -3421,7 +3423,7 @@ adds a box around the bar numbers: #(make-molecule-boxer 0.1 0.25 0.25 Text_item::brew_molecule) \property Score.BarNumber \override #'font-relative-size = #0 @end example -@lilypond +@lilypond[noindent,noquote] \score { \context Staff \notes \transpose c''' { \property Score.BarNumber \override #'break-visibility = #end-of-line-invisible @@ -3938,7 +3940,7 @@ anticipates the pitch of the first note(s) of the following line and thus helps the player or singer to manage line breaks during performance, thus enhancing readability of a score. -@lilypond[verbatim] +@lilypond[verbatim,noquote] \score { \notes { c'1 \break \property Staff.Custos \set #'style = #'mensural diff --git a/Documentation/user/tutorial.itely b/Documentation/user/tutorial.itely index 8ce4aba19c..664528b190 100644 --- a/Documentation/user/tutorial.itely +++ b/Documentation/user/tutorial.itely @@ -24,7 +24,7 @@ * End of tutorial:: The end @end menu -Operating lilypond is done through text files: to print a piece of +Operating lilypond is done through text files: To print a piece of music, you enter the music in a file. When you run lilypond (normally using the program @code{ly2dvi}) on that file, the program produces another file which contains sheet music that you can print or view. @@ -32,112 +32,82 @@ another file which contains sheet music that you can print or view. This tutorial starts with a small introduction to the LilyPond music language. After this first contact, we will show you how to run LilyPond to produce printed output; you should then be able to create -your first sheets of music. The tutorial continues with more and more +your first sheets of music. The tutorial continues with more and more complex examples. + @node First steps @section First steps We start off by showing how very simple music is entered in -LilyPond: you get a note simply by typing its note name, from -@code{a} through @code{g}. So if you enter -@quotation +LilyPond: You get a note simply by typing its note name, from +@samp{a} through @samp{g}. So if you enter + @example c d e f g a b @end example -@end quotation + +@noindent then the result looks like this: -@quotation -@lilypond[fragment] + +@lilypond[notime] \property Score.timing = ##f -\property Staff.TimeSignature = \turnOff \transpose c'' { c d e f g a b } @end lilypond -@end quotation -@separate -We will continue with this format: first we show a snippet of input, +We will continue with this format: First we show a snippet of input, then the resulting output. -The length of a note is specified by adding a number, ``@code{1}'' for a -whole note, ``@code{2}'' for a half note, and so on: +The length of a note is specified by adding a number, @samp{1} for a +whole note, @samp{2} for a half note, and so on: -@quotation @example a1 a2 a4 a16 a32 @end example -@c missing clef seems to raise more questions than actual pitch of notes, -@c as these are snippets anyway -@lilypond[fragment] +@lilypond[notime] \property Score.timing = ##f -\property Staff.TimeSignature = \turnOff \property Staff.autoBeaming = ##f -%\property Staff.Clef = \turnOff -\transpose c'' { a1 a2 a4 a16 a32 } -s16_" " +\transpose c'' { a1 a2 a4 a16 a32 s16_" " } @end lilypond -@end quotation -@separate If you don't specify a duration, the previous one is used: -@quotation + @example a4 a a2 a @end example -@c missing clef seems to raise more questions than actual pitch of notes, -@c as these are snippets anyway -@lilypond[fragment] +@lilypond[notime] \property Score.timing = ##f -\property Staff.TimeSignature = \turnOff -%\property Staff.Clef = \turnOff -\transpose c'' { a a a2 a } -s16_" " +\transpose c'' { a a a2 a s16_" " } @end lilypond -@end quotation -@separate -A sharp (@texisharp{}) is made by adding ``@code{is}'', a flat -(@texiflat{}) by adding ``@code{es}''. As you would expect, a -double-sharp or double-flat is made by adding ``@code{isis}'' or -``@code{eses}'': +A sharp (@texisharp{}) is made by adding @samp{is}, a flat +(@texiflat{}) by adding @samp{es}. As you would expect, a +double-sharp or double-flat is made by adding @samp{isis} or +@samp{eses}: -@quotation @example cis1 ees fisis aeses @end example -@lilypond[fragment] +@lilypond[notime] \property Score.timing = ##f -\property Staff.TimeSignature = \turnOff -\transpose c'' { cis1 ees fisis aeses } -s16_" " +\transpose c'' { cis1 ees fisis aeses s16_" " } @end lilypond -@end quotation -@separate -Add a dot ``@code{.}'' after the duration to get a dotted note: -@quotation +Add a dot @samp{.} after the duration to get a dotted note: @example a2. a4 a8. a16 @end example -@c missing clef seems to raise more questions than actual pitch of notes, -@c as these are snippets anyway -@lilypond[fragment] +@lilypond[notime] \property Score.timing = ##f -\property Staff.TimeSignature \set #'transparent = ##t -%\property Staff.Clef = \turnOff -\transpose c'' { a2. a4 a8. a16 } -s16_" " +\transpose c'' { a2. a4 a8. a16 s16_" " } @end lilypond -@end quotation -@separate The meter (or time signature) can be set with the @code{\time} command: -@quotation @example \time 3/4 \time 6/8 @@ -145,7 +115,7 @@ The meter (or time signature) can be set with the @code{\time} command: @end example @c a clef here may lead to confusion -@lilypond[fragment] +@lilypond \property Staff.Clef \set #'transparent = ##t \time 3/4 s4_" " @@ -154,15 +124,12 @@ s4_" " \time 4/4 s16_" " @end lilypond -@end quotation -@separate -The clef can be set using the ``@code{\clef}'' command: +The clef can be set using the @code{\clef} command: @c what is more common name treble or violin? @c in Dutch, its violin. @c in English its definitely treble. -@quotation @example \clef treble \clef bass @@ -170,9 +137,8 @@ The clef can be set using the ``@code{\clef}'' command: \clef tenor @end example -@lilypond[fragment] +@lilypond[notime] \property Score.timing = ##f -\property Staff.TimeSignature = \turnOff \clef violin s4_" " \clef bass @@ -182,51 +148,42 @@ s4_" " \clef tenor s16_" " @end lilypond -@end quotation -@separate -@c From these commands and notes, a piece of music can be formed. A piece -@c of music is made by enclosing it in ``@code{\notes @{ ... @}}''. -@c rephrased: When you enter these commands in a file, you must to enclose them in -``@code{\notes @{ .. @}}''. This lets LilyPond know that music (and +@code{\notes @{@dots{}@}}. This lets LilyPond know that music (and not lyrics, for example) follows: -@quotation @example \notes @{ - \time 3/4 - \clef bass - c2 e4 g2. - f4 e d c2. + \time 3/4 + \clef bass + c2 e4 g2. + f4 e d c2. @} @end example -@end quotation -@separate Now the piece of music is almost ready to be printed. The final step is to combine the music with a printing command. -The printing command is the so-called ``@code{\paper}'' block. Later on +The printing command is the so-called @code{\paper} block. Later on you will see that the @code{\paper} block is used to customize printing specifics. The music and the @code{\paper} block are combined by -enclosing them in ``@code{\score @{ ... @}}''. This is what a full +enclosing them in @code{\score @{ ... @}}. This is what a full LilyPond source file looks like: -@quotation @example \score @{ \notes @{ - \time 3/4 - \clef bass - c2 e4 g2. - f4 e d c2. + \time 3/4 + \clef bass + c2 e4 g2. + f4 e d c2. @} \paper @{ @} @} @end example -@lilypond +@lilypond[noindent] \score { \notes { \time 3/4 @@ -234,11 +191,11 @@ LilyPond source file looks like: c2 e4 g2. f4 e d c2. } - \paper { linewidth = 60 * \staffspace } + \paper { + linewidth = 55 * \staffspace + } } @end lilypond -@end quotation -@separate @node Running LilyPond @@ -395,8 +352,7 @@ discussed in the previous two sections. @item @code{1 2 8 16} @tab durations @tab -@lilypond[fragment, relative 1] -\property Staff.TimeSignature = \turnOff +@lilypond[relative 1, noquote, notime] \property Staff.autoBeaming = ##f \property Staff.Clef = \turnOff c1 c2 c8 c16 @@ -405,8 +361,7 @@ c1 c2 c8 c16 @item @code{. ..} @tab augmentation dots @tab -@lilypond[fragment, relative 1] -\property Staff.TimeSignature = \turnOff +@lilypond[relative 1, noquote, notime] \property Staff.Clef = \turnOff c4. c4.. @end lilypond @@ -414,8 +369,7 @@ c4. c4.. @item @code{c d e f g a b } @tab scale @tab -@lilypond[fragment, relative 1] -\property Staff.TimeSignature = \turnOff +@lilypond[relative 1, noquote, notime] \property Staff.Clef = \turnOff c d e f g a b @end lilypond @@ -423,8 +377,7 @@ c d e f g a b @item @code{\clef treble \clef bass } @tab clefs @tab -@lilypond[fragment] -\property Staff.TimeSignature \set #'transparent = ##t +@lilypond[noquote, notime] \clef treble s4_" " \clef bass @@ -434,7 +387,7 @@ s4_" " @item @code{\time 3/4 \time 4/4 } @tab time signature @tab -@lilypond[fragment] +@lilypond[noquote] \property Staff.Clef \set #'transparent = ##t \time 3/4 s4_" " @@ -681,30 +634,25 @@ The following table summarizes the syntax learned so far in this section. @item @code{r4 r8} @tab rest @tab -@lilypond[fragment, relative 1] -\property Staff.TimeSignature = \turnOff +@lilypond[relative 1, noquote, notime] \property Staff.Clef = \turnOff r4 r8 @end lilypond - @item @code{~} @tab tie @tab -@lilypond[fragment, relative 1] +@lilypond[relative 1, noquote, notime] \property Score.timing = ##f -\property Staff.TimeSignature = \turnOff \property Staff.autoBeaming = ##f \property Staff.Clef = \turnOff d ~ d @end lilypond - @item @code{\key es \major } @tab key signature @tab -@lilypond[fragment] -\property Staff.TimeSignature \set #'transparent = ##t +@lilypond[noquote, notime] \clef treble \key es \major s4 @@ -713,9 +661,8 @@ s4 @item @var{note}@code{'} @tab raise octave @tab -@lilypond[fragment, relative 1] +@lilypond[relative 1, noquote, notime] \property Score.timing = ##f -\property Staff.TimeSignature = \turnOff \property Staff.autoBeaming = ##f \property Staff.Clef = \turnOff a a' @@ -724,9 +671,8 @@ a a' @item @var{note}@code{,} @tab lower octave @tab -@lilypond[fragment, relative 1] +@lilypond[relative 1, noquote, notime] \property Score.timing = ##f -\property Staff.TimeSignature = \turnOff \property Staff.autoBeaming = ##f \property Staff.Clef = \turnOff c c, @@ -1762,7 +1708,7 @@ input file is a piano reduction of the G major Sinfonia by Giovanni Battista Sammartini, composed around 1740. It's in the source package under the name @file{input/tutorial/sammartini.ly}. -@lilypondfile[smallverbatim]{sammartini.ly} +@lilypondfile[smallverbatim,noquote]{sammartini.ly} As you can see, this example features multiple voices on one staff. To make room for those voices, their notes should be stemmed in opposite @@ -1948,12 +1894,12 @@ getting the motive in a wrong octave. @cindex @code{\translator} @example - \translator Staff = down - \stemUp - c8 - \translator Staff = up - \stemDown - c'8 @} +\translator Staff = down +\stemUp +c8 +\translator Staff = up +\stemDown +c'8 @} @end example Voices can switch between staves. Here you see two staff switching commands. The first one moves to the lower staff, the second one to @@ -2190,7 +2136,7 @@ The following command manually adds an offset to the object. We move it a little to the left, and 1.8 staff space downwards. @example \property Voice.Fingering \set #'extra-offset = #'(-0.3 . -1.8) -@end example +@end example The @code{extra-offset} is a low-level feature: it moves around objects in the printout; the formatting engine is completely oblivious to these offsets. The unit of these offsets are staff-spaces. The @@ -2270,7 +2216,7 @@ Between the object and its support (in this case the notes in the voice going down), there should be more space. This space is controlled by @code{padding}, so we increase it. @example - \property Voice.DynamicLineSpanner \override #'padding = #5.0 +\property Voice.DynamicLineSpanner \override #'padding = #5.0 @end example This command is almost like the command for setting slur attachments, @@ -2293,8 +2239,8 @@ different voice, and blank the stem. This is done in the following snippet of code. @example - \property Voice.Stem \set #'transparent = ##t - d' +\property Voice.Stem \set #'transparent = ##t +d' @end example Blanking the stem should be done for only one object. One of the ways to achieve that, is by setting the property before a note. Reverting @@ -2452,7 +2398,7 @@ conductor's score. > \context StaffGroup = brass < \context Staff = trombe < - \property Staff.midiInstrument = #"trumpet" + \property Staff.midiInstrument = #"trumpet" \property Staff.instrument = #`(lines "2 Trombe" "(C)") \property Staff.instr = #`(lines "Tbe." "(C)") \Key @@ -2474,7 +2420,7 @@ conductor's score. > \paper @{ indent = 15 * \staffspace - linewidth = 60 * \staffspace + linewidth = 55 * \staffspace textheight = 90 * \staffspace \translator@{ \HaraKiriStaffContext @@ -2645,8 +2591,8 @@ when they're different. @separate @example - \property Staff.instrument = #`(lines "Corno" - (columns "(E" ,text-flat ")")) +\property Staff.instrument = #`(lines "Corno" + (columns "(E" ,text-flat ")")) @end example The french horn (``Corno'') has the most complex scheme markup name, made up of two lines of text. The second line has three elements (columns) -- @@ -2675,7 +2621,7 @@ Since the horn is transposing, it's in a different key. @separate @example indent = 15 * \staffspace - linewidth = 60 * \staffspace + linewidth = 55 * \staffspace @end example We specify a big indent for the first line and a small linewidth for this tutorial. @@ -2876,9 +2822,14 @@ The result looks more or less like this: In a lilypond-book document, you can freely mix music and text. For example: @lilypond - \score { \notes \relative c' { - c2 g'2 \times 2/3 { f8 e d } c'2 g4 - } } +\score { + \notes \relative c' { + c2 g'2 \times 2/3 { f8 e d } c'2 g4 + } + \paper { + linewidth = -1 + } +} @end lilypond Notice that the music line length matches the margin settings of the document. @@ -2909,7 +2860,7 @@ the default music size, @code{fragment} adds a score block, If you include large examples into the text, it may be more convenient to put the example in a separate file: -@lilypondfile[printfilename]{sammartini.ly} +@lilypondfile[printfilename,noquote]{sammartini.ly} The @code{printfilename} option adds the file name to the output. @node End of tutorial diff --git a/scm/tex.scm b/scm/tex.scm index 399dafd51a..106720b36b 100644 --- a/scm/tex.scm +++ b/scm/tex.scm @@ -142,7 +142,19 @@ (begin ; uncomment for some stats about lily memory ; (display (gc-stats)) - (string-append "%\n\\endgroup\\EndLilyPondOutput\n" + (string-append + "%\n" + "\\EndLilyPondOutput\n" + "\\begingroup\n" + "\\ifx\\LilyPondDocument\\undefined\n" + " \\def\\x{\\endgroup}%\n" + "\\else\n" + " \\def\\x{%\n" + " \\endgroup\n" + " \\enddocument\n" + " }\n" + "\\fi\n" + "\\x\n" ; Put GC stats here. ))) @@ -178,10 +190,30 @@ (ly-gulp-file "music-drawing-routines.ps") 'pre " %\n" 'post) (ly-gulp-file "music-drawing-routines.ps")) ; (if (defined? 'ps-testing) "/testing true def%\n" "") - "}" + "}%\n" + "\\begingroup\n" + "\\catcode `\\@=11\n" + "\\expandafter\\ifx\\csname @nodocument\\endcsname \\relax\n" + " \\def\\x{\\endgroup}%\n" + "\\else\n" + " \\def\\x{%\n" + " \\endgroup\n" + " \\def\\LilyPondDocument{}\n" + " \\documentclass{article}\n" + ; argh, we can't say \begin{document} because \begin is defined as + ; \outer in texinfo + " \\begingroup\n" + " \\document\n" + " \\ifdim\\lilypondpaperlinewidth\\lilypondpaperunit > 0pt\n" + " \\hsize\\lilypondpaperlinewidth\\lilypondpaperunit\n" + " \\fi\n" + " \\parindent 0pt\n" + " }\n" + "\\fi\n" + "\\x\n" "\\input lilyponddefs\n" "\\outputscale=\\lilypondpaperoutputscale \\lilypondpaperunit\n" - "\\turnOnPostScript\\begingroup\\parindent0pt\n")) + "\\turnOnPostScript\n")) ;; Note: this string must match the string in ly2dvi.py!!! (define (header creator generate) diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 21040be146..58be944513 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -173,7 +173,7 @@ class LatexPaper: self.m_document_preamble = [] self.m_num_cols = 1 self.m_multicols = 1 - + def find_latex_dims(self): if g_outdir: fname = os.path.join(g_outdir, "lily-tmp.tex") @@ -216,13 +216,13 @@ class LatexPaper: if countdown == 0: break - + if countdown > 0: countdown = countdown -1 sys.stderr.write (" ... (further messages elided)...\n") sys.exit (1) - + lns = open ('lily-tmp.log').readlines() for ln in lns: ln = string.strip(ln) @@ -230,7 +230,7 @@ class LatexPaper: if m: if m.groups()[0] in ('textwidth', 'columnsep'): self.__dict__['m_%s' % m.groups()[0]] = float(m.groups()[1]) - + try: os.remove (fname) os.remove (os.path.splitext(fname)[0]+".aux") @@ -240,7 +240,7 @@ class LatexPaper: if not self.__dict__.has_key ('m_textwidth'): raise 'foo!' - + def get_linewidth(self): if self.m_num_cols == 1: w = self.m_textwidth @@ -296,9 +296,9 @@ def conv_dimen_to_float(value): unit = m.group (2) num = string.atof(m.group (1)) conv = dimension_conversion_dict[m.group(2)] - + value = conv(num) - + elif re.match ("^[0-9.]+$",value): value = float(value) @@ -331,7 +331,7 @@ option_definitions = [ ('PREF', '', 'dep-prefix', 'prepend PREF before each -M dependency'), ('', 'n', 'no-lily', 'don\'t run lilypond'), ('', '', 'no-pictures', "don\'t generate pictures"), - ('', '', 'no-music', "strip all lilypond blocks from output"), + ('', '', 'no-music', "strip all lilypond blocks from output"), ('', '', 'read-lys', "don't write ly files."), ('FILE', 'o', 'outname', 'filename main output file'), ('FILE', '', 'outdir', "where to place generated files"), @@ -341,14 +341,17 @@ option_definitions = [ # format specific strings, ie. regex-es for input, and % strings for output output_dict= { + + 'html' : { + 'output-lilypond': ''' %s ''', 'output-filename' : r''' )\s", - 'singleline-comment': no_match, - 'numcols': no_match, - 'multicols': no_match, - }, - - 'latex': {'input': r'(?m)^[^%\n]*?(?P\\mbinput{?([^}\t \n}]*))', - 'include': r'(?m)^[^%\n]*?(?P\\mbinclude{(?P[^}]+)})', - 'option-sep' : ',\s*', - 'header': r"\n*\\documentclass\s*(\[.*?\])?", - 'preamble-end': r'(?P\\begin\s*{document})', - 'verbatim': r"(?s)(?P\\begin\s*{verbatim}.*?\\end{verbatim})", - 'verb': r"(?P\\verb(?P.).*?(?P=del))", - 'lilypond-file': r'(?m)^[^%\n]*?(?P\\lilypondfile\s*(\[(?P.*?)\])?\s*\{(?P.+)})', - 'lilypond' : r'(?m)^[^%\n]*?(?P\\lilypond\s*(\[(?P.*?)\])?\s*{(?P.*?)})', - 'lilypond-block': r"(?sm)^[^%\n]*?(?P\\begin\s*(\[(?P.*?)\])?\s*{lilypond}(?P.*?)\\end{lilypond})", - 'def-post-re': r"\\def\\postLilypondExample", - 'def-pre-re': r"\\def\\preLilypondExample", - 'usepackage-graphics': r"\usepackage\s*{graphics}", - 'intertext': r',?\s*intertext=\".*?\"', - 'multiline-comment': no_match, - 'singleline-comment': r"(?m)^.*?(?P(?P^%.*$\n+))", - 'numcols': r"(?P\\(?Pone|two)column)", - 'multicols': r"(?P\\(?Pbegin|end)\s*{multicols}({(?P\d+)?})?)", - }, + 'include': no_match, + 'input': no_match, + 'header': no_match, + 'preamble-end': no_match, + 'landscape': no_match, + 'verbatim': r'''(?s)(?P
\s.*?
\s)''', + 'verb': r'''(?P
.*?
)''', + 'lilypond-file': r'(?m)(?P[^>]+)?>\s*(?P[^<]+)\s*)', + 'lilypond' : '(?m)(?P[^:]*):)(?P.*?)/>)', + 'lilypond-block': r'''(?ms)(?P[^>]+)?>(?P.*?))''', + 'option-sep' : '\s*', + 'intertext': r',?\s*intertext=\".*?\"', + 'multiline-comment': r"(?sm)\s*(?!@c\s+)(?P)\s", + 'singleline-comment': no_match, + 'numcols': no_match, + 'multicols': no_match, + }, + 'latex': { + 'input': r'(?m)^[^%\n]*?(?P\\mbinput{?([^}\t \n}]*))', + 'include': r'(?m)^[^%\n]*?(?P\\mbinclude{(?P[^}]+)})', + 'option-sep' : ',\s*', + 'header': r"\n*\\documentclass\s*(\[.*?\])?", + 'preamble-end': r'(?P\\begin\s*{document})', + 'verbatim': r"(?s)(?P\\begin\s*{verbatim}.*?\\end{verbatim})", + 'verb': r"(?P\\verb(?P.).*?(?P=del))", + 'lilypond-file': r'(?m)^[^%\n]*?(?P\\lilypondfile\s*(\[(?P.*?)\])?\s*\{(?P.+)})', + 'lilypond' : r'(?m)^[^%\n]*?(?P\\lilypond\s*(\[(?P.*?)\])?\s*{(?P.*?)})', + 'lilypond-block': r"(?sm)^[^%\n]*?(?P\\begin\s*(\[(?P.*?)\])?\s*{lilypond}(?P.*?)\\end{lilypond})", + 'def-post-re': r"\\def\\postLilypondExample", + 'def-pre-re': r"\\def\\preLilypondExample", + 'usepackage-graphics': r"\usepackage\s*{graphics}", + 'intertext': r',?\s*intertext=\".*?\"', + 'multiline-comment': no_match, + 'singleline-comment': r"(?m)^.*?(?P(?P^%.*$\n+))", + 'numcols': r"(?P\\(?Pone|two)column)", + 'multicols': r"(?P\\(?Pbegin|end)\s*{multicols}({(?P\d+)?})?)", + }, # why do we have distinction between @mbinclude and @include? - 'texi': { - 'include': '(?m)^[^%\n]*?(?P@mbinclude[ \n\t]+(?P[^\t \n]*))', - 'input': no_match, - 'header': no_match, - 'preamble-end': no_match, - 'landscape': no_match, - 'verbatim': r'''(?s)(?P@example\s.*?@end example\s)''', - 'verb': r'''(?P@code{.*?})''', - 'lilypond-file': '(?m)^(?P@lilypondfile(\[(?P[^]]*)\])?{(?P[^}]+)})', - 'lilypond' : '(?m)^(?P@lilypond(\[(?P[^]]*)\])?{(?P.*?)})', - 'lilypond-block': r'''(?ms)^(?P@lilypond(\[(?P[^]]*)\])?\s(?P.*?)@end +lilypond)\s''', - 'option-sep' : ',\s*', - 'intertext': r',?\s*intertext=\".*?\"', - 'multiline-comment': r"(?sm)^\s*(?!@c\s+)(?P@ignore\s.*?@end ignore)\s", - 'singleline-comment': r"(?m)^.*?(?P(?P@c.*$\n+))", - 'numcols': no_match, - 'multicols': no_match, - } + 'include': '(?m)^[^%\n]*?(?P@mbinclude[ \n\t]+(?P[^\t \n]*))', + 'input': no_match, + 'header': no_match, + 'preamble-end': no_match, + 'landscape': no_match, + 'verbatim': r'''(?s)(?P@example\s.*?@end example\s)''', + 'verb': r'''(?P@code{.*?})''', + 'lilypond-file': '(?m)^(?P@lilypondfile(\[(?P[^]]*)\])?{(?P[^}]+)})', + 'lilypond' : '(?m)^(?P@lilypond(\[(?P[^]]*)\])?{(?P.*?)})', + 'lilypond-block': r'''(?ms)^(?P@lilypond(\[(?P[^]]*)\])?\s(?P.*?)@end +lilypond)\s''', + 'option-sep' : ',\s*', + 'intertext': r',?\s*intertext=\".*?\"', + 'multiline-comment': r"(?sm)^\s*(?!@c\s+)(?P@ignore\s.*?@end ignore)\s", + 'singleline-comment': r"(?m)^.*?(?P(?P@c.*$\n+))", + 'numcols': no_match, + 'multicols': no_match, + } } @@ -566,7 +589,7 @@ for r in re_dict.keys (): raise "Invalid re" re_dict[r] = newdict - + def uniq (list): list.sort () s = list @@ -575,7 +598,7 @@ def uniq (list): if x not in list: list.append (x) return list - + def get_output (name): return output_dict[format][name] @@ -593,7 +616,7 @@ def bounding_box_dimensions(fname): str = fd.read () s = re.search('%%BoundingBox: ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)', str) if s: - + gs = map (lambda x: string.atoi (x), s.groups ()) return (int (gs[2] - gs[0] + 0.5), int (gs[3] - gs[1] + 0.5)) @@ -624,7 +647,7 @@ def compose_full_body (body, opts): 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)) @@ -641,9 +664,10 @@ def compose_full_body (body, opts): if is_fragment and not 'multiline' in opts: opts.append('singleline') - + if 'singleline' in opts: - linewidth = 'linewidth = -1.0' + if not linewidth: + linewidth = 'linewidth = -1.0' if not indent: indent = 'indent = 0.0\mm' elif not linewidth: @@ -678,7 +702,7 @@ def compose_full_body (body, opts): pitch = pitch + '\'' * v body = '\\relative %s { %s }' %(pitch, body) - + if is_fragment: body = r''' \score { @@ -730,7 +754,7 @@ def scan_latex_preamble(chunks): break - # Then we add everythin before \begin{document} to + # Then we add everything before \begin{document} to # paperguru.m_document_preamble so that we can later write this header # to a temporary file in find_latex_dims() to find textwidth. while idx < len(chunks) and chunks[idx][0] != 'preamble-end': @@ -742,7 +766,7 @@ def scan_latex_preamble(chunks): if len(chunks) == idx: error ("Didn't find end of preamble (\\begin{document})") - + paperguru.find_latex_dims() def scan_texi_preamble (chunks): @@ -762,7 +786,7 @@ def scan_preamble (chunks): scan_latex_preamble (chunks) elif __main__.format == 'texi': scan_texi_preamble (chunks) - + def completize_preamble (chunks): if __main__.format != 'latex': @@ -779,7 +803,7 @@ def completize_preamble (chunks): m = get_re('def-post-re').search(chunk[1]) if m: post_b = 1 - + if chunk[0] == 'input': m = get_re('usepackage-graphics').search(chunk[1]) if m: @@ -790,7 +814,7 @@ def completize_preamble (chunks): if x == len(chunks): return chunks - + if not pre_b: chunks.insert(x, ('input', get_output ('output-default-pre'))) if not post_b: @@ -859,9 +883,9 @@ def make_lilypond_file(m): Find @lilypondfile{bla.ly} occurences and substitute bla.ly into a @lilypond .. @end lilypond block. - + ''' - + if m.group('options'): options = m.group('options') else: @@ -875,11 +899,11 @@ def make_lilypond_file(m): def make_lilypond_block(m): if not g_do_music: return [] - + if m.group('options'): options = get_re('option-sep').split (m.group('options')) else: - options = [] + options = [] options = filter(lambda s: s != '', options) return [('lilypond', m.group('code'), options)] @@ -925,14 +949,14 @@ def chop_chunks(chunks, re_name, func, use_match=0): def determine_format (str): if __main__.format == '': - + html = re.search ('(?i)<[dh]tml', str[:200]) latex = re.search (r'''\\document''', str[:200]) texi = re.search ('@node|@setfilename', str[:200]) f = '' g = None - + if html and not latex and not texi: f = 'html' elif latex and not html and not texi: @@ -950,7 +974,7 @@ def determine_format (str): g = LatexPaper () elif __main__.format == 'texi': g = TexiPaper () - + __main__.paperguru = g @@ -959,15 +983,14 @@ def read_doc_file (filename): ''' (str, path) = find_file(filename) determine_format (str) - + chunks = [('input', str)] - + # we have to check for verbatim before doing include, # because we don't want to include files that are mentioned # inside a verbatim environment chunks = chop_chunks(chunks, 'verbatim', make_verbatim) - chunks = chop_chunks(chunks, 'verb', make_verb) chunks = chop_chunks(chunks, 'multiline-comment', do_ignore) #ugh fix input @@ -986,7 +1009,6 @@ def schedule_lilypond_block (chunk): Return: a chunk (TYPE_STR, MAIN_STR, OPTIONS, TODO, BASE) TODO has format [basename, extension, extension, ... ] - ''' (type, body, opts) = chunk assert type == 'lilypond' @@ -1037,7 +1059,7 @@ def schedule_lilypond_block (chunk): if m: newbody = newbody + get_output ("output-filename") % (m.group(1), basename + '.ly', m.group(1)) break - + if 'smallverbatim' in opts: newbody = newbody + output_verbatim (body, 1) @@ -1047,8 +1069,13 @@ def schedule_lilypond_block (chunk): for o in opts: m = re.search ('intertext="(.*?)"', o) if m: - newbody = newbody + m.group (1) + "\n\n" - + newbody = newbody + "\n" + if format == 'texi': + newbody = newbody + "@noindent\n" + elif format == 'latex': + newbody = newbody + "\\noindent\n" + newbody = newbody + m.group (1) + "\n" + if 'noinline' in opts: s = 'output-noinline' elif format == 'latex': @@ -1056,8 +1083,13 @@ def schedule_lilypond_block (chunk): s = 'output-eps' else: s = 'output-tex' - else: # format == 'html' or format == 'texi': - s = 'output-all' + elif format == 'texi': + if 'noquote' in opts: + s = 'output-texi-noquote' + else: + s = 'output-texi-quoted' + else: # format == 'html' + s = 'output-html' newbody = newbody + get_output (s) % {'fn': basename } return ('lilypond', newbody, opts, todo, basename) @@ -1100,7 +1132,7 @@ def get_bbox (filename): gr = [] if m: gr = map (string.atoi, m.groups ()) - + return gr def make_pixmap (name): @@ -1109,14 +1141,14 @@ def make_pixmap (name): fo = open (name + '.trans.eps' , 'w') fo.write ('%d %d translate\n' % (-bbox[0]+margin, -bbox[1]+margin)) fo.close () - + res = 90 x = (2* margin + bbox[2] - bbox[0]) * res / 72. y = (2* margin + bbox[3] - bbox[1]) * res / 72. cmd = r'''gs -g%dx%d -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -r%d -dNOPAUSE %s %s -c quit ''' - + cmd = cmd % (x, y, name + '.png', res, name + '.trans.eps', name + '.eps') status = 0 try: @@ -1185,15 +1217,15 @@ def compile_all_files (chunks): f.close () for e in eps: - cmd = r"echo $TEXMF; tex '\nonstopmode \input %s'" % e - quiet_system (cmd, 'TeX') - + cmd = r"echo $TEXMF; latex '\nonstopmode \input %s'" % e + quiet_system (cmd, 'LaTeX') + cmd = r"dvips -E -o %s %s" % (e + '.eps', e) quiet_system (cmd, 'dvips') - + for g in png: make_pixmap (g) - + os.chdir (d) @@ -1213,7 +1245,7 @@ def update_file (body, name): f = open (name , 'w') f.write (body) f.close () - + return not same @@ -1235,14 +1267,14 @@ def getopt_args (opts): def option_help_str (o): "Transform one option description (4-tuple ) into neatly formatted string" - sh = ' ' + sh = ' ' if o[1]: sh = '-%s' % o[1] sep = ' ' if o[1] and o[2]: sep = ',' - + long = '' if o[2]: long= '--%s' % o[2] @@ -1365,17 +1397,17 @@ def fix_epswidth (chunks): dims = bounding_box_dimensions (filename) return '%fpt' % (dims[0] *lmag) - + body = re.sub (r'''\\lilypondepswidth{(.*?)}''', replace_eps_dim, c[1]) newchunks.append(('lilypond', body, c[2], c[3], c[4])) - + return newchunks ##docme: why global? foutn="" -def do_file(input_filename): +def do_file(input_filename): chunks = read_doc_file(input_filename) chunks = chop_chunks(chunks, 'lilypond', make_lilypond, 1) chunks = chop_chunks(chunks, 'lilypond-file', make_lilypond_file, 1) @@ -1401,7 +1433,6 @@ def do_file(input_filename): x = 0 chunks = completize_preamble (chunks) - global foutn if outname: @@ -1410,8 +1441,8 @@ def do_file(input_filename): my_outname = '-' else: my_outname = os.path.basename (os.path.splitext(input_filename)[0]) + '.' + format - my_depname = my_outname + '.dep' - + my_depname = my_outname + '.dep' + if my_outname == '-' or my_outname == '/dev/stdout': fout = sys.stdout foutn = "" @@ -1437,7 +1468,7 @@ except getopt.error, msg: sys.exit(1) do_deps = 0 -for opt in options: +for opt in options: o = opt[0] a = opt[1] @@ -1494,7 +1525,7 @@ if g_outdir: setup_environment () for input_filename in files: do_file(input_filename) - + # # Petr, ik zou willen dat ik iets zinvoller deed, # maar wat ik kan ik doen, het verandert toch niets?