;;; <PRE>
;;; SYNOPSIS: mhtml-mode and html quick ref, adds to html-mode.el
;;; AUTHOR: GPL(C) Mohsin Ahmed, http://www.cs.albany.edu/~mosh

(defvar comment-start  "<!--")
(defvar comment-end    "-->" )
(defvar mhtml-comment  "\n<!-- COMMENT -->\n")

(defvar mhtml-list  "\n<ol>\n<li> ITEM1 \n<li> ITEM2 \n</OL>\n")
(defvar mhtml-href  "\n<a href=\"URL\"> LINK TO URL </a>\n")
(defvar mhtml-image "\n<img src=\"IMAGE.GIF\" alt=\"DESCRIPTION\">\n")
(defvar mhtml-mark  "<a name=\"ma\">MARK</a>\n<a href=\"#ma\">Goto MARK</a>\n")

(defvar mhtml-head    "
<h1> HEAD </h1>
"
)

(defvar mhtml-header  "
<!--
;
;
;
-->"
)

(defvar mhtml-hrule "
<hr> <!-- ===================================================== -->
"
)

(defvar mhtml-page "
<html>
<head> <title> TITLE STRING </title> </head>
<body>
Paragraph one. <p>
<!-- ....... -->
Paragraph two. <p>
<!-- ....... -->
</body>
</html>
"
)


(defun mhtml-region-to-file (file &optional aname)
  "Save the region as a file and put a link in its place."
  (interactive "F")

  ;; If no extension, add .html to filename.

  (if (equal (file-name-sans-extension file) file)
     (setq file (concat file ".html")))
  (if (file-exists-p file)
      (error "File %s present." file))
  (mosh-show-region)

  ;; Default name for the anchor is same as file name.

  (if aname nil (setq aname file))
  (write-region (region-beginning) (region-end) file)
  (delete-region (region-beginning) (region-end))
  (insert (concat "<A HREF=FILE:\"" file "\"> Link to " aname " </A>\n"))
)

(defun mhtml-line-to-href ()

  "Make current line into a href, eg if Line was:
            http://www.cs.albany.edu/~mosh
   then Line becomes:
    <a href=\"http://www.cs.albany.edu/~mosh\"> DESCRIPTION </a><br>
   An easy way to make bookmarks files.
  "

  (interactive)
  (beginning-of-line)
  (insert "    <a href=\"")
  (mosh-eat-whitespace-forward)
  (end-of-line)
  (mosh-eat-whitespace-backward)
  (insert "\">\nDESCRIPTION\n    </a><br>")
)

(provide 'mhtml)

;;; EOF

