(setq next (nth 2 tmp-list))
(setq index 1)
- (if (not (string-match "=" prev))
- (progn
- (if (not (string= (substring this 0 1) "="))
- (setq attr-list (cons (list prev nil) attr-list))
- )
- )
- )
+ (unless (string-match "=" prev)
+ (unless (string= (substring this 0 1) "=")
+ (setq attr-list (cons (list prev nil) attr-list))))
(while (< index (1- (length tmp-list)))
(if (not (string-match "=" this))
(if (not (or (string= (substring next 0 1) "=")
(string= (substring prev -1) "=")))
- (setq attr-list (cons (list this nil) attr-list))
- )
- )
+ (setq attr-list (cons (list this nil) attr-list))))
(setq index (1+ index))
(setq prev this)
(setq this next)
- (setq next (nth (1+ index) tmp-list))
- )
+ (setq next (nth (1+ index) tmp-list)))
- (if this
- (progn
- (if (not (string-match "=" this))
- (progn
- (if (not (string= (substring prev -1) "="))
- (setq attr-list (cons (list this nil) attr-list))
- )
- )
- )
- )
- )
- attr-list ;; return - value
- )
- )
+ (when this
+ (unless (string-match "=" this)
+ (unless (string= (substring prev -1) "=")
+ (setq attr-list (cons (list this nil) attr-list)))))
+ attr-list)) ;; return - value
+
;;
;; </Functions related to attributes>
(let ((has-br-line)
(refill-start)
(refill-stop))
- (if (re-search-forward "<br>$" p2 t)
- (setq has-br-line t)
- )
- (if has-br-line
- (progn
- (goto-char p1)
- (if (re-search-forward ".+[^<][^b][^r][^>]$" p2 t)
- (progn
- (beginning-of-line)
- (setq refill-start (point))
- (goto-char p2)
- (re-search-backward ".+[^<][^b][^r][^>]$" refill-start t)
- (next-line 1)
- (end-of-line)
- ;; refill-stop should ideally be adjusted to
- ;; accomodate the "<br>" strings which are removed
- ;; between refill-start and refill-stop. Can simply
- ;; be returned from my-replace-string
- (setq refill-stop (+ (point)
- (html2text-replace-string
- "<br>" ""
- refill-start (point))))
- ;; (message "Point = %s refill-stop = %s" (point) refill-stop)
- ;; (sleep-for 4)
- (fill-region refill-start refill-stop)
- )
- )
- )
- )
- )
- (html2text-replace-string "<br>" "" p1 p2)
- )
+ (when (re-search-forward "<br>$" p2 t)
+ (setq has-br-line t))
+ (when has-br-line
+ (goto-char p1)
+ (when (re-search-forward ".+[^<][^b][^r][^>]$" p2 t)
+ (beginning-of-line)
+ (setq refill-start (point))
+ (goto-char p2)
+ (re-search-backward ".+[^<][^b][^r][^>]$" refill-start t)
+ (next-line 1)
+ (end-of-line)
+ ;; refill-stop should ideally be adjusted to
+ ;; accomodate the "<br>" strings which are removed
+ ;; between refill-start and refill-stop. Can simply
+ ;; be returned from my-replace-string
+ (setq refill-stop (+ (point)
+ (html2text-replace-string
+ "<br>" ""
+ refill-start (point))))
+ ;; (message "Point = %s refill-stop = %s" (point) refill-stop)
+ ;; (sleep-for 4)
+ (fill-region refill-start refill-stop))))
+ (html2text-replace-string "<br>" "" p1 p2))
;;
;; This one is interactive ...
(interactive)
(dolist (tag tag-list)
(html2text-buffer-head)
- (while (re-search-forward (format "\\(</?%s[^>]*>\\)" tag) (point-max) t)
- (let ((p1 (point)))
- (search-backward "<")
- (delete-region (point) p1)))))
+ (while (re-search-forward (format "</?%s[^>]*>" tag) (point-max) t)
+ (delete-region (match-beginning 0) (match-end 0)))))
(defun html2text-format-tags ()
"See the variable \"html2text-format-tag-list\" for documentation"
(let ((tag (car tag-and-function))
(function (cdr tag-and-function)))
(html2text-buffer-head)
- (while (re-search-forward (format "\\(<%s\\( [^>]*\\)?>\\)" tag)
+ (while (re-search-forward (format "<%s\\( [^>]*\\)?>" tag)
(point-max) t)
(let ((p1)
(p2 (point))
(p3) (p4)
- (attr (match-string 1)))
+ (attr (match-string 0)))
(search-backward "<" (point-min) t)
(setq p1 (point))
(re-search-forward (format "</%s>" tag) (point-max) t)
(let ((tag (car tag-and-function))
(function (cdr tag-and-function)))
(html2text-buffer-head)
- (while (re-search-forward (format "\\(<%s\\( [^>]*\\)?>\\)" tag)
+ (while (re-search-forward (format "<%s\\( [^>]*\\)?>" tag)
(point-max) t)
(let ((p1)
(p2 (point)))