Function: eww-display-html
eww-display-html is a byte-compiled function defined in eww.el.gz.
Signature
(eww-display-html CHARSET URL &optional DOCUMENT POINT BUFFER ENCODE)
Source Code
;; Defined in /usr/src/emacs/lisp/net/eww.el.gz
(defun eww-display-html (charset url &optional document point buffer encode)
(unless (fboundp 'libxml-parse-html-region)
(error "This function requires Emacs to be compiled with libxml2"))
(unless (buffer-live-p buffer)
(error "Buffer %s doesn't exist" buffer))
;; There should be a better way to abort loading images
;; asynchronously.
(setq url-queue nil)
(let ((document
(or document
(list
'base (list (cons 'href url))
(progn
(setq encode (or encode charset 'utf-8))
(condition-case nil
(decode-coding-region (point) (point-max) encode)
(coding-system-error nil))
(save-excursion
;; Remove CRLF and replace NUL with � before parsing.
(while (re-search-forward "\\(\r$\\)\\|\0" nil t)
(replace-match (if (match-beginning 1) "" "�") t t)))
(eww--preprocess-html (point) (point-max))
(libxml-parse-html-region (point) (point-max))))))
(source (and (null document)
(buffer-substring (point) (point-max)))))
(with-current-buffer buffer
(setq bidi-paragraph-direction nil)
(plist-put eww-data :source source)
(plist-put eww-data :dom document)
(let ((inhibit-read-only t)
(inhibit-modification-hooks t)
;; Possibly set by the caller, e.g., `eww-render' which
;; preserves the old URL #target before chasing redirects.
(shr-target-id (or shr-target-id
(url-target (url-generic-parse-url url))))
(shr-external-rendering-functions
(append
shr-external-rendering-functions
'((title . eww-tag-title)
(form . eww-tag-form)
(input . eww-tag-input)
(button . eww-form-submit)
(textarea . eww-tag-textarea)
(select . eww-tag-select)
(link . eww-tag-link)
(meta . eww-tag-meta)
(a . eww-tag-a)))))
(erase-buffer)
(shr-insert-document document)
(cond
(point
(goto-char point))
(shr-target-id
(goto-char (point-min))
(let ((match (text-property-search-forward
'shr-target-id shr-target-id t)))
(when match
(goto-char (prop-match-beginning match)))))
(t
(goto-char (point-min))
;; Don't leave point inside forms, because the normal eww
;; commands aren't available there.
(while (and (not (eobp))
(get-text-property (point) 'eww-form))
(forward-line 1)))))
(eww-size-text-inputs))))