]> git.lyx.org Git - lyx.git/blobdiff - lib/scripts/docbook_copy.py
DocBook: update links to LilyPond bugs.
[lyx.git] / lib / scripts / docbook_copy.py
index 7cb68dca43b05bdfa9c736f88a60acf3c999ad08..5b5a3f400e0e8862af10423bbf14e17680612b60 100644 (file)
@@ -61,8 +61,9 @@ class DocBookCopier:
     def preprocess_input_for_lilypond(self):
         # LilyPond requires that its input file has the .lyxml extension. Due to a bug in LilyPond,
         # use " instead of ' to encode XML attributes.
-        # https://lists.gnu.org/archive/html/bug-lilypond/2021-09/msg00039.html
+        # Bug report: https://gitlab.com/lilypond/lilypond/-/issues/6185
         # Typical transformation:
+        # Fixed by 2.23.4.
         #     FROM:  language='lilypond' role='fragment verbatim staffsize=16 ragged-right relative=2'
         #     TO:    language="lilypond" role="fragment verbatim staffsize=16 ragged-right relative=2"
         with open(self.in_file, 'r', encoding='utf-8') as f, open(self.in_lily_file, 'w', encoding='utf-8') as f_lily:
@@ -77,14 +78,12 @@ class DocBookCopier:
         os.unlink(self.in_file)
 
     def postprocess_output_for_lilypond(self):
+        # Major problem: LilyPond used to output the LilyPond code outside the image, which is then always displayed
+        # before the image (instead of only the generated image).
+        # Bug report: https://gitlab.com/lilypond/lilypond/-/issues/6186
+        # No more necessary with the new version of LilyPond (2.23.4). No efficient way to decide how to post-process
+        # for previous versions of LilyPond. Basically, it does not make sense to post-process.
         pass
-        # # Erase the <programlisting> that LilyPond left behind in the XML.
-        # in_file_before = self.in_file + '.tmp'
-        # shutil.move(self.in_file, in_file_before)
-        # with open(in_file_before, 'r', encoding='utf-8') as f_before, open(self.in_file, 'w', encoding='utf-8') as f_after:
-        #     looking_for_end_programlisting = False
-        #     for line in f_before:
-        #         # TODO: find an efficient way to distinguish those left-overs.
 
     def call_lilypond(self):
         # LilyPond requires that its input file has the .lyxml extension (plus bugs in LilyPond).
@@ -97,7 +96,8 @@ class DocBookCopier:
             os.environ['PATH'] += os.pathsep + self.lilypond_folder
 
         # Make LilyPond believe it is working from the temporary LyX directory. Otherwise, it tries to find files
-        # starting from LyX's working directory... LilyPond bug.
+        # starting from LyX's working directory... LilyPond bug, most likely.
+        # https://lists.gnu.org/archive/html/bug-lilypond/2021-09/msg00041.html
         os.chdir(self.in_folder)
 
         # Start LilyPond on the copied file. First test the binary, then check if adding Python helps.
@@ -152,7 +152,6 @@ class DocBookCopier:
             shutil.copyfile(
                 os.path.join(in_generated_images_folder, img),
                 os.path.join(out_generated_images_folder, img),
-                follow_symlinks=False,
             )
 
     def copy(self):
@@ -162,7 +161,7 @@ class DocBookCopier:
             self.call_lilypond()
 
         # Perform the actual copy: both the modified XML file and the generated images, if LilyPond is used.
-        shutil.copyfile(self.in_file, self.out_file, follow_symlinks=False)
+        shutil.copyfile(self.in_file, self.out_file)
         if self.do_lilypond_processing:
             self.copy_lilypond_generated_images()