;; Author: Steve Youngs <steve@sxemacs.org>
;; Maintainer: Steve Youngs <steve@sxemacs.org>
;; Created: <2007-12-02>
-;; Time-stamp: <Friday Apr 10, 2020 15:14:04 steve>
+;; Time-stamp: <Tuesday Apr 14, 2020 17:04:47 steve>
;; Download: <https://downloads.sxemacs.org/SYinits/>
;; HTMLised: <https://www.sxemacs.org/SYinits/07-html.html>
;; Git Repo: git clone https://git.sxemacs.org/syinit
(eval-and-compile
(require 'htmlize))
+;; Force XHTML 1.0 Transitional
+(defun htmlize-default-doctype ()
+ nil
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
+ \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
+
;; File-local variables can cause problems so this advice simply
;; disables them when htmlize runs.
(defadvice htmlize-buffer (around nolocals (&rest args) activate)
(replace-string "<!--" "<!--")
(replace-string "-->" "-->"))))))
+(defun sy-htmlize-add-xmlns ()
+ "Adds a xmlns property to the html tag.
+
+Because we are trying to output XHTML we need to add the xmlns to the
+html tag. Done via `htmlize-after-hook'."
+ (save-excursion
+ (goto-char (point-min))
+ (re-search-forward "<html>" nil t)
+ (replace-match
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">")))
+
;; 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
<img style=\"padding:0px 5px 0px 0px;border:0;width:88px;height:31px\"
src=\"/Images/cbsx.png\"
title=\"This page was created entirely in SXEmacs\"
- alt=\"Created with SXEmacs\">
+ alt=\"Created with SXEmacs\" />
</a>
<!-- End SXEmacs Logo -->
<!-- Valid XHTML 1.0 / CSS -->
- <a href=\"http://validator.w3.org/check/referer\">
+ <a href=\"http://validator.w3.org/check?uri=referer\">
<img style=\"padding:0px 5px 0px 10px;border:0;width:88px;height:31px\"
- src=\"/Images/valid-html401.png\"
- title=\"Valid HTML 4.01 Strict!\"
- alt=\"Valid HTML 4.01 Strict!\">
+ src=\"/Images/valid-xhtml10.png\"
+ title=\"Valid XHTML 1.0 Transitional!\"
+ alt=\"Valid XHTML 1.0 Transitional!\" />
</a>
<a href=\"http://jigsaw.w3.org/css-validator/check/referer\">
<img style=\"padding:0px 0px 0px 5px;border:0;width:88px;height:31px\"
src=\"/Images/vcss.png\"
- title=\"Valid CSS!\" alt=\"Valid CSS!\">
+ title=\"Valid CSS!\" alt=\"Valid CSS!\" />
</a>
</div>
-</p>
+
<!-- End Valid HTML / CSS-->
<h6>Copyright © "
- (format-time-string "%Y") " Steve Youngs<br>
+ (format-time-string "%Y") " Steve Youngs<br />
Verbatim copying and distribution is permitted in any medium,
- providing this notice is preserved.<br>
+ providing this notice is preserved.<br />
<!-- hhmts start -->
<!-- hhmts end -->
</h6>
;; Set a couple of basic things.
(setq
- htmlize-html-charset "UTF-8"
+ htmlize-html-charset nil
htmlize-html-major-mode 'html-mode
htmlize-head-tags
- "<meta name=\"author\" content=\"Steve Youngs\">
-<meta name=\"owner\" content=\"steve@sxemacs.org\">
+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
+ <meta name=\"author\" content=\"Steve Youngs\" />
+ <meta name=\"owner\" content=\"steve@sxemacs.org\" />
")
(setq htmlize-hyperlink-style "
(defun sy-htmlize-after-hook ()
(sy-htmlize-set-links)
(sy-htmlize-append)
+ (sy-htmlize-add-xmlns)
(with-current-buffer (get-file-buffer sy-htmlize-this-file)
(normal-mode)) ; Will turn howm-mode back on if it was off
(setq sy-htmlize-this-file nil))