From: Adam S. <as...@ko...> - 2019-04-14 10:00:50
|
>From c7fd762d410dd0fcb13919eff56dbde115166c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Sj=C3=B8gren?= <as...@ko...> Date: Sun, 14 Apr 2019 11:48:34 +0200 Subject: To use: (require 'jabber-print-html) --- This is the work done by Phil Groce back in 2016 with my kludges to make it work nicely (remove whitespace around the rendered text, advertise XHTML rendering, use same logic as jabber-chat.el for finding html node and returning foundp). jabber-print-html.el | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 jabber-print-html.el diff --git a/jabber-print-html.el b/jabber-print-html.el new file mode 100644 index 0000000..fbfae94 --- /dev/null +++ b/jabber-print-html.el @@ -0,0 +1,26 @@ +(defun jabber-print-html (xml-data who mode) + "Print messages formatted in HTML, using shr." + (let ((foundp nil)) + (dolist (x (jabber-xml-node-children xml-data)) + (when (and (listp x) (eq (jabber-xml-node-name x) 'html)) + (setq foundp t) + + (when (eql mode :insert) + (when x + (let ((beg (point)) + (end nil)) + (insert (jabber-sexp2xml x)) + (setq end (point)) + (shr-render-region beg end) + (goto-char beg) + (delete-region (point) (progn (skip-chars-forward " \t\r\n") (point))) + (search-forward "---\n") + (goto-char (match-beginning 0)) + (delete-region (point) (progn (skip-chars-backward " \t\r\n") (point))) + ))))) + foundp)) + +(add-to-list 'jabber-body-printers 'jabber-print-html) +(jabber-disco-advertise-feature "http://jabber.org/protocol/xhtml-im") + +(provide 'jabber-print-html) -- 2.20.1 -- "Everything needs to change. Adam Sjøgren And it has to start today." as...@ko... |