From f5d7181e0ce7fd8af713930a960d1d7af99cb7bc Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Fri, 4 Jul 2025 09:53:01 +1000 Subject: [emacs] Render ol in nov without numbering --- emacs/.emacs.d/init/ycp-markup.el | 1 + emacs/.emacs.d/lisp/my/my-nov.el | 14 ++++++++++++++ 2 files changed, 15 insertions(+) (limited to 'emacs') diff --git a/emacs/.emacs.d/init/ycp-markup.el b/emacs/.emacs.d/init/ycp-markup.el index c511d55..c331f49 100644 --- a/emacs/.emacs.d/init/ycp-markup.el +++ b/emacs/.emacs.d/init/ycp-markup.el @@ -120,6 +120,7 @@ "F" #'my-nov-skim-forward "B" #'my-nov-skim-backward) (add-to-list 'nov-shr-rendering-functions '(span . my-nov-render-span)) + (add-to-list 'nov-shr-rendering-functions '(ol . my-nov-render-ol)) (add-hook 'nov-mode-hook (lambda () (add-hook 'post-command-hook #'my-nov-update-mode-line nil t))) diff --git a/emacs/.emacs.d/lisp/my/my-nov.el b/emacs/.emacs.d/lisp/my/my-nov.el index 7cdb2a7..21df675 100644 --- a/emacs/.emacs.d/lisp/my/my-nov.el +++ b/emacs/.emacs.d/lisp/my/my-nov.el @@ -59,6 +59,20 @@ chapter title." (unless (equal (dom-attr dom 'epub:type) "pagebreak") (shr-generic dom))) +;;; TODO: perhaps no indentation? +(defun my-nov-render-ol (dom) + (shr-ensure-paragraph) + (let* ((attrs (dom-attributes dom)) + (start-attr (alist-get 'start attrs)) + ;; Start at 1 if there is no start attribute + ;; or if start can't be parsed as an integer. + (start-index (condition-case _ + (cl-parse-integer start-attr) + (t nil))) + (shr-list-mode (or start-index 'ul)) + (shr-internal-bullet `(" " . ,(shr-string-pixel-width " ")))) + (shr-generic dom)) + (shr-ensure-paragraph)) (defun my-nov-find-file-with-ipath (file-name ipath) "Find epub file and goto IPATH. -- cgit v1.2.3