Emacs: HTML, Wrap Paragraph Tags š
Here's a command to wrap a āpā tag around current text block or selection.
(defun xah-html-blocks-to-paragraph () "Add p tag to current block or selection. If there is a selection, wrap p around each block. After this command is called, press `xah-repeat-key' to repeat it. URL `http://xahlee.info/emacs/emacs/emacs_html_wrap_tags.html' Version: 2019-06-21 2021-09-11 2022-03-22" (interactive) (let* ((xbds (xah-get-bounds-of-thing-or-region 'block)) (xp1 (car xbds)) (xp2 (cdr xbds))) (save-restriction (narrow-to-region xp1 xp2) (goto-char (point-min)) (insert "<p>\n") (goto-char (point-min)) (while (re-search-forward "\n\n+" nil t) (replace-match "</p>\n\n<p>" t t)) (goto-char (point-max)) (insert "\n</p>")) (skip-chars-forward "\n")) (set-transient-map (let ((xkmap (make-sparse-keymap))) (define-key xkmap (or xah-repeat-key (kbd "DEL")) this-command) xkmap)))
requires package Emacs: xah-get-thing.el š¦
This is part of Emacs: Xah HTML Mode š¦