Function: shr-collect-extra-strings-in-table
shr-collect-extra-strings-in-table is a byte-compiled function defined
in shr.el.gz.
Signature
(shr-collect-extra-strings-in-table DOM &optional FLAGS)
Documentation
Return extra strings in DOM of which the root is a table clause.
Render <img>s and <object>s, and strings and child <table>s of which the parent <td> or <th> is lacking. FLAGS is a cons of two boolean flags that control whether to collect or render objects.
Source Code
;; Defined in /usr/src/emacs/lisp/net/shr.el.gz
(defun shr-collect-extra-strings-in-table (dom &optional flags)
"Return extra strings in DOM of which the root is a table clause.
Render <img>s and <object>s, and strings and child <table>s of which
the parent <td> or <th> is lacking. FLAGS is a cons of two boolean
flags that control whether to collect or render objects."
;; This function runs recursively and collects strings if the cdr of
;; FLAGS is nil and the car is not nil, and it renders also child
;; <table>s if the cdr is nil. Note: FLAGS may be nil, not a cons.
;; FLAGS becomes (t . nil) if a <tr> clause is found in the children
;; of DOM, and becomes (t . t) if a <td> or a <th> clause is found
;; and the car is t then. When a <table> clause is found, FLAGS
;; becomes nil if the cdr is t then. But if FLAGS is (t . nil) then,
;; it renders the <table>.
(cl-loop for child in (dom-children dom) with recurse with tag
do (setq recurse nil)
if (stringp child)
unless (or (not (car flags)) (cdr flags))
when (string-match "\\(?:[^\t\n\r ]+[\t\n\r ]+\\)*[^\t\n\r ]+"
child)
collect (match-string 0 child)
end end
else if (consp child)
do (setq tag (dom-tag child)) and
unless (memq tag '(comment style))
if (eq tag 'img)
do (shr-indirect-call 'img child)
else if (eq tag 'object)
do (shr-indirect-call 'object child)
else
do (setq recurse t) and
if (eq tag 'tr)
do (setq flags '(t . nil))
else if (memq tag '(td th))
when (car flags)
do (setq flags '(t . t))
end
else if (eq tag 'table)
if (cdr flags)
do (setq flags nil)
else if (car flags)
do (setq recurse nil)
(shr-indirect-call 'table child)
end end end end end end end end end end
when recurse
append (shr-collect-extra-strings-in-table child flags)))