X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Flilypond-book.py;h=9998f1ceec367277a181091b4646479e1c3c2af1;hb=1d4e8083422321e7e4a6d92d1ed99980a4cbf5f6;hp=b8c765d3fb0b74799d2269f922a4bcbf2e3f43a4;hpb=f52e59b15644e5da959b30a2e2d55fd5d5970bcb;p=lilypond.git diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index b8c765d3fb..9998f1ceec 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -260,6 +260,7 @@ DOCTITLE = 'doctitle' TEXIDOC = 'texidoc' TEXINFO = 'texinfo' VERBATIM = 'verbatim' +VERSION = 'lilypondversion' FONTLOAD = 'fontload' FILENAME = 'filename' ALT = 'alt' @@ -317,7 +318,9 @@ snippet_res = { 'verbatim': no_match, - + + 'lilypondversion': + no_match, }, ## HTML: { @@ -370,6 +373,11 @@ snippet_res = { (?s) (?P (?P
\s.*?
\s))''', + + 'lilypondversion': + r'''(?mx) + (?P + )''', }, ## @@ -443,6 +451,12 @@ snippet_res = { \\begin\s*{verbatim} .*? \\end\s*{verbatim}))''', + + 'lilypondversion': + r'''(?smx) + (?P + \\lilypondversion)[^a-zA-Z]''', + }, ## @@ -509,6 +523,12 @@ snippet_res = { @example \s.*? @end\s+example\s))''', + + 'lilypondversion': + r'''(?mx) + (?P + @lilypondversion)[^a-zA-Z]''', + }, } @@ -608,6 +628,8 @@ output = { ''', VERBATIM: r'''%(verb)s''', + + VERSION: program_version, PRINTFILENAME: '%(filename)s' }, @@ -638,6 +660,8 @@ output = { VERBATIM: r'''
 %(verb)s
''', + + VERSION: program_version, }, ## @@ -667,6 +691,8 @@ output = { VERBATIM: r'''\noindent \begin{verbatim}%(verb)s\end{verbatim}''', + VERSION: program_version, + FILTER: r'''\begin{lilypond}[%(options)s] %(code)s \end{lilypond}''', @@ -721,6 +747,8 @@ output = { %(verb)s@end verbatim ''', + VERSION: program_version, + ADDVERSION: r'''@example \version @w{"@version{}"} @end example @@ -1446,11 +1474,21 @@ class LilypondFileSnippet (LilypondSnippet): % (name, self.contents)) +class LilyPondVersionString (Snippet): + """A string that does not require extra memory.""" + def __init__ (self, type, match, format, line_number): + Snippet.__init__ (self, type, match, format, line_number) + + def replacement_text (self): + return output[self.format][self.type] + + snippet_type_to_class = { 'lilypond_file': LilypondFileSnippet, 'lilypond_block': LilypondSnippet, 'lilypond': LilypondSnippet, 'include': IncludeSnippet, + 'lilypondversion': LilyPondVersionString, } def find_linestarts (s): @@ -1879,6 +1917,7 @@ def do_file (input_filename, included=False): 'lilypond_file', 'include', 'lilypond', + 'lilypondversion', ) progress (_ ("Dissecting...")) chunks = find_toplevel_snippets (source, global_options.format, snippet_types)