+2004-10-16 Werner Lemberg <wl@gnu.org>
+
+ * scripts/lilypond-book.ly (snippet_res): Define group `match'
+ everywhere.
+ Accept more spaces between commands and its arguments and options.
+ Fix some regexps.
+ (output): Remove some newlines in string values and suppress spaces
+ in output.
+ (output_texinfo): Output `output_print_filename' only if not empty.
+ (Lilypond_snippet)[find_toplevel_snippets]: Use group `match'.
+
2004-10-16 Werner Lemberg <wl@gnu.org>
* scm/framework-tex.scm (font-load-command, define-fonts): Protect
</lilypondfile>)''',
'multiline_comment':
r'''(?smx)
+ (?P<match>
\s*(?!@c\s+)
(?P<code><!--\s.*?!-->)
- \s''',
+ \s)''',
'singleline_comment':
no_match,
'verb':
r'''(?x)
- (?P<code><pre>.*?</pre>)''',
+ (?P<match>
+ (?P<code><pre>.*?</pre>))''',
'verbatim':
r'''(?x)
(?s)
- (?P<code><pre>\s.*?</pre>\s)''',
+ (?P<match>
+ (?P<code><pre>\s.*?</pre>\s))''',
},
LATEX: {
'include':
- r'''(?mx)
+ r'''(?smx)
^[^%\n]*?
(?P<match>
- \\input{
- (?P<filename>[^}]+)
+ \\input\s*{
+ (?P<filename>\S+?)
})''',
'lilypond':
r'''(?smx)
\])?\s*{lilypond}
(?P<code>.*?)
^[^%\n]*?
- \\end{lilypond})''',
+ \\end\s*{lilypond})''',
'lilypond_file':
- r'''(?mx)
+ r'''(?smx)
^[^%\n]*?
(?P<match>
\\lilypondfile\s*(
\[
(?P<options>.*?)
\])?\s*\{
- (?P<filename>.+)
+ (?P<filename>\S+?)
})''',
'multiline_comment':
no_match,
^.*?
(?P<match>
(?P<code>
- ^%.*$\n+))''',
+ %.*$\n+))''',
'verb':
- r'''(?x)
- (?P<code>
- \\verb(?P<del>.)
- .*?
- (?P=del))''',
+ r'''(?mx)
+ ^[^%\n]*?
+ (?P<match>
+ (?P<code>
+ \\verb(?P<del>.)
+ .*?
+ (?P=del)))''',
'verbatim':
- r'''(?sx)
- (?P<code>
- \\begin\s*{verbatim}
- .*?
- \\end{verbatim})''',
+ r'''(?msx)
+ ^[^%\n]*?
+ (?P<match>
+ (?P<code>
+ \\begin\s*{verbatim}
+ .*?
+ \\end\s*{verbatim}))''',
},
TEXINFO: {
'include':
r'''(?mx)
- ^[^%\n]*?
- (?P<match>
+ ^(?P<match>
@include\s+
(?P<filename>\S+))''',
'lilypond':
- r'''(?mx)
- ^
+ r'''(?smx)
+ ^[^\n]*?(?!@c\s+)[^\n]*?
(?P<match>
- @lilypond(
+ @lilypond\s*(
\[
- (?P<options>[^]]*)
- \])?{
+ (?P<options>.*?)
+ \])?\s*{
(?P<code>.*?)
})''',
'lilypond_block':
r'''(?msx)
- ^
- (?P<match>
- @lilypond(
+ ^(?P<match>
+ @lilypond\s*(
\[
- (?P<options>[^]]*)
- \])?\s
- (?P<code>.*?)
- @end lilypond)\s''',
+ (?P<options>.*?)
+ \])?\s+?
+ ^(?P<code>.*?)
+ ^@end\s+lilypond)\s''',
'lilypond_file':
r'''(?mx)
- ^
- (?P<match>
- @lilypondfile(
+ ^(?P<match>
+ @lilypondfile\s*(
\[
- (?P<options>[^]]*)
- \])?{
- (?P<filename>[^}]+)
+ (?P<options>.*?)
+ \])?\s*{
+ (?P<filename>\S+)
})''',
'multiline_comment':
r'''(?smx)
- ^\s*(?!@c\s+)
- (?P<code>
- @ignore
- \s.*?
- @end\s+ignore)\s''',
+ ^(?P<match>
+ (?P<code>
+ @ignore\s
+ .*?
+ @end\s+ignore))\s''',
'singleline_comment':
r'''(?mx)
^.*
# 'verb': r'''(?P<code>@code{.*?})''',
'verbatim':
r'''(?sx)
- (?P<code>
- @example
- \s.*?
- @end\s+example\s)''',
+ (?P<match>
+ (?P<code>
+ @example
+ \s.*?
+ @end\s+example\s))''',
},
}
AFTER: r'''
</a>
</p>''',
- BEFORE: r'''
-<p>
+ BEFORE: r'''<p>
<a href="%(base)s.ly">''',
OUTPUT: r'''
<img align="center" valign="center"
OUTPUT: r'''{\parindent 0pt
\catcode`\@=12
\ifx\preLilyPondExample\undefined\relax\else\preLilyPondExample\fi
-\def\lilypondbook{}
+\def\lilypondbook{}%%
\input %(base)s.tex
\ifx\postLilyPondExample\undefined\relax\else\postLilyPondExample\fi
\catcode`\@=0}''',
PRINTFILENAME: '''\\texttt{%(filename)s}
-
''',
QUOTE: r'''\begin{quotation}
%(str)s
AFTER: '',
BEFORE: '',
OUTPUT: r'''@noindent
-@image{%(base)s,,,[image of music],%(ext)s}
-''',
+@image{%(base)s,,,[image of music],%(ext)s}''',
PRINTFILENAME: '''@file{%(filename)s}
-
''',
QUOTE: r'''@quotation
%(str)s
def output_texinfo (self):
str = ''
# self.output_print_filename (TEXINFO)
- str += ('@html\n' + self.output_print_filename (HTML)
- + '\n@end html\n')
- str += ('@tex\n' + self.output_print_filename (LATEX)
- + '\n@end tex\n')
+ if self.output_print_filename (0):
+ str += ('@html\n' + self.output_print_filename (HTML)
+ + '\n@end html\n')
+ str += ('@tex\n' + self.output_print_filename (LATEX)
+ + '\n@end tex\n')
base = self.basename ()
if TEXIDOC in self.options:
texidoc = base + '.texidoc'
if snippet_type_to_class.has_key (type):
cl = snippet_type_to_class[type]
snip = cl (type, m, format)
- start = index + m.start (1)
+ start = index + m.start ('match')
found[type] = (start, snip)
if found[type] \
snippets.append (Substring (s, index, start))
snippets.append (snip)
found[first] = None
- index = start + len (snip.match.group (1))
+ index = start + len (snip.match.group ('match'))
return snippets