Last active
June 1, 2019 06:47
-
-
Save iporsut/e8f8ca88507e41a67cae5574ab0e4747 to your computer and use it in GitHub Desktop.
Elisp function calling to Ruby for escape and unescape HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun escape-html (start end) | |
(interactive "r") | |
(if (use-region-p) | |
(let ((regionp (buffer-substring start end))) | |
(delete-region start end) | |
(call-process-region regionp nil "ruby" nil t nil "-e" "# encoding: utf-8 | |
require 'cgi' | |
print CGI.escapeHTML(ARGF.read)")))) | |
(defun unescape-html (start end) | |
(interactive "r") | |
(if (use-region-p) | |
(let ((regionp (buffer-substring start end))) | |
(delete-region start end) | |
(call-process-region regionp nil "ruby" nil t nil "-e" "# encoding: utf-8 | |
require 'cgi' | |
print CGI.unescapeHTML(ARGF.read)")))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment