Emacs: HTML, Lines/Blocks to List
Here's a command that turn lines or paragraphs into HTML list.
(defun xah-html-lines-to-list () "Make the current lines or text blocks into a HTML list. If there is no selection, make each line into a list item. If there is selection, each text block becomes a list item. (text block is separated by empty lines.) If `universal-argument' is called first, use ordered list <ol> instead of <ul>. URL `http://xahlee.info/emacs/emacs/elisp_lines_to_list.html' Version ~2013 2021-06-22" (interactive) (let ($bds $p1 $p2 ($markActive mark-active)) (if $markActive (setq $p1 (region-beginning) $p2 (region-end)) (progn (setq $bds (xah-get-bounds-of-thing 'block)) (setq $p1 (car $bds) $p2 (cdr $bds)))) (save-restriction (narrow-to-region $p1 $p2) (progn (goto-char (point-min)) (while (re-search-forward "\.html$" nil "move") (backward-char 1) (xah-html-any-linkify))) (progn (goto-char (point-min)) (insert "<li>") (if $markActive (while (re-search-forward "\n\n+" nil "move" ) (replace-match "</li>\n\n<li>" t t )) (while (search-forward "\n" nil "move" ) (replace-match "</li>\n<li>" t t ))) (insert "</li>\n")) (if current-prefix-arg (progn (goto-char (point-min)) (insert "<ol>\n") (goto-char (point-max)) (insert "</ol>")) (progn (goto-char (point-min)) (insert "<ul>\n") (goto-char (point-max)) (insert "</ul>"))) (goto-char (point-min)) (while (re-search-forward "<li>[-•*⓪①②③④⑤⑥⑦⑧⑨⑩] " nil "move") (replace-match "<li>" t t )) (goto-char (point-min)) (while (re-search-forward "<li></li>" nil "move" ) (replace-match "" t t )) (goto-char (point-min)) (while (re-search-forward "<li>\n" nil "move" ) (replace-match "<li>" t t )) (goto-char (point-min)) (while (re-search-forward "\n\n+" nil "move" ) (replace-match "\n\n" t t )) (insert "\n\n"))))
You need
Emacs: xah-get-thing.el
and
xah-html-any-linkify