Xah Talk Show 2024-05-03 Ep551 Emacs Lisp Coding, html add related box

vidthumb Gqd1Kut48N0
(defun xx-add-related-box ()
  "add a html div tag with class name rltd, to current text block.
Created: 2024-05-03
Version: 2025-03-25"
  (interactive)
  (let (xp1 xp2 xtext)
    (seq-setq (xp1 xp2)
              (if (region-active-p)
                  (list (region-beginning) (region-end))
                (list
                 (save-excursion (if (re-search-backward "\n[ \t]*\n" nil 1) (match-end 0) (point)))
                 (save-excursion (if (re-search-forward "\n[ \t]*\n" nil 1) (match-beginning 0) (point))))))
    (setq xtext (buffer-substring-no-properties xp1 xp2))
    (delete-region xp1 xp2)
    (insert "<div class=\"rltd\">\n"
            xtext
            "\n</div>")))

task 2. fix this function xah-html-local-file-to-link. When a local file link contains a query string, you need to first remove the query string, then link the file, then add back the query string.

e.g.

file:///C:/Users/xah/web/xahlee_info/comp/unicode_index.html?q=power+-tel