Function: shr-tag-table
shr-tag-table is a byte-compiled function defined in shr.el.gz.
Signature
(shr-tag-table DOM)
Source Code
;; Defined in /usr/src/emacs/lisp/net/shr.el.gz
(defun shr-tag-table (dom)
(shr-ensure-paragraph)
(let* ((caption (dom-children (dom-child-by-tag dom 'caption)))
(header (dom-non-text-children (dom-child-by-tag dom 'thead)))
(footer (dom-non-text-children (dom-child-by-tag dom 'tfoot))))
(if (and (not caption)
(not header)
(not (dom-child-by-tag dom 'tbody))
(not (dom-child-by-tag dom 'tr))
(not footer))
;; The table is totally invalid and just contains random junk.
;; Try to output it anyway.
(shr-generic dom)
;; It's a real table, so render it.
(if (dom-attr dom 'shr-fixed-table)
(shr-tag-table-1 dom)
;; Only fix up the table once.
(let ((table (shr--fix-table dom caption header footer)))
(dom-set-attribute table 'shr-fixed-table t)
(setcdr dom (cdr table))
(shr-tag-table-1 dom)))
(let* ((bgcolor (dom-attr dom 'bgcolor))
(start (point))
(shr-stylesheet (nconc (list (cons 'background-color bgcolor))
shr-stylesheet)))
(when bgcolor
(shr-colorize-region start (point) (cdr (assq 'color shr-stylesheet))
bgcolor))
;; Finally, insert all the images after the table. The Emacs buffer
;; model isn't strong enough to allow us to put the images actually
;; into the tables. It inserts also non-td/th objects.
(when (zerop shr-table-depth)
(save-excursion
(shr-expand-alignments start (point)))
(let ((strings (shr-collect-extra-strings-in-table dom)))
(when strings
(save-restriction
(narrow-to-region (point) (point))
(insert (mapconcat #'identity strings "\n"))
(shr-fill-lines (point-min) (point-max))))))))))