From: fred Date: Tue, 26 Mar 2002 21:45:34 +0000 (+0000) Subject: lilypond-1.1.16 X-Git-Tag: release/1.5.59~2666 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=8a2332dcaa37e05868c48fe687cc975e3ce6c9bc;p=lilypond.git lilypond-1.1.16 --- diff --git a/Documentation/tex/mudela-book-doc.doc b/Documentation/tex/mudela-book-doc.doc index cd5591adfd..386417f39d 100644 --- a/Documentation/tex/mudela-book-doc.doc +++ b/Documentation/tex/mudela-book-doc.doc @@ -1,3 +1,4 @@ +% -*-LaTeX-*- \documentclass[a4paper, 12pt]{article} \usepackage{t1enc,isolatin1} @@ -30,22 +31,7 @@ This document assumes you have basic knowledge of GNU LilyPond and send a patch. So what does this look like? Well, here is an example: - -\begin{mudela}[verbatim] -\score{ - \notes\relative c'{ - \time 5/8; - [e16( g b c a g][e a b d] | )e2 d,8 | - [e16( g b c a g][e a b d] | )b2 [a16( f] | - [e a b d] )e4 c8 | [es16( bes a as g es][d c b! )g] | - [f( a b d b a][f a b d] | )e2 - } -} -\end{mudela} - -\noindent produces this music: - -\begin{mudela} +\begin{mudela}[veryverbatim, intertext="produces this music:"] \score{ \notes\relative c'{ \time 5/8; @@ -56,7 +42,6 @@ So what does this look like? Well, here is an example: } } \end{mudela} - If you are lucky, the above example show a nice feature of LilyPond and \LaTeX. Since LilyPond can output the music as \TeX~graphics, \LaTeX~can insert pagebreaks between the lines of music. @@ -81,23 +66,7 @@ music, another file than \verb|paper16.ly| will be included. If you want to make the music not so wide, you can insert a \verb|\paper| statement that set the linewidth: -\begin{mudela}[verbatim] -\score{ - \notes\relative c'{ - \time 5/8; - [e16( g b c a g][e a b d] | )e2 d,8 | - [e16( g b c a g][e a b d] | )b2 [a16( f] | - [e a b d] )e4 c8 | [es16( bes a as g es][d c b! )g] | - [f( a b d b a][f a b d] | )e2 - } - \paper{linewidth = 10.\cm;} -} -\end{mudela} - -\noindent produces this music: - -\begin{mudela} -% dette er en kommentar +\begin{mudela}[veryverbatim, intertext="produces this music:"] \score{ \notes\relative c'{ \time 5/8; @@ -118,12 +87,7 @@ If you only write voice-contents in the mudela block, mudela-book will set the \verb|linewidth| variable to -1, so Lilypond will make the music as short as possible but without breaking the line. Here is a well know harmonic progression: -\begin{mudela} -% dette er en kommentar - -\end{mudela} -\noindent that is made by this code: -\begin{mudela}[verbatim] +\begin{mudela}[veryverbatim, intertext="produce a well known harmonic progression:"] \end{mudela} @@ -136,9 +100,11 @@ eps graphics and include it into the document with the \verb|\includegraphics| command. The code used look like this: -\begin{mudela}[eps, verbatim] +\begin{verbatim} +\begin{mudela}[eps] \end{mudela} +\end{verbatim} You can also use the \verb|eps| option if the block is a complete mudela source. This 5 cm long empty line, @@ -149,24 +115,29 @@ mudela source. This 5 cm long empty line, } \end{mudela} was created with this code: -\begin{mudela}[eps, verbatim] +\begin{verbatim} +\begin{mudela}[eps] \score{ \notes{s} \paper{ linewidth = 5.\cm;} } \end{mudela} +\end{verbatim} + To avoid that \LaTeX~places the music on a line of its one, there should be no empty lines between the normal text and the mudela environment. \section{Fontsize options} You can use all lilypond fontsizes in mudela-book. -% LONG line just to test multiple mudela on one line +% LONG line just to test multiple \mudela on one line The default 16pt fontsize, \mudela{}, is probably to big to be included in the middle of the text. 11pt, \mudela[11pt]{} or 13pt, \mudela[13pt]{} is probably better. The code can look like this: -\begin{mudela}[13pt, eps, verbatim] +\begin{verbatim} +\begin{mudela}[13pt, eps] \end{mudela} +\end{verbatim} The following options set the fontsize: \begin{itemize} @@ -216,39 +187,29 @@ Mudela-book defines the \verb|\mudela| command, and let you define your own commands in a file specified by the command line option \verb|--initfile=filename|. The format for the file is a definition of a python dictionary: -% mudela-book should really respect \begin{verbatim} -\verb|{ 'mudela': r"""| - -\verb|\begin|\verb|{mudela}[eps \fontoptions]| - -\verb| \maininput| - -\verb|\end|\verb|{mudela}| - -\verb|""",| - -\verb| 'mudelaRhythm': r"""| - -\verb|\begin|\verb|{mudela}[eps \fontoptions]| \begin{verbatim} +{ 'mudela': r""" +\begin{mudela}[eps \fontoptions] + \maininput +\end{mudela} +""", + 'mudelaRhythm': r""" +\begin{mudela}[eps \fontoptions] \score{ \type RhythmicStaff{ \notes{\stemup \maininput} } \paper{linewidth = -1.\cm;} } +\end{mudela} +""" +} \end{verbatim} -\verb|\end|\verb|{mudela}| - -\verb|"""| - -\verb|}| - The above code show how \verb|\mudela| could have been defined, and also defines a new command \verb|mudelaRhythm|. Notice that you can send fontsize options to the defined commands. -\verb|\mudelaRhytm[11pt]{c4 c8 [c16 c] c4 c}| produce this music: +\verb|\mudelaRhythm[11pt]{c4 c8 [c16 c] c4 c}| produce this music: \begin{mudela}[eps, 11pt] \score{ \type RhythmicStaff{ @@ -266,7 +227,7 @@ wrong. Since there is no finder's fee which doubles every year, there is no need to wait for the price money to grow. So send a bug report today -if you need this one of this options. +if you need this one of these options. \section{Examples} This was all options to \verb|\begin{mudela}|. The rest of the @@ -289,11 +250,11 @@ and marginspars just as any other included eps graphics. \begin{mudela} \score{ \notes\relative c'{ - \time 12/8; - r4-\fermata [b16-.( )b-.] [f'8-- dis16-.( )dis-. gis8--] - [f16-.( )f-. dis8-- gis16-.( )gis-.] cis4.-\fermata | - - r4.-\fermata [cis,16 cis g'8 f16 f b8][g16 g f8 b16 b] dis4.-\fermata + \time 12/8; + r4-\fermata [b16-.( )b-.] [f'8-- dis16-.( )dis-. gis8--] + [f16-.( )f-. dis8-- gis16-.( )gis-.] cis4.-\fermata | + + r4.-\fermata [cis,16 cis g'8 f16 f b8][g16 g f8 b16 b] dis4.-\fermata } \paper{linewidth = 7.\cm;} } @@ -314,7 +275,7 @@ to the same value. The code looks like this: \time 12/8; r4.-\fermata [b16-.( )b-.] [f'8-- dis16-.( )dis-. gis8--] [f16-.( )f-. dis8-- gis16-.( )gis-.] cis8.-\fermata | - + r4.-\fermata [cis,16 cis g'8 f16 f b8] [g16 g f8 b16 b] dis4.-\fermata } @@ -368,22 +329,14 @@ Sinse the version number is quite low, you should be careful not to mix braces that belongs to mudela-book and \LaTeX~on the same line. The following code will probably break: -\verb|\footnote{\begin{mudela}| - -\verb|\relative c''{ \key es; r8 [g g g] es2} | - -\verb|\end{mudela}}| - +\begin{verbatim} +\footnote{\begin{mudela} +\relative c''{ \key es; r8 [g g g] es2} +\end{mudela}} +\end{verbatim} Mudela-book does know about \verb|\onecolumn| and \verb|\twocolumn|. So the music will be adjusted to the new linewith: -\begin{mudela}[verbatim] -\score{ - \notes\relative c'{c d e f | g2 g | a4 a a a | g1 | - f4 f f f | e2 e | d4 d d d | c1} -} -\end{mudela} -produces -\begin{mudela} +\begin{mudela}[veryverbatim, intertext="produces"] \score{ \notes\relative c'{c d e f | g2 g | a4 a a a | g1 | f4 f f f | e2 e | d4 d d d | c1} @@ -396,3 +349,6 @@ environment when you don't want \LaTeX~to do any linebreaking) \end{document} +\begin{verbatim} + +\end{verbatim} diff --git a/Documentation/topdocs/AUTHORS.yo b/Documentation/topdocs/AUTHORS.yo index ad2ad26ed5..1ab3979a87 100644 --- a/Documentation/topdocs/AUTHORS.yo +++ b/Documentation/topdocs/AUTHORS.yo @@ -5,7 +5,7 @@ list is alphabetically ordered. itemize( it()nemail(Tom Cato Amundsen)(tomcato@xoommail.com), - cembalo-partita in mudela. + cembalo-partita in mudela, accordion symbols, some mudela-book.py it()nemail(Mats Bengtsson)(matsb@s3.kth.se), lurl(http://www.s3.kth.se/~matsb/) clef stuff, key stuff, swedish notenames, testing, general diff --git a/scripts/mudela-book.py b/scripts/mudela-book.py index e79f120c80..e995b890b2 100644 --- a/scripts/mudela-book.py +++ b/scripts/mudela-book.py @@ -1,9 +1,14 @@ #!@PYTHON@ +# +# The bugs you find are made by Tom Cato Amundsen +# Send patches/questions/bugreports to a mailinglist: +# gnu-music-discuss@gnu.org +# bug-gnu-music@gnu.org +# help-gnu-music@gnu.org +# # All non-english comments are NOT in swedish, they are norwegian! # TODO: # * center option (??) -# * mudela-book should treat \begin{verbatim} that contains inline mudela -# correctly. # * make mudela-book understand usepackage{geometry} # * check that linewidth set in \paper is not wider than actual linewidth? # * the following fails because mudelabook doesn't care that the @@ -36,10 +41,18 @@ # - mudela-book will scan the mudela code to find out if it has to add # paper-definition and \score{\notes{...}} # - possible to define commands that look like this: \mudela{ c d e } +# - don't produce .dvi output, it was a silly idea... # 0.5.1: # - removed init/mudela-book-defs.py, \mudela is defined inside mudela-book # - fragment and nonfragment options will override autodetection of type of # in mudela-block (voice contents or complete code) +# 0.5.2: +# - fixed verbatim option behaviour: don't show \begin{mudela} \end{mudela} +# and show both mudela code and music +# - veryverbatim option, same as verbatim but show \begin{mudela} +# and \end{mudela}. (saves keystrokes in mudela-book-doc.doc) +# - intertext="bla bla bla" option +# - mudela-book now understand latex \begin{verbatim} import os import string @@ -49,7 +62,7 @@ import sys outdir = 'out' initfile = '' -program_version = '0.5.1' +program_version = '0.5.2' out_files = [] @@ -58,6 +71,8 @@ fontsize_i2a = {11:'eleven', 13:'thirteen', 16:'sixteen', fontsize_pt2i = {'11pt':11, '13pt':13, '16pt':16, '20pt':20, '26pt':26} begin_mudela_re = re.compile ('^ *\\\\begin{mudela}') +begin_verbatim_re = re.compile ('^ *\\\\begin{verbatim}') +end_verbatim_re = re.compile ('^ *\\\\end{verbatim}') extract_papersize_re = re.compile('\\\\documentclass[\[, ]*(\w*)paper[\w ,]*\]\{\w*\}') extract_fontsize_re = re.compile('[ ,\[]*([0-9]*)pt') begin_mudela_opts_re = re.compile('\[[^\]]*\]') @@ -73,6 +88,7 @@ onecolumn_re = re.compile('\\\\onecolumn') preMudelaExample_re = re.compile('\\\\def\\\\preMudelaExample') postMudelaExample_re = re.compile('\\\\def\\\\postMudelaExample') boundingBox_re = re.compile('%%BoundingBox: ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)') +intertext_re = re.compile("intertext=\"([^\"]*)\"") def file_exist_b(name): try: @@ -255,7 +271,6 @@ class Mudela_output: self.code_type = 'fly' if self.code_type_override: self.code_type = self.code_type_override - print "override:", self.code_type_override self.write_red_tape() for l in self.__lines: self.file.write(l) @@ -287,11 +302,14 @@ class Tex_output: def __init__ (self, name): self.output_fn = '%s/%s' % (outdir, name) self.__lines = [] - def open_verbatim (self, line): + def open_verbatim (self, line, level): self.__lines.append('\\begin{verbatim}\n') - s = re.sub('[\s,]*verbatim[\s]*', '', line) - s = re.sub('\[\]', '', s) - self.__lines.append(s); + if level == 2: + s = re.sub('veryverbatim[\s,]*', '', line) + s = re.sub('intertext=\"([^\"]*)\"[\s,]*', '', s) + s = re.sub(',\s*\]', ']', s) + s = re.sub('\[\]', '', s) + self.__lines.append(s); def close_verbatim (self): self.__lines.append('\\end{verbatim}\n') def write (self, s): @@ -452,6 +470,8 @@ class Main_tex_input(Tex_input): def do_it(self): preMudelaDef = postMudelaDef = 0 (lines, self.deps) = self.get_lines () + #HACK + latex_verbatim = 0 for line in lines: if documentclass_re.search (line): p = self.extract_papersize_from_documentclass (line) @@ -468,12 +488,16 @@ class Main_tex_input(Tex_input): preMudelaDef = 1 elif postMudelaExample_re.search (line): postMudelaDef = 1 + elif begin_verbatim_re.search (line): + latex_verbatim = 1 + elif end_verbatim_re.search (line): + latex_verbatim = 0 elif begin_document_re.search (line): if not preMudelaDef: self.mudtex.write ('\\def\\preMudelaExample{}\n') if not postMudelaDef: self.mudtex.write ('\\def\\postMudelaExample{}\n') - elif begin_mudela_re.search (line): + elif begin_mudela_re.search (line) and not latex_verbatim: Props.clear_for_new_block() if __debug__: if self.mode == 'mudela': @@ -483,33 +507,47 @@ class Main_tex_input(Tex_input): if r: o = r.group()[1:][:-1] optlist = re.compile('[ ,]*').split(o) + m = intertext_re.search(r.group()) + if m: + self.intertext = m.groups()[0] + else: + self.intertext = None else: optlist = [] - if ('verbatim' in optlist) or (Props.force_verbatim_b): + if ('veryverbatim' in optlist): + self.verbatim = 2 + elif ('verbatim' in optlist) or (Props.force_verbatim_b): self.verbatim = 1 - self.mudtex.open_verbatim (line) - continue else: self.verbatim = 0 - self.mudela = Mudela_output (self.gen_basename ()) - elif end_mudela_re.search (line): + if self.verbatim: + self.mudtex.open_verbatim (line, self.verbatim) + self.mudela = Mudela_output (self.gen_basename ()) + self.mudela.write (line) + continue + elif end_mudela_re.search (line) and not latex_verbatim: if __debug__: if self.mode != 'mudela': raise AssertionError - if self.mudela: - self.mudela.close () - self.mudtex.write (self.mudela.insert_me_string()) - del self.mudela - self.mudela = None - self.fine_count = self.fine_count + 1 - else: - self.mudtex.write (line) + + if self.verbatim: + if self.verbatim == 2: + self.mudtex.write (line) self.mudtex.close_verbatim () + self.mudela.close () + if self.verbatim and self.intertext: + self.mudtex.write(self.intertext) + self.mudtex.write (self.mudela.insert_me_string()) + del self.mudela + self.mudela = None + self.fine_count = self.fine_count + 1 self.mode = 'latex' continue - if self.mode == 'mudela' and not self.verbatim: + if self.mode == 'mudela': self.mudela.write (line) + if self.verbatim: + self.mudtex.write (line) else: self.mudtex.write (line) self.set_sections(line)