initial commit
[emacs-init.git] / nxhtml / nxhtml / html-quote.el
1 ;;; html-quote.el --- Simple quoting of html characters
2 ;;
3 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
4 ;; Created: Sun Dec 30 12:55:38 2007
5 ;; Version:
6 ;; Last-Updated: Sun Dec 30 12:59:43 2007 (3600 +0100)
7 ;; URL:
8 ;; Keywords:
9 ;; Compatibility:
10 ;;
11 ;; Features that might be required by this library:
12 ;;
13 ;;   None
14 ;;
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16 ;;
17 ;;; Commentary:
18 ;;
19 ;; Just simple quoting of & < > etc
20 ;;
21 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22 ;;
23 ;;; Change log:
24 ;;
25 ;;
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 ;;
28 ;; This program is free software; you can redistribute it and/or
29 ;; modify it under the terms of the GNU General Public License as
30 ;; published by the Free Software Foundation; either version 2, or
31 ;; (at your option) any later version.
32 ;;
33 ;; This program is distributed in the hope that it will be useful,
34 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
35 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
36 ;; General Public License for more details.
37 ;;
38 ;; You should have received a copy of the GNU General Public License
39 ;; along with this program; see the file COPYING.  If not, write to
40 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
41 ;; Floor, Boston, MA 02110-1301, USA.
42 ;;
43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
44 ;;
45 ;;; Code:
46
47
48 (defcustom html-quote-html '((?<   . "&lt;")
49                              (?&   . "&amp;"))
50   "*Alist of char -> entity mappings used to make the text html-safe."
51   :group 'html-qoute
52   :type  '(alist :key-type character
53                  :value-type string))
54
55
56 (defun html-quote-html-char (char)
57   "Return CHAR as string if safe, otherwise its html entity."
58   (or (cdr (assoc char html-quote-html))
59       (char-to-string char)))
60
61 (defun html-quote-html-string (str)
62   "Return html escaped STR."
63   (mapconcat 'html-quote-html-char
64              (append str nil)
65              ""))
66
67 ;; (html-quote-html-string "is & < s")
68
69 (provide 'html-quote)
70 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
71 ;;; html-quote.el ends here