Re: html-mode.el update

Dan Connolly (connolly@pixel.convex.com)
Wed, 18 Nov 92 22:54:10 CST


Here's a patch to add a function to fix all the existing
HREFs in an HTML file so they'll have quotes around them.

Dan

*** /mnt/connolly/foo Wed Nov 18 22:51:50 1992
--- html-mode.el Wed Nov 18 22:50:32 1992
***************
*** 517,522 ****
--- 517,543 ----
(setq html-link-counter (1+ html-link-counter))
(replace-string-in-buffer start (1- end)
(format "%d" html-link-counter))))))))
+
+ (defun html-quote-hrefs ()
+ "Insert quotes around all HREF attribute value literals.
+
+ This remedies the problem with old html files that can't be
+ processed by SGML parsers. That is, changes
+ <A HREF=foo> to <A HREF="foo">.
+
+ By Dan Connolly, so don't yell at Mark if it breaks."
+ (interactive)
+ (save-excursion
+ (goto-char (point-min))
+ (setq html-link-counter 0)
+ (while (re-search-forward "<[aA][ \t\n]+\\([nN][aA][mM][eE]=[a-zA-Z0-9]+[ \t\n]+\\)?[hH][rR][eE][fF]=" (point-max) t)
+ (cond ((null (looking-at "\""))
+ (insert "\"")
+ (re-search-forward "[ \t\n>]" (point-max) t)
+ (forward-char -1)
+ (insert "\"")
+ ))
+ ) ) )

;;; ------------------------------- html-mode --------------------------------