html - 是否有一个Emacs软件包用于html转义?

例:

<p>Um diese App verwenden zu können, benötigen Sie JavaScript.</p>

应替换为:
<p>Um diese App verwenden zu k&ouml;nnen, ben&ouml;tigen Sie JavaScript.</p>

是否有现有的功能或程序包可以在区域上执行这种替换?

最佳答案

评论后编辑,谢谢。

在此处下载文件html2uml.el:

http://bazaar.launchpad.net/~a-roehler/s-x-emacs-werkstatt/trunk/view/head:/html2uml.el

请在此处提交报告WRT错误或缺少实体:

https://bugs.launchpad.net/s-x-emacs-werkstatt

现在的代码:

(defvar ar-html2uml
  '(
    ("&nbsp;" " ")
    ("&iexcl;" "¡")
    ("&cent;" "¢")
    ("&pound;" "£")
    ("&curren;" "\x{00A4}")
    ("&yen;" "¥")
    ("&brvbar;" "\x{00A6}")
    ("&sect;" "§")
    ("&uml;" "\x{00A8}")
    ("&copy;" "©")
    ("&ordf;" "ª")
    ("&laquo;" "«")
    ("&not;" "¬")
    ("&shy;" "­")
    ("&reg;" "®")
    ("&macr;" "¯")
    ("&deg;" "°")
    ("&plusmn;" "±")
    ("&sup2;" "²")
    ("&sup3;" "³")
    ("&acute;" "\x{00B4}")
    ("&micro;" "µ")
    ("&para;" "¶")
    ("&middot;" "·")
    ("&cedil;" "\x{00B8}")
    ("&sup1;" "¹")
    ("&ordm;" "º")
    ("&raquo;" "»")
    ("&frac14;" "\x{00BC}")
    ("&frac12;" "\x{00BD}")
    ("&frac34;" "\x{00BE}")
    ("&iquest;" "¿")
    ("&Agrave;" "À")
    ("&Aacute;" "Á")
    ("&Acirc;" "Â")
    ("&Atilde;" "Ã")
    ("&Auml;" "Ä")
    ("&Aring;" "Å")
    ("&AElig;" "Æ")
    ("&Ccedil;" "Ç")
    ("&Egrave;" "È")
    ("&Eacute;" "É")
    ("&Ecirc;" "Ê")
    ("&Euml;" "Ë")
    ("&Igrave;" "Ì")
    ("&Iacute;" "Í")
    ("&Icirc;" "Î")
    ("&Iuml;" "Ï")
    ("&ETH;" "Ð")
    ("&Ntilde;" "Ñ")
    ("&Ograve;" "Ò")
    ("&Oacute;" "Ó")
    ("&Ocirc;" "Ô")
    ("&Otilde;" "Õ")
    ("&Ouml;" "Ö")
    ("&times;" "×")
    ("&Oslash;" "Ø")
    ("&Ugrave;" "Ù")
    ("&Uacute;" "Ú")
    ("&Ucirc;" "Û")
    ("&Uuml;" "Ü")
    ("&Yacute;" "Ý")
    ("&THORN;" "Þ")
    ("&szlig;" "ß")
    ("&agrave;" "à")
    ("&aacute;" "á")
    ("&acirc;" "â")
    ("&atilde;" "ã")
    ("&auml;" "ä")
    ("&aring;" "å")
    ("&aelig;" "æ")
    ("&ccedil;" "ç")
    ("&egrave;" "è")
    ("&eacute;" "é")
    ("&ecirc;" "ê")
    ("&euml;" "ë")
    ("&igrave;" "ì")
    ("&iacute;" "í")
    ("&icirc;" "î")
    ("&iuml;" "ï")
    ("&eth;" "ð")
    ("&ntilde;" "ñ")
    ("&ograve;" "ò")
    ("&oacute;" "ó")
    ("&ocirc;" "ô")
    ("&otilde;" "õ")
    ("&ouml;" "ö")
    ("\&Ouml;" "Ö")
    ("&divide;" "÷")
    ("&oslash;" "ø")
    ("&ugrave;" "ù")
    ("&uacute;" "ú")
    ("&ucirc;" "û")
    ("&uuml;" "ü")
    ("&yacute;" "ý")
    ("&thorn;" "þ")
    ("&yuml;" "ÿ")
    ))

(defun ar-uml2html ()
  "Translate chars into html entities"
  (interactive "*")
  (let ((liste ar-html2uml)
        case-fold-search erg)
    (dolist (ele liste)
      (goto-char (point-min))
      (while (search-forward (cadr ele) nil t 1)
        (setq erg (car ele))
        ;; Replacing with code starting from & upcases
        ;; Emacs bug?
        (replace-match "")
        (insert erg)))))

(defun ar-html2uml ()
  "Translate html entities into text"
  (interactive "*")
  (let ((liste ar-html2uml))
    (dolist (ele liste)
      (goto-char (point-min))
      (while (search-forward (car ele) nil t 1)
        (replace-match "")
        (insert (cadr ele))))))