all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Add user stylesheet support for doc-view EPUB support
@ 2022-03-06 17:12 Kjartan Oli Agustsson
  2022-03-06 22:07 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Kjartan Oli Agustsson @ 2022-03-06 17:12 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 421 bytes --]

With the addition of EPUB support to doc-view I took a shot at
adding support for mutool's user stylesheet feature, which allows the
user to control the layout of the EPUB with custom CSS rules.

I'm attaching the patch here if anyone is interested.  This is my first
attempt at contributing to Emacs, so I'm sure there is something I got
wrong/did sub-optimally.  Any criticism/suggestions for improvement are
welcome.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: User Stylesheet support --]
[-- Type: text/x-patch, Size: 1634 bytes --]

From f1f919d64d97a0f8bd614ef7b099ca123b66c4d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kjartan=20=C3=93li=20=C3=81g=C3=BAstsson?=
 <kjartanoli@outlook.org>
Date: Fri, 4 Mar 2022 23:01:19 +0000
Subject: [PATCH] Add user stylesheet option for doc-view EPUB support

* lisp/doc-view.el (doc-view-start-process): Add user stylesheet to
process arguments when appropriate.
---
 lisp/doc-view.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index 193cf42ea4..8658ed013f 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -226,6 +226,12 @@ doc-view-resolution
 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 (file :must-match t)
+                 (const nil))
+  :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',
@@ -1079,6 +1085,9 @@ doc-view-start-process
   (let* ((default-directory (or (unhandled-file-name-directory
                                  default-directory)
 			        (expand-file-name "~/")))
+        (args (if (and (eq doc-view-doc-type 'epub)
+                        doc-view-mutool-user-stylesheet)
+                  (cons (car args) (cons (format "-U%s" (expand-file-name doc-view-mutool-user-stylesheet)) (cdr args)))))
          (proc (apply #'start-process name doc-view-conversion-buffer
                       program args)))
     (push proc doc-view--current-converter-processes)
-- 
2.35.1


[-- Attachment #3: Type: text/plain, Size: 35 bytes --]


-- 
Kjartan Óli Ágústsson


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-03-14 11:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-06 17:12 [PATCH] Add user stylesheet support for doc-view EPUB support Kjartan Oli Agustsson
2022-03-06 22:07 ` Lars Ingebrigtsen
2022-03-07  0:17   ` Kjartan Oli Agustsson
2022-03-07  0:50     ` Kjartan Oli Agustsson
2022-03-07 16:31       ` Lars Ingebrigtsen
2022-03-08 23:06         ` Kjartan Oli Agustsson
2022-03-09 13:59           ` Lars Ingebrigtsen
2022-03-09 22:34             ` Kjartan Oli Agustsson
2022-03-12 16:40               ` Lars Ingebrigtsen
2022-03-14 10:25                 ` Kjartan Oli Agustsson
2022-03-14 10:32                   ` Lars Ingebrigtsen
2022-03-14 11:17                     ` Kjartan Oli Agustsson

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.