From: Simon Wright <simon@pushface.org>
Subject: Those annoying HMTL entities from Google Groups
Date: Sun, 15 Jul 2012 17:13:05 +0100
Date: 2012-07-15T17:13:05+01:00 [thread overview]
Message-ID: <m2vchpuhny.fsf@nidhoggr.home> (raw)
You know how, of late, there have been a lot of HTML entities (for
example, ", ', > for ", ', and > respectively) in postings
from people who're using Google Groups? Well, I haven't worked out how
to translate them while reading, but if you're using Emacs you should be
able to translate them while replying using this - probably rubbish
- Elisp (which I haven't tidied up):
(defun replace-html-entities-region (start end)
"Replace “<” by “<”, etc. This works on the current region."
(interactive "r")
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(while (re-search-forward "&\\([^&;]*\\);" nil t)
(let ((e (match-string 1)))
(replace-match (replace--entity e) nil nil))
)
)
)
(defun replace--entity (e)
(cond
((equal e "amp") "&")
((equal e "apos") "'")
((equal e "gt") ">")
((equal e "lt") "<")
((equal e "quot") "\"")
((equal (substring e 0 1) "#")
(char-to-string (string-to-number (substring e 1))))
(t (concat "&" e ";"))
)
)
In the reply buffer,
C-x h M-x replace-html-entities-region
(you may need to do this more than once!)
next reply other threads:[~2012-07-15 16:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-15 16:13 Simon Wright [this message]
2012-07-17 10:41 ` Those annoying HMTL entities from Google Groups Stephen Leake
2012-07-17 13:13 ` Simon Wright
2012-07-20 16:15 ` Adam Beneschan
2012-07-21 0:06 ` Jerry
2012-07-21 0:18 ` Adam Beneschan
2012-07-21 9:52 ` Manuel Gomez
2012-07-21 15:32 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox