1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <!-- Created by htmlize-1.34 in css mode. -->
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6 <title>07-html.el</title>
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8 <meta name="author" content="Steve Youngs" />
9 <meta name="owner" content="steve@sxemacs.org" />
10 <style type="text/css">
14 background-color: #000000;
17 /* font-lock-comment-face */
21 /* font-lock-doc-string-face */
25 /* font-lock-function-name-face */
30 /* font-lock-keyword-face */
34 /* font-lock-reference-face */
38 /* font-lock-string-face */
42 /* font-lock-type-face */
46 /* font-lock-variable-name-face */
52 background-color: inherit;
55 text-decoration: underline;
59 background-color: #FD00FD;
60 text-decoration: underline;
63 background-color: #000000;
64 text-decoration: none;
71 <span class="comment">;; 07-html-sy.el --- HTML settings
73 <span class="comment">;; Copyright (C) 2007 - 2020 Steve Youngs
75 <span class="comment">;; Author: Steve Youngs <<a href="mailto:steve@sxemacs.org">steve@sxemacs.org</a>>
76 ;; Maintainer: Steve Youngs <<a href="mailto:steve@sxemacs.org">steve@sxemacs.org</a>>
77 ;; Created: <2007-12-02>
78 ;; Time-stamp: <Saturday Apr 18, 2020 21:15:50 steve>
79 ;; Download: <<a href="https://downloads.sxemacs.org/SYinits/">https://downloads.sxemacs.org/SYinits/</a>>
80 ;; HTMLised: <<a href="https://www.sxemacs.org/SYinits/07-html.html">https://www.sxemacs.org/SYinits/07-html.html</a>>
81 ;; Git Repo: git clone https://git.sxemacs.org/syinit
82 ;; Keywords: init, compile
84 <span class="comment">;; This file is part of SYinit
86 <span class="comment">;; Redistribution and use in source and binary forms, with or without
87 ;; modification, are permitted provided that the following conditions
90 ;; 1. Redistributions of source code must retain the above copyright
91 ;; notice, this list of conditions and the following disclaimer.
93 ;; 2. Redistributions in binary form must reproduce the above copyright
94 ;; notice, this list of conditions and the following disclaimer in the
95 ;; documentation and/or other materials provided with the distribution.
97 ;; 3. Neither the name of the author nor the names of any contributors
98 ;; may be used to endorse or promote products derived from this
99 ;; software without specific prior written permission.
101 ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
102 ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
103 ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
104 ;; DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
105 ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
106 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
107 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
108 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
109 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
110 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
111 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
113 <span class="comment">;;; Commentary:
115 ;; Sets up things for writing HTML.
117 <span class="comment">;;; Credits:
119 ;; The HTML version of this file was created with Hrvoje Niksic's
120 ;; htmlize.el which is part of the XEmacs "text-modes" package.
123 <span class="comment">;;; Todo:
127 <span class="comment">;;; Code:
128 ;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
129 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> General HTML settings.
131 html-helper-htmldtd-version
132 "<span class="doc-string"><?xml version=\"1.0\" encoding=\"utf-8\"?>
133 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
134 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n</span>"
135 html-helper-use-expert-menu t
136 hm--html-automatic-create-modified-line t
137 hm--html-automatic-update-modified-line t
138 hm--html-changed-comment-prefix "<span class="doc-string">Changed with SXEmacs, by: </span>"
139 hm--html-created-comment-prefix "<span class="doc-string">Created with SXEmacs, by: </span>"
141 hm--html-html-doctype-version
142 "<span class="doc-string">\"-//W3C//DTD XHTML 1.0 Transitional//EN\"
143 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"</span>"
144 hm--html-log-date-format "<span class="doc-string">%y-%m-%d</span>"
145 hm--html-template-dir
146 (file-name-as-directory
147 (expand-file-name "<span class="string">templates</span>"
148 (locate-data-directory "<span class="string">hm--html-menus</span>")))
149 hm--html-frame-template-file
150 (expand-file-name "<span class="string">frame.html.tmpl</span>" hm--html-template-dir)
151 hm--html-title-date-format "<span class="doc-string">%y-%m-%d</span>"
152 hm--html-username "<span class="doc-string">Steve Youngs</span>"
153 html-sigusr1-signal-value 10)
155 <span class="comment">;; SGML stuff.
157 sgml-auto-activate-dtd t
158 sgml-live-element-indicator t
159 sgml-validate-command "<span class="doc-string">onsgmls -s -m %s %s</span>")
161 (<span class="keyword">defvar</span> <span class="variable-name">sy-sgml-dirs</span>
162 (directory-files-recur "<span class="string">/usr/share/sgml</span>" 'full nil nil 'subdir)
163 "<span class="doc-string">List of directories for `</span><span class="doc-string"><span class="reference">sgml-system-path</span></span><span class="doc-string">'.</span>")
165 (setq sgml-system-path
166 (append '("<span class="string">.</span>"
167 "<span class="string">/usr/share/sxemacs/xemacs-packages/etc/psgml-dtds/</span>")
170 (<span class="keyword">autoload</span> 'html-mode "<span class="doc-string">psgml-html</span>" "<span class="doc-string">Load psgml-html-mode</span>" t)
171 (<span class="keyword">autoload</span> 'css-mode "<span class="doc-string">css-mode</span>")
173 (add-hook 'html-mode-hook #'hm--html-minor-mode)
174 (<span class="keyword">eval-when-compile</span> (defvar ispell-extra-args))
175 (add-hook 'html-mode-hook
176 #'(<span class="keyword">lambda</span> ()
177 (make-local-variable 'ispell-extra-args)
178 (push "<span class="string">-H</span>" ispell-extra-args)))
179 (add-hook 'html-helper-timestamp-hook #'html-helper-default-insert-timestamp)
181 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
182 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Hrvoje Niksic's htmlize
184 ;; `</span><span class="comment"><span class="reference">htmlize.el</span></span><span class="comment">' comes with the "text-modes" SXEmacs package.
186 ;; `</span><span class="comment"><span class="reference">htmlize.el</span></span><span class="comment">' is a lovely piece of code for converting Emacs buffers
187 ;; into HTML. The default settings should be fine for most people most
188 ;; of the time in most situations. But, by now, I'm sure that you've
189 ;; come to the realisation that I don't fit into that category. So
190 ;; lets hack... </span><span class="comment"><span class="reference">:-</span></span><span class="comment">)
191 </span>(<span class="keyword">eval-and-compile</span>
192 (<span class="keyword">require</span> '<span class="reference">htmlize</span>))
194 <span class="comment">;; Force XHTML 1.0 Transitional
195 </span>(<span class="keyword">defun</span> <span class="function-name">htmlize-default-doctype</span> ()
197 "<span class="doc-string"><!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
198 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"></span>")
200 <span class="comment">;; File-local variables can cause problems so this advice simply
201 ;; disables them when htmlize runs.
202 </span>(<span class="keyword">defadvice</span> <span class="function-name">htmlize-buffer</span> (around nolocals (<span class="type">&rest</span> args) activate)
203 "<span class="doc-string">Turn off file local variables during htmlize-buffer.</span>"
204 (<span class="keyword">let</span> ((enable-local-variables nil)
207 (<span class="keyword">when</span> (interactive-p) (switch-to-buffer buf))))
209 <span class="comment">;; By default htmlize would turn 'file.el' into 'file.el.html', I
210 ;; prefer that it turned it into 'file.html'. That's what this advice
212 </span>(<span class="keyword">defadvice</span> <span class="function-name">htmlize-make-file-name</span> (before filename activate)
213 "<span class="doc-string">Prefer filenames \"file.ext\" -> \"file.html\".</span>"
214 (setq file (file-name-sans-extension file)))
216 <span class="comment">;; This function, run from `</span><span class="comment"><span class="reference">htmlize-after-hook</span></span><span class="comment">' lets me embed HTML
217 ;; comments inside normal source comments and also allows me to set up
218 ;; relative hyperlinks.
219 </span>(<span class="keyword">defun</span> <span class="function-name">sy-htmlize-set-links</span> ()
220 "<span class="doc-string">Function run from `</span><span class="doc-string"><span class="reference">htmlize-after-hook</span></span><span class="doc-string">'.
222 It takes care of any relative hyperlinks and also dequotes any HTML
223 comments that were incorrectly quoted.
225 Relative hyperlinks need to be prepared in a particular way in the
226 file that is to be converted to HTML. For example, in an emacs lisp
229 Get the latest rls=/src/foo.el;rld=version here;rle.
231 Which would be converted to:
233 Get the latest <a href=\"/src/foo.el\">version here</a>.</span>"
234 <span class="comment">;; LOL, we actually need to _NOT_ do it in _this_ file so the doc
235 </span> <span class="comment">;; string for this function looks right.
236 </span> (<span class="keyword">unless</span> (string-match "<span class="string">07-html</span>" (buffer-name (declare-boundp htmlbuf)))
237 (<span class="keyword">save-excursion</span>
238 (goto-char (point-min))
240 '(<span class="keyword">lambda</span> (x) (<span class="keyword">save-excursion</span> (eval x)))
241 '((replace-string "<span class="string">rls=</span>" "<span class="string"><a href=\"</span>")
242 (replace-string "<span class="string">;rld=</span>" "<span class="string">\"></span>")
243 (replace-string "<span class="string">;rle</span>" "<span class="string"></a></span>")
244 (replace-string "<span class="string">&lt;!--</span>" "<span class="string"><!--</span>")
245 (replace-string "<span class="string">--&gt;</span>" "<span class="string">--></span>"))))))
247 (<span class="keyword">defun</span> <span class="function-name">sy-htmlize-add-xmlns</span> ()
248 "<span class="doc-string">Adds a xmlns property to the html tag.
250 Because we are trying to output XHTML we need to add the xmlns to the
251 html tag. Done via `</span><span class="doc-string"><span class="reference">htmlize-after-hook</span></span><span class="doc-string">'.</span>"
252 (<span class="keyword">save-excursion</span>
253 (goto-char (point-min))
254 (re-search-forward "<span class="string"><html></span>" nil t)
256 "<span class="string"><html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"></span>")))
258 <span class="comment">;; I know that the pages generated by `</span><span class="comment"><span class="reference">htmlize.el</span></span><span class="comment">' are valid HTML and
259 ;; are created by SXEmacs. So I announce the fact by adding the appropriate
260 ;; logos to the bottom of the page, together with a copyright notice. This
261 ;; is the raw HTML for that.
262 ;; Used to have valid CSS as well but that is way too much mucking
263 ;; about to get the validator to work from within an iframe. In case
264 ;; you are wondering, the CSS produced from htmlize is definitely
266 ;; <a href=\"http://jigsaw.w3.org/css-validator/check/referer\" target=\"_blank\">
267 ;; <img style=\"padding:0px 0px 0px 5px;border:0;width:88px;height:31px\"
268 ;; src=\"/Images/vcss.png\"
269 ;; title=\"Valid CSS!\" alt=\"Valid CSS!\" />
271 </span>(<span class="keyword">defvar</span> <span class="variable-name">sy-htmlize-appendix</span>
272 (concat "<span class="string"><!-- SXEmacs Logo -->
273 <div class=\"img\">
274 <a href=\"https://www.sxemacs.org/\" target=\"_parent\">
275 <img style=\"padding:0px 5px 0px 0px;border:0;width:88px;height:31px\"
276 src=\"/Images/cbsx.png\"
277 title=\"This page was created entirely in SXEmacs\"
278 alt=\"Created with SXEmacs\" />
280 <!-- End SXEmacs Logo -->
281 <!-- Valid XHTML 1.0 -->
282 <a href=\"http://validator.w3.org/check?uri=</span>" "<span class="string">%s</span>" "<span class="string">\" target=\"_blank\">
283 <img style=\"padding:0px 5px 0px 10px;border:0;width:88px;height:31px\"
284 src=\"/Images/valid-xhtml10.png\"
285 title=\"Valid XHTML 1.0 Transitional!\"
286 alt=\"Valid XHTML 1.0 Transitional!\" />
289 <!-- End Valid XHTML 1.0 -->
291 <h6>Copyright &#169; </span>"
292 (format-time-string "<span class="string">%Y</span>") "<span class="string"> Steve Youngs<br />
293 Verbatim copying and distribution is permitted in any medium,
294 providing this notice is preserved.<br />
295 <!-- hhmts start -->
296 <!-- hhmts end -->
302 <span class="comment">;; Appends the above to each page. Run from `</span><span class="comment"><span class="reference">htmlize-after-hook</span></span><span class="comment">'.
303 </span>(<span class="keyword">autoload</span> 'url-hexify-string "<span class="doc-string">url-util</span>")
304 (<span class="keyword">defun</span> <span class="function-name">sy-htmlize-append</span> ()
305 "<span class="doc-string">Append some things to the end of files produced by `</span><span class="doc-string"><span class="reference">htmlize.el</span></span><span class="doc-string">'.</span>"
306 (<span class="keyword">let</span> ((html (url-hexify-string
307 (concat "<span class="string">https://www.sxemacs.org/SYinits/</span>"
309 (goto-char (point-max))
310 (re-search-backward "<span class="string"></body></span>" nil t)
311 (insert (format sy-htmlize-appendix html))))
313 <span class="comment">;; Set a couple of basic things.
315 htmlize-html-charset nil
316 htmlize-html-major-mode 'html-mode
318 "<span class="doc-string"><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
319 <meta name=\"author\" content=\"Steve Youngs\" />
320 <meta name=\"owner\" content=\"steve@sxemacs.org\" />
323 (setq htmlize-hyperlink-style "<span class="doc-string">
326 background-color: inherit;
329 text-decoration: underline;
333 background-color: #FD00FD;
334 text-decoration: underline;
337 background-color: #000000;
338 text-decoration: none;
342 <span class="comment">;; Hooks
343 </span>(<span class="keyword">defvar</span> <span class="variable-name">sy-htmlize-this-file</span> nil
344 "<span class="doc-string">The name of the file we htmlize'd.</span>")
345 (<span class="keyword">defun</span> <span class="function-name">sy-htmlize-before-hook</span> ()
346 "<span class="doc-string">Prepares the buffer for htmlising.
347 Turns off howm-mode as it can play havoc with the font-locking, and we
348 force a fontify of the buffer.</span>"
349 (setq sy-htmlize-this-file (buffer-file-name))
350 (and howm-mode (howm-mode 0))
351 (font-lock-fontify-buffer))
353 (<span class="keyword">defun</span> <span class="function-name">sy-htmlize-after-hook</span> ()
354 (sy-htmlize-set-links)
356 (sy-htmlize-add-xmlns)
357 (<span class="keyword">with-current-buffer</span> (get-file-buffer sy-htmlize-this-file)
358 (normal-mode)) <span class="comment">; Will turn howm-mode back on if it was off
359 </span> (setq sy-htmlize-this-file nil))
361 (add-hook 'htmlize-before-hook #'sy-htmlize-before-hook)
362 (add-hook 'htmlize-after-hook #'sy-htmlize-after-hook)
363 <span class="comment">;</span><span class="comment"><span class="reference">:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*</span></span><span class="comment">
364 </span>(message "<span class="doc-string">HTML settings initialised</span>")
366 <!-- SXEmacs Logo -->
368 <a href="https://www.sxemacs.org/" target="_parent">
369 <img style="padding:0px 5px 0px 0px;border:0;width:88px;height:31px"
370 src="/Images/cbsx.png"
371 title="This page was created entirely in SXEmacs"
372 alt="Created with SXEmacs" />
374 <!-- End SXEmacs Logo -->
375 <!-- Valid XHTML 1.0 -->
376 <a href="http://validator.w3.org/check?uri=https%3a%2f%2fwww.sxemacs.org%2fSYinits%2f07-html.html" target="_blank">
377 <img style="padding:0px 5px 0px 10px;border:0;width:88px;height:31px"
378 src="/Images/valid-xhtml10.png"
379 title="Valid XHTML 1.0 Transitional!"
380 alt="Valid XHTML 1.0 Transitional!" />
383 <!-- End Valid XHTML 1.0 -->
385 <h6>Copyright © 2020 Steve Youngs<br />
386 Verbatim copying and distribution is permitted in any medium,
387 providing this notice is preserved.<br />
389 Last modified: Sat Apr 18 21:42:00 AEST 2020