;;; -*-Emacs-Lisp-*- ;;; ==================================================================== ;;; @Emacs-Lisp-file{ ;;; author = "Nelson H. F. Beebe", ;;; version = "1.01", ;;; date = "17 April 2000", ;;; time = "18:17:40 MDT", ;;; filename = "html-support.el", ;;; address = "Center for Scientific Computing ;;; University of Utah ;;; Department of Mathematics, 322 INSCC ;;; 155 S 1400 E RM 233 ;;; Salt Lake City, UT 84112-0090 ;;; USA", ;;; telephone = "+1 801 581 5254", ;;; FAX = "+1 801 585 1640, +1 801 581 4148", ;;; URL = "http://www.math.utah.edu/~beebe", ;;; checksum = "56562 139 506 4425", ;;; email = "beebe@math.utah.edu, beebe@acm.org, ;;; beebe@computer.org, beebe@ieee.org ;;; (Internet)", ;;; codetable = "ISO/ASCII", ;;; keywords = "HTML", ;;; supported = "yes", ;;; docstring = "This file contains additional support for ;;; GNU Emacs editing and maintenance of HTML ;;; files. ;;; ;;; The checksum field above contains a CRC-16 ;;; checksum as the first value, followed by the ;;; equivalent of the standard UNIX wc (word ;;; count) utility output of lines, words, and ;;; characters. This is produced by Robert ;;; Solovay's checksum utility.", ;;; } ;;; ==================================================================== (defconst html-support "1.01 [17-Apr-2000]" "Version of html-support library") (provide 'html-support) ;; Revision history: ;; 1.01 [17-Apr-2000] ;; Add html-make-toc. ;; ;; 1.00 [15-Dec-1997] ;; Original version. (defun html-add-paragraph-environment () "Add a paragraph environment." (interactive) (insert "

\n\n

\n") (backward-char 6)) (defun html-make-toc (level) "At the current point, insert an index of HTML sections corresponding to ... elements, where n = LEVEL (default: 2). With suitable narrowing of the buffer, you can restrict this index to just a portion of the document, thereby creating mini-indexes. The index is not prettyprinted. You may wish to use \\[shell-command-on-region] with the command html-pretty -n to clean up your HTML document. " (interactive "p") (beginning-of-line) (let ((BeginHn (format "" level)) (EndHn (format "" level)) (HnStart 0) (TOC-full (make-vector 512 "")) (TOC-name (make-vector 512 "")) (TOC-start (point)) (n 0)) ;; First build up a vector of TOC entries (while (search-forward BeginHn nil t) ;; Isolate the content of ... (forward-word 1) (backward-word 1) (setq HnStart (point)) (search-forward EndHn) (backward-char 5) (backward-word 1) (forward-word 1) (aset TOC-full n (buffer-substring HnStart (point))) (aset TOC-name n (gsub "-+" "-" (gsub "[^A-Za-z0-9/+-]" "-" (aref TOC-full n)))) ;; insert an anchor ... around the topic (insert "") (goto-char HnStart) (insert "") ;; prepare for next entry (setq n (1+ n))) ;; Now insert the TOC (goto-char TOC-start) (insert BeginHn "\nTable of contents\n" EndHn "\n") (insert "") (goto-char TOC-start))) (defun html-newline () "Add a newline, and if two consecutive newlines are seen, generate an end-paragraph and a begin-paragraph." (interactive) (newline) (backward-char 2) (if (looking-at "\n\n") (progn (forward-char 1) (insert "

\n\n

\n") (backward-char 5)) (forward-char 2))) (defun html-wrap-em (&optional count) "Wrap the next COUNT words with ...." (interactive "P") (setq count (if count (prefix-numeric-value count) 1)) (forward-word 1) (backward-word 1) (insert "") (forward-word count) (insert ""))