+2002-09-23 Werner Lemberg <wl@gnu.org>
+
+ * 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 <hanwen@cs.uu.nl>
+
+ * Documentation/topdocs/INSTALL.texi (Top): bugfix for RH RPM
+ instructions.
+
2002-09-25 Jan Nieuwenhuizen <janneke@gnu.org>
* Documentation/user/glossary.tely: Add titling and hyperlinks.
scm/grob-property-description.scm, scripts/convert-ly.py: renamed
Stem properties: flag-style -> stroke-style, style -> flag-style.
+
2002-09-22 Werner Lemberg <wl@gnu.org>
* scripts/lilypond-book.py: Add option `notime' to suppress
@section American Chords
-@quotation
-@lilypond[verbatim]
+@lilypond[verbatim, noquote, noindent, notime]
\include "english.ly"
scheme = \chords {
\context Staff \transpose c'' \scheme
>
\paper {
+ linewidth = 5.7\in
\translator {
\ChordNamesContext
ChordName \override #'word-space = #1
}
}
@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
\context Staff \transpose c'' \scheme
>
\paper {
+ linewidth = 5.7\in
\translator {
\ChordNamesContext
ChordName \override #'word-space = #1
}
}
@end lilypond
-@end quotation
@c [barnumbers look silly, fixme.]
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}
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' {
}
@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
@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
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
@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
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
@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
\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
@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
@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
@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]@{<c' e' g'>@}
@end example
+@noindent
and its music:
@lilypond[11pt]{<c' e' g'>}
-@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
@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]@{<c' e' g'>@}
@end example
+@noindent
and its music:
@lilypond[11pt]{<c' e' g'>}
-
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.
@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
<lilypond relative1 verbatim>
\key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
-</lilypond>
+</lilypond>
@end example
-@end quotation
+@noindent
produces
-@quotation
@example
<lilypond relative1 verbatim>
\key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
-</lilypond>
+</lilypond>
@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 <lilypond a b c/> 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.
@iftex
@macro texiflat {word}
@tex
-$\\flat$
+$\\flat$%
@end tex
@end macro
@end iftex
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
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
\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]
}
>
\paper {
- linewidth = 5.875\in
- indent = 0.0
+ linewidth = 5.1\in
+ indent = 0.0\mm
}
}
@end lilypond
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 }
\context Lyrics \nam
>
\paper {
+ linewidth = 100.0\mm
\translator {
\StaffContext
\remove Bar_engraver
}
}
@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
\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'
@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
#(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
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
* 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.
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
@end example
@c a clef here may lead to confusion
-@lilypond[fragment]
+@lilypond
\property Staff.Clef \set #'transparent = ##t
\time 3/4
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
\clef tenor
@end example
-@lilypond[fragment]
+@lilypond[notime]
\property Score.timing = ##f
-\property Staff.TimeSignature = \turnOff
\clef violin
s4_" "
\clef bass
\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
c2 e4 g2.
f4 e d c2.
}
- \paper { linewidth = 60 * \staffspace }
+ \paper {
+ linewidth = 55 * \staffspace
+ }
}
@end lilypond
-@end quotation
-@separate
@node Running LilyPond
@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
@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
@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
@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
@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_" "
@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
@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'
@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,
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
@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
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
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,
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
>
\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
>
\paper @{
indent = 15 * \staffspace
- linewidth = 60 * \staffspace
+ linewidth = 55 * \staffspace
textheight = 90 * \staffspace
\translator@{
\HaraKiriStaffContext
@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) --
@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.
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.
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
(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.
)))
(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)
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")
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)
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")
if not self.__dict__.has_key ('m_textwidth'):
raise 'foo!'
-
+
def get_linewidth(self):
if self.m_num_cols == 1:
w = self.m_textwidth
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)
('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"),
# format specific strings, ie. regex-es for input, and % strings for output
output_dict= {
+
+
'html' : {
+
'output-lilypond': '''<lilypond%s>
%s
</lilypond>''',
'output-filename' : r'''
<!-- %s >
<a href="%s">
-<pre>%s</pre></a>:''',
+<pre>%s</pre></a>:''',
'output-lilypond-fragment': '''<lilypond%s>
\context Staff\context Voice{ %s }
</lilypond>''',
''',
## maybe <hr> ?
'pagebreak': None,
+ # Verbatim text is always finished with \n. FIXME: For HTML,
+ # this newline should be removed.
'output-verbatim': r'''<pre>
-%s
-</pre>''',
+%s</pre>''',
+ # Verbatim text is always finished with \n. FIXME: For HTML,
+ # this newline should be removed.
'output-small-verbatim': r'''<font size=-1><pre>
-%s
-</pre></font>''',
-
+%s</pre></font>''',
## Ugh we need to differentiate on origin:
## lilypond-block origin wants an extra <p>, but
## inline music doesn't.
## possibly other center options?
- 'output-all': r'''
+ 'output-html': r'''
<a href="%(fn)s.png">
<img align="center" valign="center" border="0" src="%(fn)s.png" alt="[picture of music]"></a>
''',
},
+
+
'latex': {
+
'output-lilypond-fragment' : r'''\begin[eps,singleline,%s]{lilypond}
\context Staff <
\context Voice{
}
>
\end{lilypond}''',
- 'output-filename' : r'''
-\verb+%s+:
+ 'output-filename' : r'''\verb+%s+:\\
%% %s
%% %s
''',
%s
\end{lilypond}
''',
- 'output-verbatim': r'''\begin{verbatim}%s\end{verbatim}%%
+ # verbatim text is always finished with \n
+ 'output-verbatim': r'''\begin{verbatim}
+%s\end{verbatim}
+''',
+ # verbatim text is always finished with \n
+ 'output-small-verbatim': r'''{\small\begin{verbatim}
+%s\end{verbatim}}
''',
- 'output-small-verbatim': r'''{\small\begin{verbatim}%s\end{verbatim}}%%''',
'output-default-post': "\\def\postLilypondExample{}\n",
'output-default-pre': "\\def\preLilypondExample{}\n",
'usepackage-graphics': '\\usepackage{graphics}\n',
'output-tex': '{\\preLilypondExample \\input %(fn)s.tex \\postLilypondExample\n}',
'pagebreak': r'\pagebreak',
},
-
+
+
'texi' : {
+
'output-lilypond': '''@lilypond[%s]
%s
@end lilypond
''',
- 'output-filename' : r'''
-@ifnothtml
-@file{%s}:
+ 'output-filename' : r'''@ifnothtml
+@file{%s}:@*
@end ifnothtml
@ifhtml
@uref{%s,@file{%s}}
@end ifhtml
-''',
+''',
'output-lilypond-fragment': '''@lilypond[%s]
\context Staff\context Voice{ %s }
@end lilypond ''',
'output-noinline': r'''
-@c generated: %(fn)s.png
+@c generated: %(fn)s.png
''',
'pagebreak': None,
+ # verbatim text is always finished with \n
'output-small-verbatim': r'''@smallexample
-%s
-@end smallexample
+%s@end smallexample
''',
+ # verbatim text is always finished with \n
'output-verbatim': r'''@example
-%s
-@end example
+%s@end example
''',
-
-# do some tweaking: @ is needed in some ps stuff.
-# override EndLilyPondOutput, since @tex is done
-# in a sandbox, you can't do \input lilyponddefs at the
-# top of the document.
-
-# should also support fragment in
-
-# ugh, the <p> below breaks inline images...
-
- 'output-all': r'''
+ # do some tweaking: @ is needed in some ps stuff.
+ # override EndLilyPondOutput, since @tex is done
+ # in a sandbox, you can't do \input lilyponddefs at the
+ # top of the document.
+ #
+ # ugh, the <p> below breaks inline images...
+ 'output-texi-noquote': r'''@tex
+\catcode`\@=12
+\parindent 0pt
+\input lilyponddefs
+\def\EndLilyPondOutput{}
+\input %(fn)s.tex
+\catcode`\@=0
+@end tex
+@html
+<p>
+<a href="%(fn)s.png">
+<img border=0 src="%(fn)s.png" alt="[picture of music]">
+</a><p>
+@end html
+''',
+ 'output-texi-quoted': r'''@quotation
@tex
\catcode`\@=12
\input lilyponddefs
\input %(fn)s.tex
\catcode`\@=0
@end tex
+@end quotation
@html
<p>
<a href="%(fn)s.png">
@end html
''',
}
-
+
}
def output_verbatim (body, small):
body = re.sub ('>', '>', body)
body = re.sub ('<', '<', body)
elif __main__.format == 'texi':
-
# clumsy workaround for python 2.2 pre bug.
body = re.sub ('@', '@@', body)
body = re.sub ('{', '@{', body)
return get_output (key) % body
-#warning: this uses extended regular expressions. Tread with care.
-
+# Warning: This uses extended regular expressions. Treat with care.
+#
# legenda
-
-# (?P -- name parameter
+#
+# (?P<name>regex) -- assign result of REGEX to NAME
# *? -- match non-greedily.
-# (?m) -- ?
+# (?m) -- multiline regex: make ^ and $ match at each line
+# (?s) -- make the dot match all characters including newline
re_dict = {
'html': {
- 'include': no_match,
- 'input': no_match,
- 'header': no_match,
- 'preamble-end': no_match,
- 'landscape': no_match,
- 'verbatim': r'''(?s)(?P<code><pre>\s.*?</pre>\s)''',
- 'verb': r'''(?P<code><pre>.*?</pre>)''',
- '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>)''',
- 'option-sep' : '\s*',
- 'intertext': r',?\s*intertext=\".*?\"',
- 'multiline-comment': r"(?sm)\s*(?!@c\s+)(?P<code><!--\s.*?!-->)\s",
- 'singleline-comment': no_match,
- 'numcols': no_match,
- 'multicols': no_match,
- },
-
- 'latex': {'input': r'(?m)^[^%\n]*?(?P<match>\\mbinput{?([^}\t \n}]*))',
- 'include': r'(?m)^[^%\n]*?(?P<match>\\mbinclude{(?P<filename>[^}]+)})',
- 'option-sep' : ',\s*',
- 'header': r"\n*\\documentclass\s*(\[.*?\])?",
- 'preamble-end': r'(?P<code>\\begin\s*{document})',
- 'verbatim': r"(?s)(?P<code>\\begin\s*{verbatim}.*?\\end{verbatim})",
- 'verb': r"(?P<code>\\verb(?P<del>.).*?(?P=del))",
- 'lilypond-file': r'(?m)^[^%\n]*?(?P<match>\\lilypondfile\s*(\[(?P<options>.*?)\])?\s*\{(?P<filename>.+)})',
- 'lilypond' : r'(?m)^[^%\n]*?(?P<match>\\lilypond\s*(\[(?P<options>.*?)\])?\s*{(?P<code>.*?)})',
- 'lilypond-block': r"(?sm)^[^%\n]*?(?P<match>\\begin\s*(\[(?P<options>.*?)\])?\s*{lilypond}(?P<code>.*?)\\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<match>(?P<code>^%.*$\n+))",
- 'numcols': r"(?P<code>\\(?P<num>one|two)column)",
- 'multicols': r"(?P<code>\\(?P<be>begin|end)\s*{multicols}({(?P<num>\d+)?})?)",
- },
+ 'include': no_match,
+ 'input': no_match,
+ 'header': no_match,
+ 'preamble-end': no_match,
+ 'landscape': no_match,
+ 'verbatim': r'''(?s)(?P<code><pre>\s.*?</pre>\s)''',
+ 'verb': r'''(?P<code><pre>.*?</pre>)''',
+ '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>)''',
+ 'option-sep' : '\s*',
+ 'intertext': r',?\s*intertext=\".*?\"',
+ 'multiline-comment': r"(?sm)\s*(?!@c\s+)(?P<code><!--\s.*?!-->)\s",
+ 'singleline-comment': no_match,
+ 'numcols': no_match,
+ 'multicols': no_match,
+ },
+ 'latex': {
+ 'input': r'(?m)^[^%\n]*?(?P<match>\\mbinput{?([^}\t \n}]*))',
+ 'include': r'(?m)^[^%\n]*?(?P<match>\\mbinclude{(?P<filename>[^}]+)})',
+ 'option-sep' : ',\s*',
+ 'header': r"\n*\\documentclass\s*(\[.*?\])?",
+ 'preamble-end': r'(?P<code>\\begin\s*{document})',
+ 'verbatim': r"(?s)(?P<code>\\begin\s*{verbatim}.*?\\end{verbatim})",
+ 'verb': r"(?P<code>\\verb(?P<del>.).*?(?P=del))",
+ 'lilypond-file': r'(?m)^[^%\n]*?(?P<match>\\lilypondfile\s*(\[(?P<options>.*?)\])?\s*\{(?P<filename>.+)})',
+ 'lilypond' : r'(?m)^[^%\n]*?(?P<match>\\lilypond\s*(\[(?P<options>.*?)\])?\s*{(?P<code>.*?)})',
+ 'lilypond-block': r"(?sm)^[^%\n]*?(?P<match>\\begin\s*(\[(?P<options>.*?)\])?\s*{lilypond}(?P<code>.*?)\\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<match>(?P<code>^%.*$\n+))",
+ 'numcols': r"(?P<code>\\(?P<num>one|two)column)",
+ 'multicols': r"(?P<code>\\(?P<be>begin|end)\s*{multicols}({(?P<num>\d+)?})?)",
+ },
# why do we have distinction between @mbinclude and @include?
-
'texi': {
- 'include': '(?m)^[^%\n]*?(?P<match>@mbinclude[ \n\t]+(?P<filename>[^\t \n]*))',
- 'input': no_match,
- 'header': no_match,
- 'preamble-end': no_match,
- 'landscape': no_match,
- 'verbatim': r'''(?s)(?P<code>@example\s.*?@end example\s)''',
- 'verb': r'''(?P<code>@code{.*?})''',
- 'lilypond-file': '(?m)^(?P<match>@lilypondfile(\[(?P<options>[^]]*)\])?{(?P<filename>[^}]+)})',
- 'lilypond' : '(?m)^(?P<match>@lilypond(\[(?P<options>[^]]*)\])?{(?P<code>.*?)})',
- 'lilypond-block': r'''(?ms)^(?P<match>@lilypond(\[(?P<options>[^]]*)\])?\s(?P<code>.*?)@end +lilypond)\s''',
- 'option-sep' : ',\s*',
- 'intertext': r',?\s*intertext=\".*?\"',
- 'multiline-comment': r"(?sm)^\s*(?!@c\s+)(?P<code>@ignore\s.*?@end ignore)\s",
- 'singleline-comment': r"(?m)^.*?(?P<match>(?P<code>@c.*$\n+))",
- 'numcols': no_match,
- 'multicols': no_match,
- }
+ 'include': '(?m)^[^%\n]*?(?P<match>@mbinclude[ \n\t]+(?P<filename>[^\t \n]*))',
+ 'input': no_match,
+ 'header': no_match,
+ 'preamble-end': no_match,
+ 'landscape': no_match,
+ 'verbatim': r'''(?s)(?P<code>@example\s.*?@end example\s)''',
+ 'verb': r'''(?P<code>@code{.*?})''',
+ 'lilypond-file': '(?m)^(?P<match>@lilypondfile(\[(?P<options>[^]]*)\])?{(?P<filename>[^}]+)})',
+ 'lilypond' : '(?m)^(?P<match>@lilypond(\[(?P<options>[^]]*)\])?{(?P<code>.*?)})',
+ 'lilypond-block': r'''(?ms)^(?P<match>@lilypond(\[(?P<options>[^]]*)\])?\s(?P<code>.*?)@end +lilypond)\s''',
+ 'option-sep' : ',\s*',
+ 'intertext': r',?\s*intertext=\".*?\"',
+ 'multiline-comment': r"(?sm)^\s*(?!@c\s+)(?P<code>@ignore\s.*?@end ignore)\s",
+ 'singleline-comment': r"(?m)^.*?(?P<match>(?P<code>@c.*$\n+))",
+ 'numcols': no_match,
+ 'multicols': no_match,
+ }
}
raise "Invalid re"
re_dict[r] = newdict
-
+
def uniq (list):
list.sort ()
s = list
if x not in list:
list.append (x)
return list
-
+
def get_output (name):
return output_dict[format][name]
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))
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))
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:
pitch = pitch + '\'' * v
body = '\\relative %s { %s }' %(pitch, body)
-
+
if is_fragment:
body = r'''
\score {
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':
if len(chunks) == idx:
error ("Didn't find end of preamble (\\begin{document})")
-
+
paperguru.find_latex_dims()
def scan_texi_preamble (chunks):
scan_latex_preamble (chunks)
elif __main__.format == 'texi':
scan_texi_preamble (chunks)
-
+
def completize_preamble (chunks):
if __main__.format != 'latex':
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:
if x == len(chunks):
return chunks
-
+
if not pre_b:
chunks.insert(x, ('input', get_output ('output-default-pre')))
if not post_b:
Find @lilypondfile{bla.ly} occurences and substitute bla.ly
into a @lilypond .. @end lilypond block.
-
+
'''
-
+
if m.group('options'):
options = m.group('options')
else:
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)]
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:
g = LatexPaper ()
elif __main__.format == 'texi':
g = TexiPaper ()
-
+
__main__.paperguru = g
'''
(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
Return: a chunk (TYPE_STR, MAIN_STR, OPTIONS, TODO, BASE)
TODO has format [basename, extension, extension, ... ]
-
'''
(type, body, opts) = chunk
assert type == 'lilypond'
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)
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':
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)
gr = []
if m:
gr = map (string.atoi, m.groups ())
-
+
return gr
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:
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)
f = open (name , 'w')
f.write (body)
f.close ()
-
+
return not same
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]
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)
x = 0
chunks = completize_preamble (chunks)
-
global foutn
if outname:
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 = "<stdout>"
sys.exit(1)
do_deps = 0
-for opt in options:
+for opt in options:
o = opt[0]
a = opt[1]
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?