]> git.donarmstrong.com Git - lilypond.git/commitdiff
This commit was manufactured by cvs2svn to create tag 'lilypond_2_1_17'. release/2.1.17
authorjanneke <janneke>
Mon, 2 Feb 2004 17:11:47 +0000 (17:11 +0000)
committerjanneke <janneke>
Mon, 2 Feb 2004 17:11:47 +0000 (17:11 +0000)
input/bugs/rhytmicstaff-tie.ly [deleted file]
scripts/filter-lilypond-book.py
scripts/lilypond.py

diff --git a/input/bugs/rhytmicstaff-tie.ly b/input/bugs/rhytmicstaff-tie.ly
deleted file mode 100644 (file)
index 197e3ac..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-% from José Luis Cruz <joseluis AT jazzartistas.com>
-\version "2.1.0"
-
-\header { 
-  texidoc="@cindex A tie in RhythmicStaff fails to compile."
-}
-
-\score { 
-  \context RhythmicStaff {
-    \notes { 
-        c1 ~ c1
-    }
-  }
-}
index a4eb0e4bab96347440ece7114c615232da538c24..70bf4cba0d9f76c2b5fc6189e95fcc633722e4f8 100644 (file)
@@ -1,28 +1,6 @@
 #!@PYTHON@
 
-'''
-TODO: latex/paper parameters
-      [verbatim]
-      \relative ly:export?
-
-
-Example usage:
-
-test:
-     filter-lilypond-book --filter="tr '[a-z]' '[A-Z]'" BOOK
-         
-convert-ly on book:
-     filter-lilypond-book --filter="convert-ly --no-version --from=1.6.11 -" BOOK
-
-minimal classic lilypond-book (WIP):
-     filter-lilypond-book --process="lilypond-bin" BOOK.tely
-
-     (([0-9][0-9])*pt) -> staffsize=\2
-     
-'''
-
 import string
-import __main__
 
 ################################################################
 # Users of python modules should include this snippet
@@ -69,7 +47,7 @@ help_summary = _ ("""Process ly snippets from lilypond-book source.  Example usa
    filter-lilypond-book --filter="convert-ly --no-version --from=1.6.11 -" BOOK
 
 """)
-copyright = ('Jan Nieuwenhuizen <janneke@gnu.org>>',
+copyright = ('Tom Cato Amundsen <tca@gnu.org>',
             'Han-Wen Nienhuys <hanwen@cs.uu.nl>')
 
 option_definitions = [
@@ -91,21 +69,12 @@ if '@bindir@' == ('@' + 'bindir@') or not os.path.exists (lilypond_binary):
        lilypond_binary = 'lilypond-bin'
 
 
-use_hash_p = 1
 format = 0
 filter_cmd = 'convert-ly --no-version --from=2.0.0 -'
 #filter_cmd = 0
 #process_cmd = 'convert-ly --no-version --from=2.0.0'
 process_cmd = 0
 
-LATEX = 'latex'
-HTML = 'html'
-TEXINFO = 'texinfo'
-BEFORE = 'before'
-AFTER = 'after'
-
-## lilypond-book heritage.  to be cleaned
-
 ################################################################
 # Recognize special sequences in the input 
 
@@ -120,7 +89,7 @@ AFTER = 'after'
 # (?s) -- make the dot match all characters including newline
 no_match = 'a\ba'
 re_dict = {
-       HTML: {
+       'html': {
                'include':  no_match,
                'input': no_match,
                'header': no_match,
@@ -140,7 +109,7 @@ re_dict = {
                'ly2dvi': r'(?m)(?P<match><ly2dvifile(?P<options>[^>]+)?>\s*(?P<filename>[^<]+)\s*</ly2dvifile>)',
                },
 
-       LATEX: {
+       'latex': {
                'input': r'(?m)^[^%\n]*?(?P<match>\\mbinput{?([^}\t \n}]*))',
                'include': r'(?m)^[^%\n]*?(?P<match>\\mbinclude{(?P<filename>[^}]+)})',
                'option-sep' : ',\s*',
@@ -165,7 +134,7 @@ re_dict = {
 
        # why do we have distinction between @mbinclude and @include?
 
-       TEXINFO: {
+       'texinfo': {
                'include':  '(?m)^[^%\n]*?(?P<match>@mbinclude\s+(?P<filename>\S*))',
                'input': no_match,
                'header': no_match,
@@ -186,88 +155,23 @@ re_dict = {
                }
        }
 
-NOTES = 'body'
-PREAMBLE = 'preamble'
-PAPER = 'paper'
-
-ly_options = {
-       NOTES: {
-       'relative': r'''\relative #(ly:make-pitch %(relative)s 0 0)'''
-       },
-       PAPER: {
-       'indent' : r'''
-    indent = %(indent)s''',
-       'linewidth' : r'''
-    linewidth = %(linewidth)s''',
-       'noindent' : r'''
-    indent = 0.0\mm''',
-       'notime' : r'''
-    \translator {
-        \StaffContext
-        \remove Time_signature_engraver
-    }''',
-       'raggedright' : r'''
-    raggedright = ##t''',
-       },
-       PREAMBLE: {
-       'staffsize': r'''
-#(set-global-staff-size %(staffsize)s)''',
-       },
-       }
-
-
-PREAMBLE_LY = r'''%% Generated by %(program_name)s
-%% Options: [%(option_string)s]
-%(preamble_string)s
-\paper {%(paper_string)s
-}
-''' 
-
-FRAGMENT_LY = r'''\score{
-    \notes%(notes_string)s{
-        %(code)s    }
-}'''
-FULL_LY = '%(code)s'
-
-
-def compose_ly (code, option_string):
+def compose_ly (code, options):
        m = re.search (r'''\\score''', code)
-       options = string.split (option_string, ',')
        if not m and (not options \
                      or not 'nofragment' in options \
                      or 'fragment' in options):
-               body = FRAGMENT_LY
+               body = r'''\score{\notes{ %(code)s }}''' % vars ()
        else:
-               body = FULL_LY
-
-       # defaults
-       relative = "0"
-       staffsize = "16"
-
-       notes_options = []
-       paper_options = []
-       preamble_options = []
-       for i in options:
-               if string.find (i, '=') > 0:
-                       key, value = string.split (i, '=')
-                       # hmm
-                       vars ()[key] = value
-               else:
-                       key = i
-
-               if key in ly_options[NOTES].keys ():
-                       notes_options.append (ly_options[NOTES][key] % vars ())
-               elif key in ly_options[PREAMBLE].keys ():
-                       preamble_options.append (ly_options[PREAMBLE][key] \
-                                                % vars ())
-               elif key in ly_options[PAPER].keys ():
-                       paper_options.append (ly_options[PAPER][key] % vars ())
-
-       program_name = __main__.program_name
-       notes_string = string.join (notes_options, '\n    ')
-       paper_string = string.join (paper_options, '\n    ')
-       preamble_string = string.join (preamble_options, '\n    ')
-       return (PREAMBLE_LY + body) % vars ()
+               body = code
+       ### todo: add options
+       return body
+
+
+LATEX = 'latex'
+HTML = 'html'
+TEXINFO = 'texinfo'
+BEFORE = 'before'
+AFTER = 'after'
 
 output = {
        HTML : {
@@ -332,9 +236,7 @@ class Snippet:
                return self.hash
 
        def basename (self, source):
-               if use_hash_p:
-                       return 'lily-%d' % self.get_hash (source)
-               raise 'to be done'
+               return 'lily-%d' % self.get_hash (source)
 
        def write_ly (self, source):
                h = open (self.basename (source) + '.ly', 'w')
@@ -366,10 +268,9 @@ class Snippet:
                base = self.basename (source)
                if os.path.exists (base + '.ly') \
                   and os.path.exists (base + '.tex') \
-                  and (not use_hash_p \
-                       or self.ly (source) == open (base + '.ly').read ()):
+                  and self.ly (source) == open (base + '.ly').read ():
                        # TODO: something smart with target formats
-                       # (ps, png) and m/ctimes
+                       # (ps, png) and m/atimes
                        return None
                return self
 
@@ -463,36 +364,7 @@ def process_snippets (source, snippets, cmd):
                for i in names:
                        to_eps (i)
                        ly.make_ps_images (i + '.eps', resolution=110)
-
-LATEX_DOCUMENT = r'''
-%(preamble)s
-\begin{document}
-\typeout{columnsep=\the\columnsep}
-\typeout{textwidth=\the\textwidth}
-\end{document}
-'''
-#need anything else besides textwidth?
-def get_latex_parameters (source):
-       snippet, = find_snippets (source, 'preamble-end')
-       latex_cmd = 'latex "\\nonstopmode \input /dev/stdin"'
-       preamble = source[:snippet.start (0)]
-       latex_document = LATEX_DOCUMENT % vars ()
-        parameter_string = filter_pipe (latex_document, latex_cmd)
-
-       columnsep = 0
-       m = re.search ('columnsep=([0-9.]*)pt', parameter_string)
-       if m:
-               columnsep = string.atof (m.group (1))
-
-       textwidth = 0
-       m = re.search('textwidth=([0-9.]*)pt', parameter_string)
-       if m:
-               textwidth = string.atof (m.group (1))
-               if columnsep:
-                       textwidth -= columnsep
-
-       return textwidth
-
+               
 
 def do_file (input_filename):
        global format
@@ -560,9 +432,6 @@ def do_file (input_filename):
                        snippet_output (snippet, source)
                index = snippet.end (0)
 
-       if format == LATEX:
-               textwdith = get_latex_parameters (source)
-               #TODO: set global option
 
        global index
        if filter_cmd:
index b2b3373484b2fe01e2c145b16a49b11001d0be35..96dd3b4cd0c241df4e189a8cdb3ac99d9443a9d6 100644 (file)
@@ -482,7 +482,7 @@ lily output file in TFILES after that, and return the Latex file constructed.  '
                first = 0
 
 
-       s = s + '\n\\thispagestyle{lastpage}\n'
+       s = s + '\\thispagestyle{lastpage}\n'
        s = s + '\\end{document}'
 
        return s