* shr.el (shr-render-td): Use a cache for the table rendering function
to avoid getting an exponential rendering behaviour in nested tables.
+ (shr-insert): Rework the line-breaking algorithm.
2010-10-07 Katsumi Yamaoka <yamaoka@jpl.org>
column)
(when (and (string-match "\\`[ \t\n]" text)
(not (bolp)))
- (insert " ")
- (setq shr-state 'space))
+ (insert " "))
(dolist (elem (split-string text))
- (setq column (current-column))
- (when (> column 0)
- (cond
- ((and (or (not first)
- (eq shr-state 'space))
- (> (+ column (length elem) 1) shr-width))
- (insert "\n")
- (put-text-property (1- (point)) (point) 'shr-break t))
- ((not first)
- (insert " "))))
- (setq first nil)
(when (and (bolp)
(> shr-indentation 0))
(shr-indent))
;; starts.
(unless shr-start
(setq shr-start (point)))
- (insert elem))
- (setq shr-state nil)
- (when (and (string-match "[ \t\n]\\'" text)
- (not (bolp)))
- (insert " ")
- (setq shr-state 'space))))))
+ (insert elem)
+ (when (> (current-column) shr-width)
+ (if (not (search-backward " " (line-beginning-position) t))
+ (insert "\n")
+ (delete-char 1)
+ (insert "\n")
+ (put-text-property (1- (point)) (point) 'shr-break t)
+ (when (> shr-indentation 0)
+ (shr-indent))
+ (end-of-line)))
+ (insert " "))))))
(defun shr-ensure-newline ()
(unless (zerop (current-column))