]> git.donarmstrong.com Git - lilypond.git/blobdiff - python/book_snippets.py
Lilypond-book: Improve comments
[lilypond.git] / python / book_snippets.py
index 0ecc5356dee930f0f1146cc2989b64668a8728a9..cbf09a7a28f59bcf47cb8103883c2d511bedc510 100644 (file)
@@ -39,12 +39,10 @@ FILENAME = 'filename'
 FILTER = 'filter'
 FRAGMENT = 'fragment'
 LAYOUT = 'layout'
-LILYQUOTE = 'lilyquote'
 LINE_WIDTH = 'line-width'
 NOFRAGMENT = 'nofragment'
 NOGETTEXT = 'nogettext'
 NOINDENT = 'noindent'
-NOQUOTE = 'noquote'
 INDENT = 'indent'
 NORAGGED_RIGHT = 'noragged-right'
 NOTES = 'body'
@@ -67,7 +65,6 @@ VERSION = 'lilypondversion'
 
 # NOTIME and NOGETTEXT have no opposite so they aren't part of this
 # dictionary.
-# NOQUOTE is used internally only.
 no_options = {
     NOFRAGMENT: FRAGMENT,
     NOINDENT: INDENT,
@@ -115,7 +112,6 @@ snippet_options = {
         INDENT: r'''indent = %(indent)s''',
         LINE_WIDTH: r'''line-width = %(line-width)s''',
         QUOTE: r'''line-width = %(line-width)s - 2.0 * %(exampleindent)s''',
-        LILYQUOTE: r'''line-width = %(line-width)s - 2.0 * %(exampleindent)s''',
         RAGGED_RIGHT: r'''ragged-right = ##t''',
         NORAGGED_RIGHT: r'''ragged-right = ##f''',
     },
@@ -144,6 +140,8 @@ snippet_options = {
 
 
 def classic_lilypond_book_compatibility (key, value):
+    if key == 'lilyquote':
+        return (QUOTE, value)
     if key == 'singleline' and value == None:
         return (RAGGED_RIGHT, None)
 
@@ -164,6 +162,8 @@ def classic_lilypond_book_compatibility (key, value):
     return (None, None)
 
 
+# TODO: Remove the 1mm additional padding in the line-width, once lilypond
+#       creates tighter cropped images!
 PREAMBLE_LY = '''%%%% Generated by %(program_name)s
 %%%% Options: [%(option_string)s]
 \\include "lilypond-book-preamble.ly"
@@ -177,7 +177,9 @@ PREAMBLE_LY = '''%%%% Generated by %(program_name)s
 
 \paper {
   %(paper_string)s
-  line-width = #(- line-width (* mm  %(padding_mm)f))
+  %% offset the left padding, also add 1mm as lilypond creates cropped
+  %% images with a little space on the right
+  line-width = #(- line-width (* mm  %(padding_mm)f) (* mm 1))
 }
 
 \layout {
@@ -393,13 +395,13 @@ class LilypondSnippet (Snippet):
                     self.option_dict[option] = None
 
 
-        # If LINE_WIDTH is used without parameter, set it to default.
+        # Store if we have an explicit line-width given
         has_line_width = self.option_dict.has_key (LINE_WIDTH)
         if has_line_width and self.option_dict[LINE_WIDTH] == None:
             has_line_width = False
             del self.option_dict[LINE_WIDTH]
 
-        # TODO: Can't we do that more efficiently (built-in python func?)
+        # Use default options (i.e. auto-detected line-width, etc)
         for k in self.formatter.default_snippet_options:
             if k not in self.option_dict:
                 self.option_dict[k] = self.formatter.default_snippet_options[k]
@@ -410,22 +412,6 @@ class LilypondSnippet (Snippet):
         if has_relative and not self.option_dict.has_key (FRAGMENT):
             self.option_dict[FRAGMENT] = None
 
-        if not has_line_width:
-            if type == 'lilypond' or FRAGMENT in self.option_dict:
-                self.option_dict[RAGGED_RIGHT] = None
-
-            if type == 'lilypond':
-                if LINE_WIDTH in self.option_dict:
-                    del self.option_dict[LINE_WIDTH]
-            else:
-                if RAGGED_RIGHT in self.option_dict:
-                    if LINE_WIDTH in self.option_dict:
-                        del self.option_dict[LINE_WIDTH]
-
-            if QUOTE in self.option_dict or type == 'lilypond':
-                if LINE_WIDTH in self.option_dict:
-                    del self.option_dict[LINE_WIDTH]
-
         if not INDENT in self.option_dict:
             self.option_dict[INDENT] = '0\\mm'
 
@@ -436,8 +422,7 @@ class LilypondSnippet (Snippet):
         # all settings before writing them in the \paper block.
         if not LINE_WIDTH in self.option_dict:
             if not QUOTE in self.option_dict:
-                if not LILYQUOTE in self.option_dict:
-                    self.option_dict[LINE_WIDTH] = "#(- paper-width \
+                self.option_dict[LINE_WIDTH] = "#(- paper-width \
 left-margin-default right-margin-default)"
 
     def get_option_list (self):