<2019-05-23 Thu>
Quickly copy an image of a htmlized buffer or region to the clipboard.
(defun ragone-htmlize () "Convert the htmlized region to an image and copy to clipboard." (interactive) (let ((htmlize-pre-style t) (region-background (face-attribute 'region :background)) (start (if (region-active-p) (region-beginning) (point-min))) (end (if (region-active-p) (region-end) (point-max)))) (set-face-background 'region "unspecified") (unwind-protect (ragone-htmlize-to-clipboard (htmlize-region-for-paste start end)) (set-face-background 'region region-background)))) (defun ragone-htmlize-to-clipboard (html) "Copy HTML to clipboard." (with-temp-buffer (insert html) (call-shell-region (point-min) (point-max) "wkhtmltoimage -f png - - | xclip -i -selection clipboard -t image/png")))