]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.3.95.tca1
authorTom Cato Amundsen <tca@gnu.org>
Thu, 12 Oct 2000 23:24:21 +0000 (01:24 +0200)
committerTom Cato Amundsen <tca@gnu.org>
Thu, 12 Oct 2000 23:24:21 +0000 (01:24 +0200)
Documentation/user/latex-mudela-example.latex
VERSION
scripts/mudela-book.py

index 5b6c08e80e5166f7281ed10c40621349c748fe27..817a0f00e1fc3ce7c51e10e2bfc14cde3807a5be 100644 (file)
@@ -1,6 +1,8 @@
+% kommentar
 \documentclass[a4paper, 12pt]{article}
-%\def\pre MudelaExample{This if before}
-%\def\pre MudelaExample{This is after}
+%\def\preMudelaExample{}
+%\def\postMudelaExample{}
+%\usepackage{graphics}
 %\usepackage{landscape}
 \begin{document}
 %uncomment this to try twocolumn mode
diff --git a/VERSION b/VERSION
index 9df76a8503710777b41c68216503304da8b70aa8..d7e04679295a19c2360f85f57890114d3cd9c46e 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=3
 PATCH_LEVEL=95
-MY_PATCH_LEVEL=jcn4
+MY_PATCH_LEVEL=tca1
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
index ec3366a9d225897f3f14e82ff3d9661f10ccc3c6..587a514b06b5728fbeb8e3a19e2bcd52eeac5628 100644 (file)
@@ -326,8 +326,9 @@ output_dict= {
 %s
 \end{mudela}""",
                'output-verbatim': "\\begin{verbatim}%s\\end{verbatim}",
-               'output-default-post': r"""\def\postMudelaExample{}""",
-               'output-default-pre': r"""\def\preMudelaExample{}""",
+               'output-default-post': "\\def\postMudelaExample{}\n",
+               'output-default-pre': "\\def\preMudelaExample{}\n",
+               'usepackage-graphics': '\\usepackage{graphics}\n',
                'output-eps': '\\noindent\\parbox{\\mudelaepswidth{%(fn)s.eps}}{\includegraphics{%(fn)s.eps}}',
                'output-tex': '\\preMudelaExample \\input %(fn)s.tex \\postMudelaExample\n',
                'pagebreak': r'\pagebreak',
@@ -391,9 +392,10 @@ re_dict = {
                  'mudela-block': r"(?sm)^[^%\n]*?(?P<match>\\begin(\[(?P<options>.*?)\])?{mudela}(?P<code>.*?)\\end{mudela})",
                  'def-post-re': r"\\def\\postMudelaExample",
                  'def-pre-re': r"\\def\\preMudelaExample",               
+                 'usepackage-graphics': r"\usepackage{graphics}",
                  'intertext': r',?\s*intertext=\".*?\"',
                  'multiline-comment': no_match,
-                 'singleline-comment': r"(?m)(?P<code>^%.*$\n+)",
+                 'singleline-comment': r"(?m)^.*?(?P<match>(?P<code>^%.*$\n+))",
                  'numcols': r"(?P<code>\\(?P<num>one|two)column)",
                  },
        
@@ -587,25 +589,35 @@ def scan_preamble (chunks):
                scan_latex_preamble(chunks)
                
 
-def completize_preamble (str):
-       m = get_re ('preamble-end').search( str)
-       if not m:
-               return str
-       
-       preamble = str [:m.start (0)]
-       str = str [m.start(0):]
-       
-       if not get_re('def-post-re').search (preamble):
-               preamble = preamble + get_output('output-default-post')
-       if not get_re ('def-pre-re').search(  preamble):
-               preamble = preamble + get_output ('output-default-pre')
-
-       # UGH ! BUG!
-       #if  re.search ('\\\\includegraphics', str) and not re.search ('usepackage{graphics}',str):
-
-       preamble = preamble + '\\usepackage{graphics}\n'
-
-       return preamble + str
+def completize_preamble (chunks):
+       if __main__.format == 'texi':
+               return chunks
+       pre_b = post_b = graphics_b = None
+       for chunk in chunks:
+               if chunk[0] == 'preamble-end':
+                       break
+               if chunk[0] == 'input':
+                       m = get_re('def-pre-re').search(chunk[1])
+                       if m:
+                               pre_b = 1
+               if chunk[0] == 'input':
+                       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:
+                               graphics_b = 1
+       x = 0
+       while chunks[x][0] != 'preamble-end':
+               x = x + 1
+       if not pre_b:
+               chunks.insert(x, ('input', get_output ('output-default-pre')))
+       if not post_b:
+               chunks.insert(x, ('input', get_output ('output-default-post')))
+       if not graphics_b:
+               chunks.insert(x, ('input', get_output ('usepackage-graphics')))
+       return chunks
 
 
 read_files = []
@@ -1022,10 +1034,8 @@ def do_file(input_filename):
                        else:
                                newchunks.append (c)
                chunks = newchunks
-
-       if chunks and chunks[0][0] == 'input':
-               chunks[0] = ('input', completize_preamble (chunks[0][1]))
-
+       x = 0
+       chunks = completize_preamble (chunks)
        foutn = os.path.join(g_outdir, my_outname + '.' + format)
        sys.stderr.write ("Writing `%s'\n" % foutn)
        fout = open (foutn, 'w')