Xah Talk Show 2024-02-27 Ep540 Emacs Lisp Coding, Hand Pain, Dark Theme Fad, Solarize Disease

(defun xah-html-add-section-to-h2 ()
  "Add section tags to h2.
the position of first opening h2, is pushed to mark.
Version: 2024-02-28"
  (interactive)
  (let (xfirstH2)
    (goto-char (point-min))
    (search-forward "<h2>" nil t)
    (setq xfirstH2 (match-beginning 0))
    (replace-match "<section>\n\n<h2>" t t)
    (push-mark xfirstH2 t)
    (goto-char xfirstH2)
    (while (search-forward "<h2>" nil t) (replace-match "</section>\n\n<section>\n\n<h2>" t t))
    (progn
      (goto-char xfirstH2)
      (when (re-search-forward "<div class=\"topicXL\">\\|<div class=\"rltd\">\\|</main>\\|</body>")
        (replace-match
         (concat "</section>\n\n" (match-string 0))
         t t)))
    (goto-char (point-min))
    (while (re-search-forward "<section>\n*</section>" nil t)
      (replace-match ""))))

random chat