From: Reinhold Kainhofer Date: Sun, 16 Nov 2008 14:57:06 +0000 (+0100) Subject: lilypond-book: Implement lilypondversion tag (to be replaced by the lilypond version) X-Git-Tag: release/2.11.64-1~5 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4681aa8f55d829e119b4c6dc630375e6d1234e4c;p=lilypond.git lilypond-book: Implement lilypondversion tag (to be replaced by the lilypond version) Syntax for the new tag is: -) LaTeX: \lilypondversion -) HTML: -) Texinfo: @lilypondversion -) Docbook: NONE The tag / command will be replaced by the LilyPond version, like "2.11.64". --- 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)