Skip to content

Instantly share code, notes, and snippets.

@kuanyui
Last active January 2, 2016 07:29
Show Gist options
  • Save kuanyui/8270157 to your computer and use it in GitHub Desktop.
Save kuanyui/8270157 to your computer and use it in GitHub Desktop.
"Replace html entities. Example: (html-enetities-convert ">") => ">"
(defun html-entities-convert (string)
"Replace html entities.
Example:
(html-enetities-convert \"&gt\;\")
=> \">\""
(map 'array (lambda (x)
(if (string-match (aref x 0) string)
(setq string (replace-regexp-in-string (aref x 0) (aref x 1) string))
))
[
["'" "'"]
[" " ""]
["¡" "¡"]
["¢" "¢"]
["£" "£"]
["¤" "¤"]
["¥" "¥"]
["¦" "¦"]
["§" "§"]
["¨" "¨"]
["©" "©"]
["ª" "ª"]
["«" "«"]
["¬" "¬"]
["®" "®"]
["¯" "¯"]
["°" "°"]
["±" "±"]
["²" "²"]
["³" "³"]
["´" "´"]
["µ" "µ"]
["¶" "¶"]
["·" "·"]
["¸" "¸"]
["¹" "¹"]
["º" "º"]
["»" "»"]
["¼" "¼"]
["½" "½"]
["¾" "¾"]
["¿" "¿"]
["À" "À"]
["Á" "Á"]
["Â" "Â"]
["Ã" "Ã"]
["Ä" "Ä"]
["Å" "Å"]
["Æ" "Æ"]
["Ç" "Ç"]
["È" "È"]
["É" "É"]
["Ê" "Ê"]
["Ë" "Ë"]
["Ì" "Ì"]
["Í" "Í"]
["Î" "Î"]
["Ï" "Ï"]
["Ð" "Ð"]
["Ñ" "Ñ"]
["Ò" "Ò"]
["Ó" "Ó"]
["Ô" "Ô"]
["Õ" "Õ"]
["Ö" "Ö"]
["×" "×"]
["Ø" "Ø"]
["Ù" "Ù"]
["Ú" "Ú"]
["Û" "Û"]
["Ü" "Ü"]
["Ý" "Ý"]
["Þ" "Þ"]
["ß" "ß"]
["à" "à"]
["á" "á"]
["â" "â"]
["ã" "ã"]
["ä" "ä"]
["å" "å"]
["æ" "æ"]
["ç" "ç"]
["è" "è"]
["é" "é"]
["ê" "ê"]
["ë" "ë"]
["ì" "ì"]
["í" "í"]
["î" "î"]
["ï" "ï"]
["ð" "ð"]
["ñ" "ñ"]
["ò" "ò"]
["ó" "ó"]
["ô" "ô"]
["õ" "õ"]
["ö" "ö"]
["÷" "÷"]
["ø" "ø"]
["ù" "ù"]
["ú" "ú"]
["û" "û"]
["ü" "ü"]
["ý" "ý"]
["þ" "þ"]
["ÿ" "ÿ"]
["ƒ" "ƒ"]
["Α" "Α"]
["Β" "Β"]
["Γ" "Γ"]
["Δ" "Δ"]
["Ε" "Ε"]
["Ζ" "Ζ"]
["Η" "Η"]
["Θ" "Θ"]
["Ι" "Ι"]
["Κ" "Κ"]
["Λ" "Λ"]
["Μ" "Μ"]
["Ν" "Ν"]
["Ξ" "Ξ"]
["Ο" "Ο"]
["Π" "Π"]
["Ρ" "Ρ"]
["Σ" "Σ"]
["Τ" "Τ"]
["Υ" "Υ"]
["Φ" "Φ"]
["Χ" "Χ"]
["Ψ" "Ψ"]
["Ω" "Ω"]
["α" "α"]
["β" "β"]
["γ" "γ"]
["δ" "δ"]
["ε" "ε"]
["ζ" "ζ"]
["η" "η"]
["θ" "θ"]
["ι" "ι"]
["κ" "κ"]
["λ" "λ"]
["μ" "μ"]
["ν" "ν"]
["ξ" "ξ"]
["ο" "ο"]
["π" "π"]
["ρ" "ρ"]
["ς" "ς"]
["σ" "σ"]
["τ" "τ"]
["υ" "υ"]
["φ" "φ"]
["χ" "χ"]
["ψ" "ψ"]
["ω" "ω"]
["ϑ" "ϑ"]
["ϒ" "ϒ"]
["ϖ" "ϖ"]
["•" "•"]
["…" "…"]
["′" "′"]
["″" "″"]
["‾" "‾"]
["⁄" "⁄"]
["℘" "℘"]
["ℑ" "ℑ"]
["ℜ" "ℜ"]
["™" "™"]
["ℵ" "ℵ"]
["←" "←"]
["↑" "↑"]
["→" "→"]
["↓" "↓"]
["↔" "↔"]
["↵" "↵"]
["⇐" "⇐"]
["⇑" "⇑"]
["⇒" "⇒"]
["⇓" "⇓"]
["⇔" "⇔"]
["∀" "∀"]
["∂" "∂"]
["∃" "∃"]
["∅" "∅"]
["∇" "∇"]
["∈" "∈"]
["∉" "∉"]
["∋" "∋"]
["∏" "∏"]
["∑" "∑"]
["−" "−"]
["∗" "∗"]
["√" "√"]
["∝" "∝"]
["∞" "∞"]
["∠" "∠"]
["∧" "∧"]
["∨" "∨"]
["∩" "∩"]
["∪" "∪"]
["∫" "∫"]
["∴" "∴"]
["∼" "∼"]
["≅" "≅"]
["≈" "≈"]
["≠" "≠"]
["≡" "≡"]
["≤" "≤"]
["≥" "≥"]
["⊂" "⊂"]
["⊃" "⊃"]
["⊄" "⊄"]
["⊆" "⊆"]
["⊇" "⊇"]
["⊕" "⊕"]
["⊗" "⊗"]
["⊥" "⊥"]
["⋅" "⋅"]
["⌈" "⌈"]
["⌉" "⌉"]
["⌊" "⌊"]
["⌋" "⌋"]
["⟨" "〈"]
["⟩" "〉"]
["◊" "◊"]
["♠" "♠"]
["♣" "♣"]
["♥" "♥"]
["♦" "♦"]
[""" "\""]
["&" "&"]
["&lt;" "<"]
["&gt;" ">"]
["&OElig;" "Œ"]
["&oelig;" "œ"]
["&Scaron;" "Š"]
["&scaron;" "š"]
["&Yuml;" "Ÿ"]
["&circ;" "ˆ"]
["&tilde;" "˜"]
["&ensp;" ""]
["&emsp;" ""]
["&thinsp;" ""]
["&zwnj;" ""]
["&zwj;" ""]
["&lrm;" ""]
["&rlm;" ""]
["&ndash;" "–"]
["&mdash;" "—"]
["&lsquo;" "‘"]
["&rsquo;" "’"]
["&sbquo;" "‚"]
["&ldquo;" "“"]
["&rdquo;" "”"]
["&bdquo;" "„"]
["&dagger;" "†"]
["&Dagger;" "‡"]
["&permil;" "‰"]
["&lsaquo;" "‹"]
["&rsaquo;" "›"]
["&euro;" "€"]
]
)
string
)
(provide 'html-entities-convert)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment