From 76b6b2b0a969b427bb993110f6d8c05060cf5f64 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Mon, 4 Oct 2010 18:11:45 +0200 Subject: [PATCH 1/1] (shr-make-table): Tweak table generation. --- lisp/ChangeLog | 1 + lisp/shr.el | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6a967af31..858b8cdb9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -6,6 +6,7 @@ (shr-tag-li): Get
  • indentation right. (shr-tag-li): Get
  • indentation even righter. (shr-tag-blockquote): Ensure paragraph start. + (shr-make-table): Tweak table generation. * shr.el: Implement table rendering. diff --git a/lisp/shr.el b/lisp/shr.el index 1724ba2bd..bacb9d9ee 100644 --- a/lisp/shr.el +++ b/lisp/shr.el @@ -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)) -- 2.25.1