Skip to content

Commit

Permalink
Use nov-render-svg
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyanming committed Sep 16, 2024
1 parent 71b1706 commit 2c3de9c
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions config.el
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
(tab-width 8)
(shr-external-rendering-functions
(append '((img . nov-render-img)
(svg . my-nov-render-svg)
(svg . nov-render-svg)
(title . nov-render-title)
(pre . shrface-shr-tag-pre-highlight)
(code . shrface-tag-code)
Expand Down Expand Up @@ -270,19 +270,6 @@
(if paw-annotation-show-unknown-words-p
(paw-focus-find-words)))))

(defun my-nov-render-svg (dom)
"A fix for `shr-render-svg' which will render relative image."
(when (and (image-type-available-p 'svg)
(not shr-inhibit-images)
(dom-attr dom 'width)
(dom-attr dom 'height))
(let ((url (dom-attr (dom-by-tag dom 'image) 'xlink:href)))
(if (nov-external-url-p url)
(funcall shr-put-image-function (list (shr-dom-to-xml dom 'utf-8)
'image/svg+xml)
"SVG Image")
(nov-insert-image (expand-file-name (nov-urldecode url)) url)))))

(defun my-shr--remove-blank-lines-at-the-end (start end)
"A fix for `shr--remove-blank-lines-at-the-end' which will remove image at the end of the document."
(save-restriction
Expand Down

0 comments on commit 2c3de9c

Please sign in to comment.