From: janneke <janneke>
Date: Thu, 26 Feb 2004 13:36:14 +0000 (+0000)
Subject: (do_file): Bugfix: change search order
X-Git-Tag: release/2.1.36~254
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a07fcaf6000b5b52d79c1f6558cbcc8e00241eb2;p=lilypond.git

(do_file): Bugfix: change search order
of snippet types; fixes @ignore and @verbatim blocks.
---

diff --git a/ChangeLog b/ChangeLog
index aacb2c65f3..e30844ffb1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-02-26  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+	* scripts/lilypond-book.py (do_file): Bugfix: change search order
+	of snippet types; fixes @ignore and @verbatim blocks.
+
 2004-02-26  Heikki Junes <hjunes@cc.hut.fi>
 
         * input/test/[a-b]*.ly: refresh descriptions -- avoid referring
diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py
index 0e78510864..b93518628b 100644
--- a/scripts/lilypond-book.py
+++ b/scripts/lilypond-book.py
@@ -159,8 +159,8 @@ snippet_res = {
 	'lilypond' : '(?m)^(?P<match>@lilypond(\[(?P<options>[^]]*)\])?{(?P<code>.*?)})',
 	'lilypond_block': r'''(?ms)^(?P<match>@lilypond(\[(?P<options>[^]]*)\])?\s(?P<code>.*?)@end lilypond)\s''',
 	'lilypond_file': '(?m)^(?P<match>@lilypondfile(\[(?P<options>[^]]*)\])?{(?P<filename>[^}]+)})',
-	'multiline_comment': r"(?sm)^\s*(?!@c\s+)(?P<code>@ignore\s.*?@end ignore)\s",
-	'singleline_comment': r"(?m)^.*(?P<match>(?P<code>@c([ \t][^\n]*|)\n))",
+	'multiline_comment': r'(?sm)^\s*(?!@c\s+)(?P<code>@ignore\s.*?@end\s+ignore)\s',
+	'singleline_comment': r'(?m)^.*(?P<match>(?P<code>@c([ \t][^\n]*|)\n))',
 
 # don't do this: fucks up with @code{@{}
 #	'verb': r'''(?P<code>@code{.*?})''',
@@ -596,7 +596,7 @@ def find_toplevel_snippets (s, types):
                                 m = res[type].search (s[index:endex])
 				if not m:
 					continue
-				
+
 				cl = Snippet
 				if snippet_type_to_class.has_key (type):
 					cl = snippet_type_to_class[type]
@@ -607,6 +607,17 @@ def find_toplevel_snippets (s, types):
                         if found[type] \
 			   and (not first or found[type][0] < found[first][0]):
                                 first = type
+
+				# FIXME.
+
+				# Limiting the search space is a cute
+				# idea, but this *requires* to search
+				# for possible containing blocks
+				# first, at least long as we do not
+				# search for the start of blocks, but
+				# always/directly for the entire
+				# @block ... @end block.
+				
                                 endex = found[first][0]
 
                 if not first:
@@ -616,6 +627,7 @@ def find_toplevel_snippets (s, types):
 		(start , snip) = found[first]
 		snippets.append (Substring (s, index, start))
 		snippets.append (snip)
+		found[first] = None
                 index = start + len (snip.match.group (0))
 
         return snippets
@@ -776,13 +788,14 @@ def do_file (input_filename):
 	ly.progress (_ ("Reading %s...") % input_fullname)
 	source = in_handle.read ()
 	ly.progress ('\n')
-	
+
+	# FIXME: containing blocks must be first, see find_toplevel_snippets
 	snippet_types = (
+		'multiline_comment',
+		'verbatim',
 		'lilypond_block',
 #		'verb',
-		'verbatim',
 		'singleline_comment',
-		'multiline_comment',
 		'lilypond_file',
 		'include',
 		'lilypond', )