From: Tom Cato Amundsen Date: Mon, 14 Dec 1998 23:10:45 +0000 (+0100) Subject: patch::: 1.1.15.tca1 X-Git-Tag: release/1.1.16~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1596509cfc25d7c0e9a275b0df074a7f5c14aba5;p=lilypond.git patch::: 1.1.15.tca1 pl15.tca1 - fixed verbatim option behaviour for mudela-book. - added mudela-book option intertext="some text" - mudela-book now understand latex \begin{verbatim} --- Generated by tomcato@xoommail.com using package-diff 0.62, From = lilypond-1.1.15, To = lilypond-1.1.15.tca1 usage cd lilypond-source-dir; patch -E -p1 < lilypond-1.1.15.tca1.diff Patches do not contain automatically generated files or (urg) empty directories, i.e., you should rerun autoconf, configure and possibly make outdirs. --state 1.1.15 1.1.15.tca1 ++state --- diff --git a/Documentation/tex/mudela-book-doc.doc b/Documentation/tex/mudela-book-doc.doc index cd5591adfd..5282037d0b 100644 --- a/Documentation/tex/mudela-book-doc.doc +++ b/Documentation/tex/mudela-book-doc.doc @@ -1,3 +1,8 @@ +% +% written by Tom Cato Amundsen +% send questions/patches to: +% gnu-music-discuss@gnu.org + \documentclass[a4paper, 12pt]{article} \usepackage{t1enc,isolatin1} @@ -30,22 +35,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 +46,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 +70,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 +91,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 +104,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 +119,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 +191,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 +231,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 +254,10 @@ 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;} } @@ -307,21 +271,21 @@ danish composer Andy Pape. The music is put inside a the right marging if you set floatingfigure width and mudela linewidth to the same value. The code looks like this: -\verb|\begin{floatingfigure}{7cm}| -\begin{mudela}[verbatim] +\begin{verbatim} +\begin{floatingfigure}[r]{7cm} +\begin{mudela} \score{ \notes\relative c'{ \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 + 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;} } \end{mudela} -\verb|\end{floatingfigure}| +\end{floatingfigure} +\end{verbatim} \twocolumn[\large The following is written in two columns just to show what mudela-book can do..\normalsize] @@ -368,22 +332,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} 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/NEWS b/NEWS index 78915caecc..ac974362f4 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,13 @@ -pl 15.jcn1 +--- ../lilypond-1.1.15/NEWS Mon Dec 14 15:30:19 1998 +++ b/NEWS Tue Dec 15 00:10:45 1998 +@@ -1,3 +1,7 @@ +pl15.tca1 + - fixed verbatim option behaviour for mudela-book. + - added mudela-book option intertext="some text" + - mudela-book now understand latex \begin{verbatim} + pl 15 + + pl 14.hwn1pl 15.jcn1 - chord inversion: * enter C/E * display chord names according to boolean property diff --git a/VERSION b/VERSION index 13674bdc40..d556a6114f 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=1 PATCH_LEVEL=15 -MY_PATCH_LEVEL=jcn1 +MY_PATCH_LEVEL=tca1 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. 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)