>From 656ced71e92d95b1ef8621bcb93984bd5e315711 Mon Sep 17 00:00:00 2001 From: Ivan Kanis Date: Thu, 27 Jun 2013 19:59:27 +0200 Subject: [PATCH] add render region function --- emacs/misc/shr.el | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/emacs/misc/shr.el b/emacs/misc/shr.el index f2db68b..fc48449 100644 --- a/emacs/misc/shr.el +++ b/emacs/misc/shr.el @@ -166,6 +166,17 @@ cid: URL as the argument.") (libxml-parse-html-region (point-min) (point-max)))) (goto-char (point-min))) +(defun shr-render-region (begin end &optional buffer) + "Display the HTML rendering of the region between BEGIN and END." + (interactive "r") + (unless (fboundp 'libxml-parse-html-region) + (error "This function requires Emacs to be compiled with libxml2")) + (with-current-buffer (or buffer (current-buffer)) + (let ((dom (libxml-parse-html-region begin end))) + (kill-region begin end) + (goto-char begin) + (shr-insert-document dom)))) + (defun shr-visit-file (file) "Parse FILE as an HTML document, and render it in a new buffer." (interactive "fHTML file name: ") -- 1.7.1