Skip to content

Instantly share code, notes, and snippets.

@akr4
Created May 1, 2013 18:44
Show Gist options
  • Save akr4/5497337 to your computer and use it in GitHub Desktop.
Save akr4/5497337 to your computer and use it in GitHub Desktop.
HTML escape & unescape
(defun unhtml (start end)
(interactive "r")
(save-excursion
(save-restriction
(replace-string "&" "&" nil start end)
(replace-string "<" "&lt;" nil start end)
(replace-string ">" "&gt;" nil start end))))
(defun html (start end)
(interactive "r")
(save-excursion
(save-restriction
(replace-string "&lt;" "<" nil start end)
(replace-string "&gt;" ">" nil start end)
(replace-string "&amp;" "&" nil start end))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment