[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 53822ba: shr table header/footer fixes
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master 53822ba: shr table header/footer fixes |
Date: |
Sun, 28 Dec 2014 14:06:15 +0000 |
branch: master
commit 53822badf47960e9341dd31e379affe86d3a7165
Author: Ivan Shmakov <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
shr table header/footer fixes
Fixes: debbugs:19444
* lisp/net/shr.el (shr-tag-table): Fix handling of tbody/header/footer
elements in tables.
---
lisp/ChangeLog | 3 ++
lisp/net/shr.el | 101 +++++++++++++++++++++++++++++++++----------------------
2 files changed, 64 insertions(+), 40 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4f0f9ba..193e0c0 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
2014-12-28 Ivan Shmakov <address@hidden>
+ * net/shr.el (shr-tag-table): Fix handling of tbody/header/footer
+ elements in tables (bug#19444).
+
* net/eww.el (eww-handle-link): Fix typo in "up" rel handling
(bug#19445).
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 387bb02..26bb292 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1439,10 +1439,11 @@ The preference is a float determined from
`shr-prefer-media-type'."
(defun shr-tag-table (dom)
(shr-ensure-paragraph)
- (let* ((caption (dom-child-by-tag dom 'caption))
- (header (dom-child-by-tag dom 'thead))
- (body (or (dom-child-by-tag dom 'tbody) dom))
- (footer (dom-child-by-tag dom 'tfoot))
+ (let* ((caption (dom-children (dom-child-by-tag dom 'caption)))
+ (header (dom-non-text-children (dom-child-by-tag dom 'thead)))
+ (body (dom-non-text-children (or (dom-child-by-tag dom 'tbody)
+ dom)))
+ (footer (dom-non-text-children (dom-child-by-tag dom 'tfoot)))
(bgcolor (dom-attr dom 'bgcolor))
(start (point))
(shr-stylesheet (nconc (list (cons 'background-color bgcolor))
@@ -1461,42 +1462,62 @@ The preference is a float determined from
`shr-prefer-media-type'."
;; It's a real table, so render it.
(shr-tag-table-1
(nconc
- (if caption `((tr (td ,@caption))))
- (if header
- (if footer
- ;; header + body + footer
- (if (= nheader nbody)
- (if (= nbody nfooter)
- `((tr (td (table (tbody ,@header ,@body ,@footer)))))
- (nconc `((tr (td (table (tbody ,@header ,@body)))))
- (if (= nfooter 1)
- footer
- `((tr (td (table (tbody ,@footer))))))))
- (nconc `((tr (td (table (tbody ,@header)))))
- (if (= nbody nfooter)
- `((tr (td (table (tbody ,@body ,@footer)))))
- (nconc `((tr (td (table (tbody ,@body)))))
- (if (= nfooter 1)
- footer
- `((tr (td (table (tbody ,@footer))))))))))
- ;; header + body
- (if (= nheader nbody)
- `((tr (td (table (tbody ,@header ,@body)))))
- (if (= nheader 1)
- `(,@header (tr (td (table (tbody ,@body)))))
- `((tr (td (table (tbody ,@header))))
- (tr (td (table (tbody ,@body))))))))
- (if footer
- ;; body + footer
- (if (= nbody nfooter)
- `((tr (td (table (tbody ,@body ,@footer)))))
- (nconc `((tr (td (table (tbody ,@body)))))
- (if (= nfooter 1)
- footer
- `((tr (td (table (tbody ,@footer))))))))
- (if caption
- `((tr (td (table (tbody ,@body)))))
- body))))))
+ (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)))))
(when bgcolor
(shr-colorize-region start (point) (cdr (assq 'color shr-stylesheet))
bgcolor))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 53822ba: shr table header/footer fixes,
Lars Ingebrigtsen <=