Advertisement
Guest User

htmlegalize evolved

a guest
May 26th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. (defun roadie-htmlegalize-region (b e)
  2. "Replace \"&\", \"<\", and \">\" with their HTML escape codes, from B to E.
  3. Is there anything else that should be done to escape HTML?"
  4. (interactive "r")
  5. (save-excursion
  6. (let ((em (copy-marker e)))
  7. (goto-char b)
  8. (while (search-forward " & " em t)
  9. (replace-match " &amp; " nil t))
  10. (goto-char b)
  11. (while (search-forward " < " em t)
  12. (replace-match " &lt; " nil t))
  13. (goto-char b)
  14. (while (search-forward " > " em t)
  15. (replace-match " &gt; " nil t))
  16. (goto-char b)
  17. (while (search-forward "ä" em t)
  18. (replace-match "&auml;" nil t))
  19. (goto-char b)
  20. (while (search-forward "ö" em t)
  21. (replace-match "&ouml;" nil t))
  22. (goto-char b)
  23. (while (search-forward "ü" em t)
  24. (replace-match "&uuml;" nil t))
  25. (goto-char b)
  26. (while (search-forward "Ä" em t)
  27. (replace-match "&Auml;" nil t))
  28. (goto-char b)
  29. (while (search-forward "Ö" em t)
  30. (replace-match "&Ouml;" nil t))
  31. (goto-char b)
  32. (while (search-forward "Ü" em t)
  33. (replace-match "&Uuml;" nil t))
  34. (goto-char b)
  35. (while (search-forward "ß" em t)
  36. (replace-match "&szlig;" nil t))
  37. )))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement