Skip to content

Instantly share code, notes, and snippets.

@ussy
Created March 24, 2010 14:01
Show Gist options
  • Save ussy/342306 to your computer and use it in GitHub Desktop.
Save ussy/342306 to your computer and use it in GitHub Desktop.
(defun my-html-escape (start end)
(interactive "r")
(save-excursion
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(while (re-search-forward "<" nil t)
(replace-match "&lt;"))
(goto-char (point-min))
(while (re-search-forward ">" nil t)
(replace-match "&gt;"))
(while (re-search-forward "\"" nil t)
(replace-match "&quote;"))
(while (re-search-forward "&" nil t)
(replace-match "&amp;")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment