Function: shr-insert-document
shr-insert-document is an autoloaded and byte-compiled function
defined in shr.el.gz.
Signature
(shr-insert-document DOM)
Documentation
Render the parsed document DOM into the current buffer.
DOM should be a parse tree as generated by
libxml-parse-html-region or similar.
Source Code
;; Defined in /usr/src/emacs/lisp/net/shr.el.gz
;;;###autoload
(defun shr-insert-document (dom)
"Render the parsed document DOM into the current buffer.
DOM should be a parse tree as generated by
`libxml-parse-html-region' or similar."
(setq shr-content-cache nil)
(let ((start (point))
(shr-start nil)
(shr-base nil)
(shr-depth 0)
(shr-table-id 0)
(shr-warning nil)
(shr-table-separator-pixel-width (shr-string-pixel-width "-"))
(shr-internal-bullet (cons shr-bullet
(shr-string-pixel-width shr-bullet)))
(shr-internal-width
(if shr-width
;; Specified width; use it.
(if (not shr-use-fonts)
shr-width
(* shr-width (frame-char-width)))
;; Compute the width based on the window width. We need to
;; adjust the available width for when the user disables
;; the fringes, which will cause the display engine usurp
;; one column for the continuation glyph.
(if (not shr-use-fonts)
(- (window-body-width) 1
(if (shr--have-one-fringe-p)
1
0))
(- (window-body-width nil t)
(* 2 (frame-char-width))
(if (shr--have-one-fringe-p)
0
(* (frame-char-width) 2))
1))))
(max-specpdl-size max-specpdl-size)
;; `bidi-display-reordering' is supposed to be only used for
;; debugging purposes, but Shr's naïve filling algorithm
;; cannot cope with the complexity of RTL text in an LTR
;; paragraph, when a long line has been continued, and for
;; most scripts the character metrics don't change when they
;; are reordered, so... this is the best we could do :-(
bidi-display-reordering)
;; Adjust for max width specification.
(when (and shr-max-width
(not shr-width))
(setq shr-internal-width
(min shr-internal-width
(if shr-use-fonts
(* shr-max-width (frame-char-width))
shr-max-width))))
;; If the window was hscrolled for some reason, shr-fill-lines
;; below will misbehave, because it silently assumes that it
;; starts with a non-hscrolled window (vertical-motion will move
;; to a wrong place otherwise).
(set-window-hscroll nil 0)
(shr-descend dom)
(shr-fill-lines start (point))
(shr--remove-blank-lines-at-the-end start (point))
(when shr-warning
(message "%s" shr-warning))))