+ return '''%% Note: this file works from version ''' + \
+ ly_new_version_re.search (ly_code).group (1) + '\n'
+
+s = 'Translation of GIT [Cc]ommittish'
+texidoc_chunk_re = re.compile (r'^(?:%+\s*' + s + \
+ r'.+)?\s*(?:texidoc|doctitle)([a-zA-Z]{2,4})\s+=(?:.|\n)*?(?=%+\s*' + \
+ s + r'|\n\} % begin verbatim|\n (?:doctitle|texidoc|lsrtags) |$(?!.|\n))', re.M)
+
+def update_translated_texidoc (m, snippet_path, visited_languages):
+ base = os.path.splitext (os.path.basename (snippet_path))[0]
+ language_code = m.group (1)
+ visited_languages.append (language_code)
+ texidoc_path = os.path.join ('Documentation', language_code,
+ 'texidocs', base + '.texidoc')
+ if os.path.isfile (texidoc_path):
+ return open (texidoc_path).read ()
+ else:
+ return m.group (0)
+
+def escape_backslashes_in_header(snippet):
+ # ASSUME: the \header exists.
+ header_char_number_start = snippet.find('\header {')
+ header_char_number_end = snippet.find('} % begin verbatim')
+
+ header = snippet[header_char_number_start:header_char_number_end]
+ # two levels of escaping happening here -- 4\ means 1\
+ # and the 10\ means two \ backslashes (that's 8\ ), and
+ # one backreference to group 1 (that's two 2\ ).
+ new_header = re.sub("@code\{\\\\([a-zA-Z])", "@code{\\\\\\\\\\1", header)
+ escaped_snippet = (snippet[:header_char_number_start] +
+ new_header + snippet[header_char_number_end:])
+ return escaped_snippet