diff --git a/oni-shr.el b/oni-shr.el index 3537fb1..9bc2dfd 100644 --- a/oni-shr.el +++ b/oni-shr.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; 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 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))