Emacs: HTML. URL to Link ๐
Here's a command turns a URL at the cursor position into a HTML link.
Put this in your Emacs Init File:
(defun xah-html-url-to-link (&optional Begin End) "Wrap anchor tag around word. No transformation is done to the word. For example, abc becomes <a href=\"abc\">abc</a> This command was named xah-html-url-linkify and then xah-html-word-to-anchor-tag URL `http://xahlee.info/emacs/emacs/wrap-url.html' Created: 2006-10-30 Version: 2025-04-05" (interactive) (let (xbeg xend xinput (xurlstops "^ ย \"\t\n'|[]{}<>ใใโโใใใใใใใใใใยซยปโนโบยทใ\\`")) (seq-setq (xbeg xend) (cond ((and Begin End) (list Begin End)) (t (if (region-active-p) (list (region-beginning) (region-end)) (list (save-excursion (skip-chars-backward xurlstops) (point)) (save-excursion (skip-chars-forward xurlstops) (point))))))) (setq xinput (buffer-substring-no-properties xbeg xend)) (delete-region xbeg xend) (insert (format "<a href=\"%s\">%s</a>" xinput xinput))))