X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fshr.el;h=e7a6c5d20810b3bd0c4a7db432acb02859189532;hb=8ba1cd0b96466a96265ec5336728519aa6030d83;hp=a0cf10daaaf41fd887f3ecdbd38ecdb387b71a3d;hpb=935af32fa5a3d22163b9b626d770f5c16a766837;p=gnus diff --git a/lisp/shr.el b/lisp/shr.el index a0cf10daa..e7a6c5d20 100644 --- a/lisp/shr.el +++ b/lisp/shr.el @@ -129,17 +129,23 @@ cid: URL as the argument.") ;; Public functions and commands. -(defun shr-visit-file (file) - "Parse FILE as an HTML document, and render it in a new buffer." - (interactive "fHTML file name: ") +(defun shr-render-buffer (buffer) + "Display the HTML rendering of the current buffer." + (interactive (list (current-buffer))) (pop-to-buffer "*html*") (erase-buffer) (shr-insert-document - (with-temp-buffer - (insert-file-contents file) + (with-current-buffer buffer (libxml-parse-html-region (point-min) (point-max)))) (goto-char (point-min))) +(defun shr-visit-file (file) + "Parse FILE as an HTML document, and render it in a new buffer." + (interactive "fHTML file name: ") + (with-temp-buffer + (insert-file-contents file) + (shr-render-buffer (current-buffer)))) + ;;;###autoload (defun shr-insert-document (dom) "Render the parsed document DOM into the current buffer. @@ -478,6 +484,9 @@ size, and full-buffer size." (string-match "\\`[a-z]*:" url) (not shr-base)) url) + ((and (string-match "\\`//" url) + (string-match "\\`[a-z]*:" shr-base)) + (concat (match-string 0 shr-base) url)) ((and (not (string-match "/\\'" shr-base)) (not (string-match "\\`/" url))) (concat shr-base "/" url))