[LyX/master] ePub: add argument for external DocBook XSLT.

Thibaut Cuvelier tcuvelier at lyx.org
Sun Feb 7 19:49:56 UTC 2021


commit e95513c8232a7da526eba44f7a30831ca5766558
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sun Feb 7 20:51:25 2021 +0100

    ePub: add argument for external DocBook XSLT.
---
 lib/configure.py            |    4 ++--
 lib/scripts/docbook2epub.py |   15 +++++++++------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/lib/configure.py b/lib/configure.py
index 47d1034..346213c 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -1008,9 +1008,9 @@ def checkConverterEntries():
     #
     global java
     if xsltproc != '':
-        addToRC('\\converter docbook5 epub "python $$s/scripts/docbook2epub.py none \\"' + xsltproc + '\\" $$i $$o" ""')
+        addToRC('\\converter docbook5 epub "python $$s/scripts/docbook2epub.py none \\"' + xsltproc + '\\" none $$i $$o" ""')
     elif java != '':
-        addToRC('\\converter docbook5 epub "python $$s/scripts/docbook2epub.py \\"' + java + '\\" none $$i $$o" ""')
+        addToRC('\\converter docbook5 epub "python $$s/scripts/docbook2epub.py \\"' + java + '\\" none none $$i $$o" ""')
     #
     checkProg('a MS Word Office Open XML converter -> LaTeX', ['pandoc -s -f docx -o $$o -t latex $$i'],
         rc_entry = [ r'\converter word2      latex      "%%"	""' ])
diff --git a/lib/scripts/docbook2epub.py b/lib/scripts/docbook2epub.py
index 9836240..b3aba7a 100644
--- a/lib/scripts/docbook2epub.py
+++ b/lib/scripts/docbook2epub.py
@@ -26,16 +26,16 @@ class DocBookToEpub:
         if args is None:
             args = sys.argv
 
-        if len(args) != 5:
-            print('Five arguments are expected, only %s found.' % len(sys.argv))
-            print(args)
+        if len(args) != 6:
+            print('Six arguments are expected, only %s found: %s.' % (len(args), args))
             sys.exit(1)
 
         self.own_path = sys.argv[0]
         self.java_path = sys.argv[1] if sys.argv[1] != '' and sys.argv[1] != 'none' else ''
         self.xsltproc_path = sys.argv[2] if sys.argv[2] != '' and sys.argv[2] != 'none' else ''
-        self.input = sys.argv[3]
-        self.output = sys.argv[4]
+        self.xslt_path = sys.argv[3] if sys.argv[3] != '' and sys.argv[3] != 'none' else ''
+        self.input = sys.argv[4]
+        self.output = sys.argv[5]
         self.script_folder = os.path.dirname(self.own_path) + '/../'
 
         print('Generating ePub with the following parameters:')
@@ -50,7 +50,10 @@ class DocBookToEpub:
         self.package_opf = self.output_dir + '/OEBPS/package.opf'  # Does not exist yet,
         print('Temporary output directory: %s' % self.output_dir)
 
-        self.xslt = self.script_folder + 'docbook/epub3/chunk.xsl'
+        if self.xslt_path == '':
+            self.xslt = self.script_folder + 'docbook/epub3/chunk.xsl'
+        else:
+            self.xslt = self.xslt_path + '/epub3/chunk.xsl'
         print('XSLT style sheet to use:')
         print(self.xslt)
 


More information about the lyx-cvs mailing list