Function: shr--fix-table

shr--fix-table is a byte-compiled function defined in shr.el.gz.

Signature

(shr--fix-table DOM CAPTION HEADER FOOTER)

Source Code

;; Defined in /usr/src/emacs/lisp/net/shr.el.gz
(defun shr--fix-table (dom caption header footer)
  (let* ((body (dom-non-text-children (shr--fix-tbody (shr-table-body dom))))
         (nheader (if header (shr-max-columns header)))
	 (nbody (if body (shr-max-columns body) 0))
         (nfooter (if footer (shr-max-columns footer))))
    (nconc
     (list 'table nil)
     (if caption `((tr nil (td nil ,@caption))))
     (cond
      (header
       (if footer
	   ;; header + body + footer
	   (if (= nheader nbody)
	       (if (= nbody nfooter)
		   `((tr nil (td nil (table nil
					    (tbody nil ,@header
						   ,@body ,@footer)))))
                 (nconc `((tr nil (td nil (table nil
                                                 (tbody nil ,@header
                                                        ,@body)))))
                        (if (= nfooter 1)
			    footer
			  `((tr nil (td nil (table
					     nil (tbody
						  nil ,@footer))))))))
	     (nconc `((tr nil (td nil (table nil (tbody
						  nil ,@header)))))
		    (if (= nbody nfooter)
                        `((tr nil (td nil (table
					   nil (tbody nil ,@body
						      ,@footer)))))
		      (nconc `((tr nil (td nil (table
                                                nil (tbody nil
							   ,@body)))))
			     (if (= nfooter 1)
                                 footer
			       `((tr nil (td nil (table
						  nil
						  (tbody
						   nil
						   ,@footer))))))))))
         ;; header + body
         (if (= nheader nbody)
	     `((tr nil (td nil (table nil (tbody nil ,@header
                                                 ,@body)))))
	   (if (= nheader 1)
	       `(,@header (tr nil (td nil (table
					   nil (tbody nil ,@body)))))
	     `((tr nil (td nil (table nil (tbody nil ,@header))))
	       (tr nil (td nil (table nil (tbody nil ,@body)))))))))
      (footer
       ;; body + footer
       (if (= nbody nfooter)
	   `((tr nil (td nil (table
			      nil (tbody nil ,@body ,@footer)))))
         (nconc `((tr nil (td nil (table nil (tbody nil ,@body)))))
                (if (= nfooter 1)
		    footer
		  `((tr nil (td nil (table
				     nil (tbody nil ,@footer)))))))))
      (caption
       `((tr nil (td nil (table nil (tbody nil ,@body))))))
      (body)))))