aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatsumi Yamaoka2010-10-20 07:31:25 +0000
committerKatsumi Yamaoka2010-10-20 07:31:25 +0000
commit6c7693116bd40663a3c2c05d652de3c8b51b5cf3 (patch)
tree4d9f4677bc44d3fb52df55f7718b8cf4954d0e73
parentdaabcfb9c651a087a2fe02e2d42947297c3cdf39 (diff)
downloademacs-6c7693116bd40663a3c2c05d652de3c8b51b5cf3.tar.gz
emacs-6c7693116bd40663a3c2c05d652de3c8b51b5cf3.zip
shr.el: (shr-tag-table): Support caption, thead, and tfoot.
-rw-r--r--lisp/gnus/ChangeLog2
-rw-r--r--lisp/gnus/shr.el53
2 files changed, 53 insertions, 2 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 9194c70be45..11244224452 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -2,6 +2,8 @@
2 2
3 * shr.el (shr-find-fill-point): Shorten line if the preceding char is 3 * shr.el (shr-find-fill-point): Shorten line if the preceding char is
4 kinsoku-eol regardless of shr-kinsoku-shorten. 4 kinsoku-eol regardless of shr-kinsoku-shorten.
5 (shr-tag-table-1): Rename from shr-tag-table; make it a subroutine.
6 (shr-tag-table): Support caption, thead, and tfoot.
5 7
62010-10-19 Lars Magne Ingebrigtsen <larsi@gnus.org> 82010-10-19 Lars Magne Ingebrigtsen <larsi@gnus.org>
7 9
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el
index d7a5fb33f66..9183e985fe6 100644
--- a/lisp/gnus/shr.el
+++ b/lisp/gnus/shr.el
@@ -593,8 +593,7 @@ Return a string with image data."
593;; main buffer). Now we know how much space each TD really takes, so 593;; main buffer). Now we know how much space each TD really takes, so
594;; we then render everything again with the new widths, and finally 594;; we then render everything again with the new widths, and finally
595;; insert all these boxes into the main buffer. 595;; insert all these boxes into the main buffer.
596(defun shr-tag-table (cont) 596(defun shr-tag-table-1 (cont)
597 (shr-ensure-paragraph)
598 (setq cont (or (cdr (assq 'tbody cont)) 597 (setq cont (or (cdr (assq 'tbody cont))
599 cont)) 598 cont))
600 (let* ((shr-inhibit-images t) 599 (let* ((shr-inhibit-images t)
@@ -622,6 +621,56 @@ Return a string with image data."
622 (dolist (elem (shr-find-elements cont 'img)) 621 (dolist (elem (shr-find-elements cont 'img))
623 (shr-tag-img (cdr elem)))) 622 (shr-tag-img (cdr elem))))
624 623
624(defun shr-tag-table (cont)
625 (shr-ensure-paragraph)
626 (let* ((caption (cdr (assq 'caption cont)))
627 (header (cdr (assq 'thead cont)))
628 (body (or (cdr (assq 'tbody cont)) cont))
629 (footer (cdr (assq 'tfoot cont)))
630 (nheader (if header (shr-max-columns header)))
631 (nbody (if body (shr-max-columns body)))
632 (nfooter (if footer (shr-max-columns footer))))
633 (shr-tag-table-1
634 (nconc
635 (if caption `((tr (td ,@caption))))
636 (if header
637 (if footer
638 ;; header + body + footer
639 (if (= nheader nbody)
640 (if (= nbody nfooter)
641 `((tr (td (table (tbody ,@header ,@body ,@footer)))))
642 (if (= nfooter 1)
643 `((tr (td (table (tbody ,@header ,@body))))
644 ,@footer)
645 `((tr (td (table (tbody ,@header ,@body))))
646 (tr (td (table (tbody ,@footer)))))))
647 (if (= nbody nfooter)
648 `((tr (td (table (tbody ,@header))))
649 (tr (td (table (tbody ,@body ,@footer)))))
650 (if (= nfooter 1)
651 `((tr (td (table (tbody ,@header))))
652 (tr (td (table (tbody ,@body))))
653 ,@footer)
654 `((tr (td (table (tbody ,@header))))
655 (tr (td (table (tbody ,@body))))
656 (tr (td (table (tbody ,@footer))))))))
657 ;; header + body
658 (if (= nheader nbody)
659 `((tr (td (table (tbody ,@header ,@body)))))
660 (if (= nheader 1)
661 `(,@header (tr (td (table (tbody ,@body)))))
662 `((tr (td (table (tbody ,@header))))
663 (tr (td (table (tbody ,@body))))))))
664 (if footer
665 ;; body + footer
666 (if (= nbody nfooter)
667 `((tr (td (table (tbody ,@body ,@footer)))))
668 (if (= nfooter 1)
669 `((tr (td (table (tbody ,@body)))) ,@footer)
670 `((tr (td (table (tbody ,@body))))
671 (tr (td (table (tbody ,@footer)))))))
672 body))))))
673
625(defun shr-find-elements (cont type) 674(defun shr-find-elements (cont type)
626 (let (result) 675 (let (result)
627 (dolist (elem cont) 676 (dolist (elem cont)