| 1 | ;;; html2text.el --- a simple html to plain text converter |
| 2 | |
| 3 | ;; Copyright (C) 2002-2012 Free Software Foundation, Inc. |
| 4 | |
| 5 | ;; Author: Joakim Hove <hove@phys.ntnu.no> |
| 6 | |
| 7 | ;; This file is part of GNU Emacs. |
| 8 | |
| 9 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
| 10 | ;; it under the terms of the GNU General Public License as published by |
| 11 | ;; the Free Software Foundation, either version 3 of the License, or |
| 12 | ;; (at your option) any later version. |
| 13 | |
| 14 | ;; GNU Emacs is distributed in the hope that it will be useful, |
| 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | ;; GNU General Public License for more details. |
| 18 | |
| 19 | ;; You should have received a copy of the GNU General Public License |
| 20 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
| 21 | |
| 22 | ;;; Commentary: |
| 23 | |
| 24 | ;; These functions provide a simple way to wash/clean html infected |
| 25 | ;; mails. Definitely do not work in all cases, but some improvement |
| 26 | ;; in readability is generally obtained. Formatting is only done in |
| 27 | ;; the buffer, so the next time you enter the article it will be |
| 28 | ;; "re-htmlized". |
| 29 | ;; |
| 30 | ;; The main function is `html2text'. |
| 31 | |
| 32 | ;;; Code: |
| 33 | |
| 34 | ;; |
| 35 | ;; <Global variables> |
| 36 | ;; |
| 37 | |
| 38 | (eval-when-compile |
| 39 | (require 'cl)) |
| 40 | |
| 41 | (defvar html2text-format-single-element-list '(("hr" . html2text-clean-hr))) |
| 42 | |
| 43 | (defvar html2text-replace-list |
| 44 | '(("´" . "`") |
| 45 | ("&" . "&") |
| 46 | ("'" . "'") |
| 47 | ("¦" . "|") |
| 48 | ("¢" . "c") |
| 49 | ("ˆ" . "^") |
| 50 | ("©" . "(C)") |
| 51 | ("¤" . "(#)") |
| 52 | ("°" . "degree") |
| 53 | ("÷" . "/") |
| 54 | ("€" . "e") |
| 55 | ("½" . "1/2") |
| 56 | (">" . ">") |
| 57 | ("¿" . "?") |
| 58 | ("«" . "<<") |
| 59 | ("&ldquo" . "\"") |
| 60 | ("‹" . "(") |
| 61 | ("‘" . "`") |
| 62 | ("<" . "<") |
| 63 | ("—" . "--") |
| 64 | (" " . " ") |
| 65 | ("–" . "-") |
| 66 | ("‰" . "%%") |
| 67 | ("±" . "+-") |
| 68 |