116 |
;; <Utility functions> |
;; <Utility functions> |
117 |
;; |
;; |
118 |
|
|
|
(defun html2text-buffer-head () |
|
|
(if (string= mode-name "Article") |
|
|
(beginning-of-buffer) |
|
|
(beginning-of-buffer) |
|
|
) |
|
|
) |
|
119 |
|
|
120 |
(defun html2text-replace-string (from-string to-string p1 p2) |
(defun html2text-replace-string (from-string to-string p1 p2) |
121 |
(goto-char p1) |
(goto-char p1) |
426 |
"This _tries_ to fix up the paragraphs - this is done in quite a ad-hook |
"This _tries_ to fix up the paragraphs - this is done in quite a ad-hook |
427 |
fashion, quite close to pure guess-work. It does work in some cases though." |
fashion, quite close to pure guess-work. It does work in some cases though." |
428 |
(interactive) |
(interactive) |
429 |
(html2text-buffer-head) |
(goto-char (point-min)) |
430 |
(replace-regexp "^<br>$" "") |
(replace-regexp "^<br>$" "") |
431 |
;; Removing lonely <br> on a single line, if they are left intact we |
;; Removing lonely <br> on a single line, if they are left intact we |
432 |
;; dont have any paragraphs at all. |
;; dont have any paragraphs at all. |
433 |
(html2text-buffer-head) |
(goto-char (point-min)) |
434 |
(while (not (eobp)) |
(while (not (eobp)) |
435 |
(let ((p1 (point))) |
(let ((p1 (point))) |
436 |
(forward-paragraph 1) |
(forward-paragraph 1) |
456 |
See the documentation for that variable." |
See the documentation for that variable." |
457 |
(interactive) |
(interactive) |
458 |
(dolist (tag tag-list) |
(dolist (tag tag-list) |
459 |
(html2text-buffer-head) |
(goto-char (point-min)) |
460 |
(while (re-search-forward (format "\\(</?%s[^>]*>\\)" tag) (point-max) t) |
(while (re-search-forward (format "\\(</?%s[^>]*>\\)" tag) (point-max) t) |
461 |
(delete-region (match-beginning 0) (match-end 0))))) |
(delete-region (match-beginning 0) (match-end 0))))) |
462 |
|
|
466 |
(dolist (tag-and-function html2text-format-tag-list) |
(dolist (tag-and-function html2text-format-tag-list) |
467 |
(let ((tag (car tag-and-function)) |
(let ((tag (car tag-and-function)) |
468 |
(function (cdr tag-and-function))) |
(function (cdr tag-and-function))) |
469 |
(html2text-buffer-head) |
(goto-char (point-min)) |
470 |
(while (re-search-forward (format "\\(<%s\\( [^>]*\\)?>\\)" tag) |
(while (re-search-forward (format "\\(<%s\\( [^>]*\\)?>\\)" tag) |
471 |
(point-max) t) |
(point-max) t) |
472 |
(let ((p1) |
(let ((p1) |
491 |
"See the variable \"html2text-replace-list\" for documentation" |
"See the variable \"html2text-replace-list\" for documentation" |
492 |
(interactive) |
(interactive) |
493 |
(dolist (e html2text-replace-list) |
(dolist (e html2text-replace-list) |
494 |
(html2text-buffer-head) |
(goto-char (point-min)) |
495 |
(let ((old-string (car e)) |
(let ((old-string (car e)) |
496 |
(new-string (cdr e))) |
(new-string (cdr e))) |
497 |
(html2text-replace-string old-string new-string (point-min) (point-max)) |
(html2text-replace-string old-string new-string (point-min) (point-max)) |
505 |
(dolist (tag-and-function html2text-format-single-element-list) |
(dolist (tag-and-function html2text-format-single-element-list) |
506 |
(let ((tag (car tag-and-function)) |
(let ((tag (car tag-and-function)) |
507 |
(function (cdr tag-and-function))) |
(function (cdr tag-and-function))) |
508 |
(html2text-buffer-head) |
(goto-char (point-min)) |
509 |
(while (re-search-forward (format "\\(<%s\\( [^>]*\\)?>\\)" tag) |
(while (re-search-forward (format "\\(<%s\\( [^>]*\\)?>\\)" tag) |
510 |
(point-max) t) |
(point-max) t) |
511 |
(let ((p1) |
(let ((p1) |