是否存在用于html转义的Emacs包?

时间:2014-06-06 15:06:17

标签: html emacs

示例:

<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>

是否存在在区域上执行此类替换的现有功能或包?

1 个答案:

答案 0 :(得分:1)

评论后编辑,谢谢。

在此处下载文件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))))))