Function: shr-max-columns

shr-max-columns is a byte-compiled function defined in shr.el.gz.

Signature

(shr-max-columns DOM)

Source Code

;; Defined in /usr/src/emacs/lisp/net/shr.el.gz
(defun shr-max-columns (dom)
  (let ((max 0)
        (this 0)
        (rowspans nil))
    (dolist (row (dom-children dom))
      (when (and (not (stringp row))
		 (eq (dom-tag row) 'tr))
        (setq this 0)
        (dolist (column (dom-children row))
          (when (and (not (stringp column))
                     (memq (dom-tag column) '(td th)))
            (setq this (+ 1 this (length rowspans)))
            ;; We have a rowspan, which we emulate later in rendering
            ;; by adding an extra column to the following rows.
            (when-let* ((span (dom-attr column 'rowspan)))
              (push (string-to-number span) rowspans))))
	(setq max (max max this)))
      ;; Count down the rowspans in effect.
      (let ((new nil))
        (dolist (span rowspans)
          (when (> span 1)
            (push (1- span) new)))
        (setq rowspans new)))
    max))