(shr-make-table): Tweak table generation.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Mon, 4 Oct 2010 16:11:45 +0000 (18:11 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Mon, 4 Oct 2010 16:11:45 +0000 (18:11 +0200)
lisp/ChangeLog
lisp/shr.el

index 6a967af..858b8cd 100644 (file)
@@ -6,6 +6,7 @@
        (shr-tag-li): Get <li> indentation right.
        (shr-tag-li): Get <li> indentation even righter.
        (shr-tag-blockquote): Ensure paragraph start.
+       (shr-make-table): Tweak table generation.
 
        * shr.el: Implement table rendering.
 
index 1724ba2..bacb9d9 100644 (file)
@@ -354,10 +354,18 @@ Return a string with image data."
        (insert "|\n"))
       (dolist (column row)
        (goto-char start)
-       (end-of-line)
-       (dolist (line (split-string (nth 2 column) "\n"))
-         (insert line "|")
-         (forward-line 1))))
+       (let ((lines (split-string (nth 2 column) "\n")))
+         (dolist (line lines)
+           (when (> (length line) 0)
+             (end-of-line)
+             (insert line "|")
+             (forward-line 1)))
+         ;; Add blank lines at padding at the bottom of the TD,
+         ;; possibly.
+         (dotimes (i (- height (length lines)))
+           (end-of-line)
+           (insert (make-string (length (car lines)) ? ) "|")
+           (forward-line 1)))))
     (shr-insert-table-ruler widths)))
 
 (defun shr-insert-table-ruler (widths)
@@ -395,6 +403,8 @@ Return a string with image data."
   (with-temp-buffer
     (let ((shr-width width))
       (shr-generic cont))
+    (while (re-search-backward "\n *$" nil t)
+      (delete-region (match-beginning 0) (match-end 0)))
     (goto-char (point-min))
     (let ((max 0))
       (while (not (eobp))