mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
DocBook copy: don't error if the file was already copied.
This commit is contained in:
parent
a464915f58
commit
6d3be39587
@ -3,11 +3,13 @@
|
||||
See https://www.lyx.org/ for more information -->
|
||||
<article xml:lang="en_US" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.2">
|
||||
<title>LilyPond-book and LyX</title>
|
||||
<mediaobject>
|
||||
<textobject>
|
||||
<programlisting language='lilypond' role='fragment verbatim staffsize=16 ragged-right relative=2'>
|
||||
<programlisting>
|
||||
|
||||
\relative c'' { g a b c}
|
||||
</programlisting>
|
||||
</textobject>
|
||||
</mediaobject>
|
||||
</programlisting><mediaobject><imageobject role="latex">
|
||||
<imagedata fileref="ff\lily-3ed27d76.pdf" format="PDF"/>
|
||||
</imageobject>
|
||||
<imageobject role="html">
|
||||
<imagedata fileref="ff\lily-3ed27d76.png" format="PNG"/>
|
||||
</imageobject></mediaobject>
|
||||
</article>
|
@ -77,8 +77,14 @@ class DocBookCopier:
|
||||
os.unlink(self.in_file)
|
||||
|
||||
def postprocess_output_for_lilypond(self):
|
||||
# TODO.
|
||||
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).
|
||||
@ -125,17 +131,19 @@ class DocBookCopier:
|
||||
if failed:
|
||||
sys.exit(1)
|
||||
|
||||
# Now, in_file should have the LilyPond-processed contents.
|
||||
# LilyPond has a distressing tendency to leave the raw LilyPond code in the new file.
|
||||
self.postprocess_output_for_lilypond()
|
||||
|
||||
# Now, in_file should have the clean LilyPond-processed contents.
|
||||
|
||||
def copy_lilypond_generated_images(self):
|
||||
# LilyPond generates a lot of files in LyX' temporary folder, within the ff folder: source LilyPond files
|
||||
# for each snippet to render, images in several formats.
|
||||
in_generated_images_folder = os.path.join(self.in_folder, 'ff')
|
||||
out_generated_images_folder = os.path.join(self.out_folder, 'ff')
|
||||
|
||||
os.mkdir(out_generated_images_folder)
|
||||
if not os.path.isdir(out_generated_images_folder):
|
||||
os.mkdir(out_generated_images_folder)
|
||||
|
||||
for img in os.listdir(in_generated_images_folder):
|
||||
if not img.endswith('.png') and not img.endswith('.pdf'):
|
||||
|
Loading…
Reference in New Issue
Block a user