(defvar shr-folding-mode nil)
(defvar shr-state nil)
(defvar shr-start nil)
+(defvar shr-indentation 0)
(defvar shr-width 70)
(shr-descend sub)))))
(defun shr-tag-p (cont)
- (shr-ensure-newline)
- (insert "\n")
+ (shr-ensure-paragraph)
(shr-generic cont)
- (insert "\n"))
+ (unless (bobp)
+ (insert "\n")))
+
+(defun shr-ensure-paragraph ()
+ (unless (bobp)
+ (if (bolp)
+ (unless (eql (char-after (- (point) 2)) ?\n)
+ (insert "\n"))
+ (insert "\n\n"))))
(defun shr-tag-b (cont)
(shr-fontize-cont cont 'bold))
(defun shr-s (cont)
(shr-fontize-cont cont 'strikethru))
-(defun shr-fontize-cont (cont type)
+(defun shr-fontize-cont (cont &rest types)
(let (shr-start)
(shr-generic cont)
- (shr-add-font (or shr-start (point)) (point) type)))
+ (dolist (type types)
+ (shr-add-font (or shr-start (point)) (point) type))))
(defun shr-add-font (start end type)
(let ((overlay (make-overlay start end)))
(shr-ensure-newline)))
(defun shr-tag-blockquote (cont)
- (shr-tag-pre cont))
+ (let ((shr-indentation (+ shr-indentation 4)))
+ (shr-tag-pre cont)))
(defun shr-ensure-newline ()
(unless (zerop (current-column))
(if (> (+ column (length elem) 1) shr-width)
(insert "\n")
(insert " ")))
+ (when (and (bolp)
+ (plusp shr-indentation))
+ (insert (make-string shr-indentation ? )))
;; The shr-start is a special variable that is used to pass
;; upwards the first point in the buffer where the text really
;; starts.
(shr-ensure-newline)
(shr-generic cont))
+(defun shr-tag-h1 (cont)
+ (shr-heading cont 'bold 'underline))
+
+(defun shr-tag-h2 (cont)
+ (shr-heading cont 'bold))
+
+(defun shr-tag-h3 (cont)
+ (shr-heading cont 'italic))
+
+(defun shr-tag-h4 (cont)
+ (shr-heading cont))
+
+(defun shr-tag-h5 (cont)
+ (shr-heading cont))
+
+(defun shr-heading (cont &rest types)
+ (shr-ensure-paragraph)
+ (apply #'shr-fontize-cont cont types)
+ (shr-ensure-paragraph))
+
(provide 'shr)
;;; shr.el ends here