comp.lang.ada
 help / color / mirror / Atom feed
* Those annoying HMTL entities from Google Groups
@ 2012-07-15 16:13 Simon Wright
  2012-07-17 10:41 ` Stephen Leake
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Simon Wright @ 2012-07-15 16:13 UTC (permalink / 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 “&lt;” 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!)



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-07-26 22:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-15 16:13 Those annoying HMTL entities from Google Groups Simon Wright
2012-07-17 10:41 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox