;; 07-html-sy.el --- HTML settings
;; Copyright (C) 2007 - 2020 Steve Youngs
;; Author: Steve Youngs
;; Maintainer: Steve Youngs
;; Created: <2007-12-02>
;; Time-stamp:
;; Download:
;; HTMLised:
;; Git Repo: git clone https://git.sxemacs.org/syinit
;; Keywords: init, compile
;; This file is part of SYinit
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions
;; are met:
;;
;; 1. Redistributions of source code must retain the above copyright
;; notice, this list of conditions and the following disclaimer.
;;
;; 2. Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;;
;; 3. Neither the name of the author nor the names of any contributors
;; may be used to endorse or promote products derived from this
;; software without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;; Commentary:
;;
;; Sets up things for writing HTML.
;;; Credits:
;;
;; The HTML version of this file was created with Hrvoje Niksic's
;; htmlize.el which is part of the XEmacs "text-modes" package.
;;
;;; Todo:
;;
;;
;;; Code:
;:*=======================
;:* General HTML settings.
(setq
html-helper-htmldtd-version
"
\n"
html-helper-use-expert-menu t
hm--html-automatic-create-modified-line t
hm--html-automatic-update-modified-line t
hm--html-changed-comment-prefix "Changed with SXEmacs, by: "
hm--html-created-comment-prefix "Created with SXEmacs, by: "
hm--html-expert t
hm--html-html-doctype-version
"\"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\""
hm--html-log-date-format "%y-%m-%d"
hm--html-template-dir
(file-name-as-directory
(expand-file-name "templates"
(locate-data-directory "hm--html-menus")))
hm--html-frame-template-file
(expand-file-name "frame.html.tmpl" hm--html-template-dir)
hm--html-title-date-format "%y-%m-%d"
hm--html-username "Steve Youngs"
html-sigusr1-signal-value 10)
;; SGML stuff.
(setq
sgml-auto-activate-dtd t
sgml-live-element-indicator t
sgml-validate-command "onsgmls -s -m %s %s")
(defvar sy-sgml-dirs
(directory-files-recur "/usr/share/sgml" 'full nil nil 'subdir)
"List of directories for `sgml-system-path'.")
(setq sgml-system-path
(append '("."
"/usr/share/sxemacs/xemacs-packages/etc/psgml-dtds/")
sy-sgml-dirs))
(autoload 'html-mode "psgml-html" "Load psgml-html-mode" t)
(autoload 'css-mode "css-mode")
(add-hook 'html-mode-hook #'hm--html-minor-mode)
(eval-when-compile (defvar ispell-extra-args))
(add-hook 'html-mode-hook
#'(lambda ()
(make-local-variable 'ispell-extra-args)
(push "-H" ispell-extra-args)))
(add-hook 'html-helper-timestamp-hook #'html-helper-default-insert-timestamp)
;:*=======================
;:* Hrvoje Niksic's htmlize
;;
;; `htmlize.el' comes with the "text-modes" SXEmacs package.
;;
;; `htmlize.el' is a lovely piece of code for converting Emacs buffers
;; into HTML. The default settings should be fine for most people most
;; of the time in most situations. But, by now, I'm sure that you've
;; come to the realisation that I don't fit into that category. So
;; lets hack... :-)
(eval-and-compile
(require 'htmlize))
;; File-local variables can cause problems so this advice simply
;; disables them when htmlize runs.
(defadvice htmlize-buffer (around nolocals (&rest args) activate)
"Turn off file local variables during htmlize-buffer."
(let ((enable-local-variables nil)
buf)
(setq buf ad-do-it)
(when (interactive-p) (switch-to-buffer buf))))
;; By default htmlize would turn 'file.el' into 'file.el.html', I
;; prefer that it turned it into 'file.html'. That's what this advice
;; does.
(defadvice htmlize-make-file-name (before filename activate)
"Prefer filenames \"file.ext\" -> \"file.html\"."
(setq file (file-name-sans-extension file)))
;; This function, run from `htmlize-after-hook' lets me embed HTML
;; comments inside normal source comments and also allows me to set up
;; relative hyperlinks.
(defun sy-htmlize-set-links ()
"Function run from `htmlize-after-hook'.
It takes care of any relative hyperlinks and also dequotes any HTML
comments that were incorrectly quoted.
Relative hyperlinks need to be prepared in a particular way in the
file that is to be converted to HTML. For example, in an emacs lisp
file you might see:
Get the latest rls=/src/foo.el;rld=version here;rle.
Which would be converted to:
Get the latest version here."
;; LOL, we actually need to _NOT_ do it in _this_ file so the doc
;; string for this function looks right.
(unless (string-match "07-html" (buffer-name htmlbuf))
(save-excursion
(goto-char (point-min))
(mapcar
'(lambda (x) (save-excursion (eval x)))
'((replace-string "rls=" "")
(replace-string ";rle" "")
(replace-string "<!--" ""))))))
;; I know that the pages generated by `htmlize.el' are valid HTML/CSS and
;; are created by SXEmacs. So I announce the fact by adding the appropriate
;; logos to the bottom of the page, together with a copyright notice. This
;; is the raw HTML for that.
(defconst sy-htmlize-appendix
(concat "
Copyright © "
(format-time-string "%Y") " Steve Youngs
Verbatim copying and distribution is permitted in any medium,
providing this notice is preserved.
"
))
;; Appends the above to each page. Run from `htmlize-after-hook'.
(defun sy-htmlize-append ()
"Append some things to the end of files produced by `htmlize.el'."
(goto-char (point-max))
(re-search-backward "