]> git.eshelyaron.com Git - emacs.git/commitdiff
Add user stylesheet option for doc-view EPUB support
authorKjartan Oli Agustsson <kjartanoli@outlook.com>
Mon, 7 Mar 2022 16:29:38 +0000 (17:29 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 7 Mar 2022 16:29:38 +0000 (17:29 +0100)
* lisp/doc-view.el (doc-view-start-process): Add user stylesheet to
process arguments when appropriate.

* lisp/doc-view.el (doc-view-mutool-user-stylesheet): New user option.

Copyright-paperwork-exempt: yes

lisp/doc-view.el

index 193cf42ea426223baa287dfb547041177d2e2426..5b07d75f6d86d9f6c38223bf9fe6e255cffe773c 100644 (file)
@@ -226,6 +226,12 @@ are available (see Info node `(emacs)Document View')"
 Higher values result in larger images."
   :type 'number)
 
+(defcustom doc-view-mutool-user-stylesheet nil
+  "User stylesheet to use when converting EPUB documents to PDF."
+  :type '(choice (const nil)
+                 (file :must-match t))
+  :version "29.1")
+
 (defvar doc-view-doc-type nil
   "The type of document in the current buffer.
 Can be `dvi', `pdf', `ps', `djvu', `odf', 'epub', `cbz', `fb2',
@@ -1169,8 +1175,16 @@ The test is performed using `doc-view-pdfdraw-program'."
          (options `(,(concat "-o" png)
                     ,(format "-r%d" (round doc-view-resolution))
                     ,@(if pdf-passwd `("-p" ,pdf-passwd)))))
-    (when (and (eq doc-view-doc-type 'epub) doc-view-epub-font-size)
-      (setq options (append options (list (format "-S%s" doc-view-epub-font-size)))))
+    (when (eq doc-view-doc-type 'epub)
+      (when doc-view-epub-font-size
+        (setq options (append options
+                              (list (format "-S%s" doc-view-epub-font-size)))))
+      (when doc-view-mutool-user-stylesheet
+        (setq options
+              (append options
+                      (list (format "-U%s"
+                                    (expand-file-name
+                                     doc-view-mutool-user-stylesheet)))))))
     (doc-view-start-process
      "pdf->png" doc-view-pdfdraw-program
      `(,@(doc-view-pdfdraw-program-subcommand)