Xah Talk Show 2022-09-21 Emacs Lisp Coding, Write Command to Demote HTML Headers
(defun xah-html-demote-header-h2h3h4h5 ()
"Demote HTML headers in whole buffer.
except h1. others, h2 becomes h3, etc. And h6 remains the same.
Version 2022-09-21"
(interactive)
(let ((case-fold-search nil))
(save-excursion
(progn
(goto-char (point-min))
(while (search-forward "<h5>" nil t)
(replace-match "<h6>"))
(goto-char (point-min))
(while (search-forward "</h5>" nil t)
(replace-match "</h6>")))
(progn
(goto-char (point-min))
(while (search-forward "<h4>" nil t)
(replace-match "<h5>"))
(goto-char (point-min))
(while (search-forward "</h4>" nil t)
(replace-match "</h5>")))
(progn
(goto-char (point-min))
(while (search-forward "<h3>" nil t)
(replace-match "<h4>"))
(goto-char (point-min))
(while (search-forward "</h3>" nil t)
(replace-match "</h4>")))
(progn
(goto-char (point-min))
(while (search-forward "<h2>" nil t)
(replace-match "<h3>"))
(goto-char (point-min))
(while (search-forward "</h2>" nil t)
(replace-match "</h3>"))))))