* shr.el (shr-insert-table): Respect border-collapse: collapse.
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Mon, 17 Jun 2013 20:29:01 +0000 (22:29 +0200)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Mon, 17 Jun 2013 20:29:01 +0000 (22:29 +0200)
lisp/ChangeLog
lisp/shr.el

index f3ebfe9..a4e2db3 100644 (file)
@@ -1,5 +1,7 @@
 2013-06-17  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * shr.el (shr-insert-table): Respect border-collapse: collapse.
+
        * eww.el (eww-convert-widgets): Put `help-echo' on input fields so that
        we can navigate to them.
 
index 25fa4f3..92e6250 100644 (file)
@@ -350,7 +350,7 @@ size, and full-buffer size."
        (shr-stylesheet shr-stylesheet)
        (start (point)))
     (when style
-      (if (string-match "color\\|display" style)
+      (if (string-match "color\\|display\\|border-collapse" style)
          (setq shr-stylesheet (nconc (shr-parse-style style)
                                      shr-stylesheet))
        (setq style nil)))
@@ -1317,35 +1317,40 @@ ones, in case fg and bg are nil."
     (nreverse result)))
 
 (defun shr-insert-table (table widths)
-  (shr-insert-table-ruler widths)
-  (dolist (row table)
-    (let ((start (point))
-         (height (let ((max 0))
-                   (dolist (column row)
-                     (setq max (max max (cadr column))))
-                   max)))
-      (dotimes (i height)
-       (shr-indent)
-       (insert shr-table-vertical-line "\n"))
-      (dolist (column row)
-       (goto-char start)
-       (let ((lines (nth 2 column)))
-         (dolist (line lines)
-           (end-of-line)
-           (insert line shr-table-vertical-line)
-           (forward-line 1))
-         ;; Add blank lines at padding at the bottom of the TD,
-         ;; possibly.
-         (dotimes (i (- height (length lines)))
-           (end-of-line)
-           (let ((start (point)))
-             (insert (make-string (string-width (car lines)) ? )
-                     shr-table-vertical-line)
-             (when (nth 4 column)
-               (shr-add-font start (1- (point))
-                             (list :background (nth 4 column)))))
-           (forward-line 1)))))
-    (shr-insert-table-ruler widths)))
+  (let* ((collapse (equal (cdr (assq 'border-collapse shr-stylesheet))
+                         "collapse"))
+        (shr-table-vertical-line (if collapse "" shr-table-vertical-line)))
+    (unless collapse
+      (shr-insert-table-ruler widths))
+    (dolist (row table)
+      (let ((start (point))
+           (height (let ((max 0))
+                     (dolist (column row)
+                       (setq max (max max (cadr column))))
+                     max)))
+       (dotimes (i height)
+         (shr-indent)
+         (insert shr-table-vertical-line "\n"))
+       (dolist (column row)
+         (goto-char start)
+         (let ((lines (nth 2 column)))
+           (dolist (line lines)
+             (end-of-line)
+             (insert line shr-table-vertical-line)
+             (forward-line 1))
+           ;; Add blank lines at padding at the bottom of the TD,
+           ;; possibly.
+           (dotimes (i (- height (length lines)))
+             (end-of-line)
+             (let ((start (point)))
+               (insert (make-string (string-width (car lines)) ? )
+                       shr-table-vertical-line)
+               (when (nth 4 column)
+                 (shr-add-font start (1- (point))
+                               (list :background (nth 4 column)))))
+             (forward-line 1)))))
+      (unless collapse
+       (shr-insert-table-ruler widths)))))
 
 (defun shr-insert-table-ruler (widths)
   (when (and (bolp)