diff options
author | Tom Willemse | 2020-03-28 11:50:44 -0700 |
---|---|---|
committer | Tom Willemse | 2020-03-28 11:51:28 -0700 |
commit | 931f38989eff3d8ecc09aa030d2d6ee1aade883d (patch) | |
tree | c2029ad61d4bb716daa051667f372c7e507155af /oni-shr.el | |
parent | 226c1d86bd3aeee6c07bdeee6facb3039841c3da (diff) | |
download | emacs-config-931f38989eff3d8ecc09aa030d2d6ee1aade883d.tar.gz emacs-config-931f38989eff3d8ecc09aa030d2d6ee1aade883d.zip |
Improve shr rendering of <code> and <pre> tags a little
Diffstat (limited to 'oni-shr.el')
-rw-r--r-- | oni-shr.el | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -4,7 +4,7 @@ ;; Author: Tom Willemse <tom@ryuslash.org> ;; Keywords: local -;; Version: 2019.0904.210815 +;; Version: 2020.0328.023508 ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -33,8 +33,29 @@ (butlast args) args)) +(defun shr-tag-code (dom) + "Render a <code> tag from DOM." + (let ((shr-current-font 'default) + (start (point))) + (shr-generic dom) + (add-face-text-property start (point) '(:background "#222222" :box (:line-width 3 :color "#222222"))))) + +(defun oni-shr--recolorize (orig-fun &rest args) + "Do some custom colorization. + +This should be used with ‘add-function’ with the ‘:around’ +combinator. ORIG-FUN is the original function being wrapped, ARGS +are the arguments passed in to it." + (let ((start (point))) + (apply orig-fun args) + (save-excursion + (forward-line -1) + (string-rectangle start (point) " ")) + (add-face-text-property start (point) '(:background "#222222")))) + (advice-add #'shr-colorize-region - :filter-args #'oni-shr--colorize-remove-last-arg) + :filter-args #'oni-shr--colorize-remove-last-arg) +(add-function :around (symbol-function 'shr-tag-pre) #'oni-shr--recolorize) ;;;###autoload(with-eval-after-load 'shr (require 'oni-shr)) |