/.emacs.d/el-get/nxhtml/nxhtml/html-quote.el

https://bitbucket.org/shuangxinyu/emacspack · Lisp · 71 lines · 16 code · 7 blank · 48 comment · 1 complexity · 1ac51e7ab770cfdf2936c21f2acd0771 MD5 · raw file

  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. (defcustom html-quote-html '((?< . "&lt;")
  47. (?& . "&amp;"))
  48. "*Alist of char -> entity mappings used to make the text html-safe."
  49. :group 'html-qoute
  50. :type '(alist :key-type character
  51. :value-type string))
  52. (defun html-quote-html-char (char)
  53. "Return CHAR as string if safe, otherwise its html entity."
  54. (or (cdr (assoc char html-quote-html))
  55. (char-to-string char)))
  56. (defun html-quote-html-string (str)
  57. "Return html escaped STR."
  58. (mapconcat 'html-quote-html-char
  59. (append str nil)
  60. ""))
  61. ;; (html-quote-html-string "is & < s")
  62. (provide 'html-quote)
  63. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  64. ;;; html-quote.el ends here