(Go to my E2 tool index)
E2 doesn't allow external links to be used, but ocassionally people have HTML document at hand with just a couple of links that they'd like to node (for example, a +5, Insightful Slashdot comment or 4.91 / 12 Kuro5hin comment, or something of slightly less rated by others but of equal worthiness in metaphysical sense).
This program takes a HTML document and "unlinks" it (adding footnote numbers), adding all links it found to the end of the document.
;;; This "Unlinks" a HTML document - it removes all hypertext anchors
;;; from the text, inserts superscript numbers, and creates a
;;; list of those links to the end of the document.
;;; Be sure to remove all those links from the document that you don't
;;; want to list in the end, because otherwise clearing the list up
;;; makes numbers go out of synch And That Isn't Fun.
;;; Not tested with links that go to multiple lines...
;;; Distributed under the Artistic Lisence.
;;; Written by Urpo Lankinen / Weyfour WWWWolf
;;; <firstname.lastname@example.org> <http://www.iki.fi/wwwwolf/>
;;; $Id: html-unlink.el,v 1.0 2001/04/26 17:40:06 wwwwolf Exp $
(defun html-links-to-footnotes-buffer (buffer)
"Remove all HTML links from buffer and insert them to the end of the
document as a list."
(interactive "bBuffer: ")
;; Replace all occurences of <a href="...">...</a>
;; Increment match counter
(setq foundlinks (+ foundlinks 1))
;; Append the URL to the link list
(list (match-string 1))))
;; Replace the string with stuph...
(format "\\2 <sup><small><small>%d</small></small></sup>" foundlinks)
(if (> foundlinks 0)
;; I know, using bare side effects is Naughty...
;; I wanted to use (insert (concat... )) but that didn't
;; work at all (said just that my string wasn't characterp. Silly.)
(insert (format "<li>%s\n" string)))
(message "Found %d links." foundlinks))
(error "No links found!")))))