Link inside table issue, fixes read-only text error.
[muse-el.git] / lisp / muse-html.el
blob87117924fdb4703cfcf0eefddce42f3af5721803
1 ;;; muse-html.el --- Publish to HTML and XHTML.
3 ;; Copyright (C) 2004, 2005 Free Software Foundation, Inc.
5 ;; This file is not part of GNU Emacs.
7 ;; This is free software; you can redistribute it and/or modify it under
8 ;; the terms of the GNU General Public License as published by the Free
9 ;; Software Foundation; either version 2, or (at your option) any later
10 ;; version.
12 ;; This is distributed in the hope that it will be useful, but WITHOUT
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 ;; for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the
19 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 ;; Boston, MA 02110-1301, USA.
22 ;;; Commentary:
24 ;;; Contributors:
26 ;; Zhiqiang Ye (yezq AT mail DOT cbi DOT pku DOT edu DOT cn) suggested
27 ;; appending an 'encoding="..."' fragment to the first line of the
28 ;; sample publishing header so that when editing the resulting XHTML
29 ;; file, Emacs would use the proper encoding.
31 ;;; Code:
33 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
35 ;; Muse HTML Publishing
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
39 (require 'muse-publish)
40 (require 'muse-regexps)
42 (defgroup muse-html nil
43 "Options controlling the behavior of Muse HTML publishing.
44 See `muse-html' for more information."
45 :group 'muse-publish)
47 (defcustom muse-html-extension ".html"
48 "Default file extension for publishing HTML files."
49 :type 'string
50 :group 'muse-html)
52 (defcustom muse-html-style-sheet
53 "<style type=\"text/css\">
54 body {
55 background: white; color: black;
56 margin-left: 3%; margin-right: 7%;
59 p { margin-top: 1% }
60 p.verse { margin-left: 3% }
62 .example { margin-left: 3% }
64 h2 {
65 margin-top: 25px;
66 margin-bottom: 0px;
68 h3 { margin-bottom: 0px; }
69 </style>"
70 "Store your stylesheet definitions here.
71 This is used in `muse-html-header'.
72 You can put raw CSS in here or a <link> tag to an external stylesheet.
73 This text may contain <lisp> markup tags.
75 An example of using <link> is as follows.
77 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"all\" href=\"/default.css\">
79 If you are using XHTML, make sure to close the tag properly, as
80 shown in the following example.
82 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"all\" href=\"/default.css\" />"
83 :type 'string
84 :group 'muse-html)
86 (defcustom muse-html-header
87 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
88 <html>
89 <head>
90 <title><lisp>
91 (concat (muse-publishing-directive \"title\")
92 (let ((author (muse-publishing-directive \"author\")))
93 (if (not (string= author (user-full-name)))
94 (concat \" (by \" author \")\"))))</lisp></title>
95 <meta name=\"generator\" content=\"muse.el\">
96 <meta http-equiv=\"<lisp>muse-html-meta-http-equiv</lisp>\"
97 content=\"<lisp>muse-html-meta-content-type</lisp>\">
98 <lisp>
99 (let ((maintainer (muse-style-element :maintainer)))
100 (when maintainer
101 (concat \"<link rev=\\\"made\\\" href=\\\"\" maintainer \"\\\">\")))
102 </lisp>
103 <lisp>muse-html-style-sheet</lisp>
104 </head>
105 <body>
106 <h1><lisp>
107 (concat (muse-publishing-directive \"title\")
108 (let ((author (muse-publishing-directive \"author\")))
109 (if (not (string= author (user-full-name)))
110 (concat \" (by \" author \")\"))))</lisp></h1>
111 <!-- Page published by Emacs Muse begins here -->\n"
112 "Header used for publishing HTML files. This may be text or a filename."
113 :type 'string
114 :group 'muse-html)
116 (defcustom muse-html-footer "
117 <!-- Page published by Emacs Muse ends here -->
118 </body>
119 </html>\n"
120 "Footer used for publishing HTML files. This may be text or a filename."
121 :type 'string
122 :group 'muse-html)
124 (defcustom muse-xhtml-header
125 "<?xml version=\"1.0\" encoding=\"<lisp>
126 (muse-html-encoding)</lisp>\"?>
127 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
128 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
129 <html xmlns=\"http://www.w3.org/1999/xhtml\">
130 <head>
131 <title><lisp>
132 (concat (muse-publishing-directive \"title\")
133 (let ((author (muse-publishing-directive \"author\")))
134 (if (not (string= author (user-full-name)))
135 (concat \" (by \" author \")\"))))</lisp></title>
136 <meta name=\"generator\" content=\"muse.el\" />
137 <meta http-equiv=\"<lisp>muse-html-meta-http-equiv</lisp>\"
138 content=\"<lisp>muse-html-meta-content-type</lisp>\" />
139 <lisp>
140 (let ((maintainer (muse-style-element :maintainer)))
141 (when maintainer
142 (concat \"<link rev=\\\"made\\\" href=\\\"\" maintainer \"\\\" />\")))
143 </lisp>
144 <lisp>muse-html-style-sheet</lisp>
145 </head>
146 <body>
147 <h1><lisp>
148 (concat (muse-publishing-directive \"title\")
149 (let ((author (muse-publishing-directive \"author\")))
150 (if (not (string= author (user-full-name)))
151 (concat \" (by \" author \")\"))))</lisp></h1>
152 <!-- Page published by Emacs Muse begins here -->\n"
153 "Header used for publishing XHTML files. This may be text or a filename."
154 :type 'string
155 :group 'muse-html)
157 (defcustom muse-xhtml-footer "
158 <!-- Page published by Emacs Muse ends here -->
159 </body>
160 </html>\n"
161 "Footer used for publishing XHTML files. This may be text or a filename."
162 :type 'string
163 :group 'muse-html)
165 (defcustom muse-html-anchor-on-word nil
166 "When true, anchors surround the closest word. This allows you
167 to select them in a browser (i.e. for pasting), but has the
168 side-effect of marking up headers in multiple colors if your
169 header style is different from your link style."
170 :type 'boolean
171 :group 'muse-html)
173 (defcustom muse-html-table-attributes
174 "class=\"muse-table\" border=\"2\" cellpadding=\"5\""
175 "The attribute to be used with HTML <table> tags.
176 Note that since Muse supports direct insertion of HTML tags, you
177 can easily create any kind of table you want, as long as each
178 line begins at column 0 (to prevent it from being blockquoted).
179 To make such a table, use this idiom:
181 <verbatim>
182 <table>
183 [... contents of my table, in raw HTML ...]
184 </verbatim></table>
186 It may look strange to have the tags out of sequence, but this is
187 because the Muse verbatim tag is handled during a different pass
188 than the HTML table tag."
189 :type 'string
190 :group 'muse-html)
192 (defcustom muse-html-markup-regexps
193 `(;; join together the parts of a list or table
194 (10000 "</\\([oud]l\\)>\\s-*<\\1>\\s-*" 0 "")
195 (10100 ,(concat " </t\\(body\\|head\\|foot\\)>\\s-*</table>\\s-*"
196 "<table[^>]*>\\s-*<t\\1>\n") 0 "")
197 (10200 "</table>\\s-*<table[^>]*>\n" 0 "")
199 ;; beginning of doc, end of doc, or plain paragraph separator
200 (10300 ,(concat "\\(\n</\\(blockquote\\|center\\)>\\)?"
201 "\\(?:\n\\(["
202 muse-regexp-blank
203 "]*\n\\)+\\|\\`\\s-*\\|\\s-*\\'\\)"
204 "\\(<\\(blockquote\\|center\\)>\n\\)?")
205 0 muse-html-markup-paragraph))
206 "List of markup rules for publishing a Muse page to HTML.
207 For more on the structure of this list, see `muse-publish-markup-regexps'."
208 :type '(repeat (choice
209 (list :tag "Markup rule"
210 integer
211 (choice regexp symbol)
212 integer
213 (choice string function symbol))
214 function))
215 :group 'muse-html)
217 (defcustom muse-html-markup-functions
218 '((anchor . muse-html-markup-anchor)
219 (table . muse-html-markup-table)
220 (footnote . muse-html-markup-footnote))
221 "An alist of style types to custom functions for that kind of text.
222 For more on the structure of this list, see
223 `muse-publish-markup-functions'."
224 :type '(alist :key-type symbol :value-type function)
225 :group 'muse-html)
227 (defcustom muse-html-markup-strings
228 '((image-with-desc . "<img src=\"%s\" alt=\"%s\">")
229 (image-link . "<img src=\"%s\" alt=\"\">")
230 (url-with-image . "<a class=\"image-link\" href=\"%s\"><img src=\"%s\"></a>")
231 (url-link . "<a href=\"%s\">%s</a>")
232 (email-addr . "<a href=\"mailto:%s\">%s</a>")
233 (emdash . " &mdash; ")
234 (rule . "<hr>")
235 (fn-sep . "<hr>\n")
236 (enddots . "....")
237 (dots . "...")
238 (section . "<h2>")
239 (section-end . "</h2>")
240 (subsection . "<h3>")
241 (subsection-end . "</h3>")
242 (subsubsection . "<h4>")
243 (subsubsection-end . "</h4>")
244 (section-other . "<h5>")
245 (section-other-end . "</h5>")
246 (begin-underline . "<u>")
247 (end-underline . "</u>")
248 (begin-literal . "<code>")
249 (end-literal . "</code>")
250 (begin-emph . "<em>")
251 (end-emph . "</em>")
252 (begin-more-emph . "<strong>")
253 (end-more-emph . "</strong>")
254 (begin-most-emph . "<strong><em>")
255 (end-most-emph . "</em></strong>")
256 (begin-verse . "<p class=\"verse\">\n")
257 (verse-space . "&nbsp;&nbsp;")
258 (end-verse-line . "<br>")
259 (last-stanza-end . "<br>")
260 (empty-verse-line . "<br>")
261 (end-verse . "</p>")
262 (begin-example . "<pre class=\"example\">")
263 (end-example . "</pre>")
264 (begin-center . "<center>\n")
265 (end-center . "\n</center>")
266 (begin-quote . "<blockquote>\n")
267 (end-quote . "\n</blockquote>")
268 (begin-uli . "<ul>\n<li>")
269 (end-uli . "</li>\n</ul>")
270 (begin-oli . "<ol>\n<li>")
271 (end-oli . "</li>\n</ol>")
272 (begin-ddt . "<dl>\n<dt><strong>")
273 (start-dde . "</strong></dt>\n<dd>")
274 (end-ddt . "</dd>\n</dl>"))
275 "Strings used for marking up text as HTML.
276 These cover the most basic kinds of markup, the handling of which
277 differs little between the various styles."
278 :type '(alist :key-type symbol :value-type string)
279 :group 'muse-html)
281 (defcustom muse-xhtml-markup-strings
282 '((image-with-desc . "<img src=\"%s\" alt=\"%s\" />")
283 (image-link . "<img src=\"%s\" alt=\"\" />")
284 (url-with-image . "<a class=\"image-link\" href=\"%s\"><img src=\"%s\" alt=\"\" /></a>")
285 (rule . "<hr />")
286 (fn-sep . "<hr />\n")
287 (begin-underline . "<span style=\"text-decoration: underline;\">")
288 (end-underline . "</span>")
289 (begin-center . "<span style=\"text-align: center;\">\n")
290 (end-verse-line . "<br />")
291 (last-stanza-end . "<br />")
292 (empty-verse-line . "<br />")
293 (end-center . "\n</span>"))
294 "Strings used for marking up text as XHTML.
295 These cover the most basic kinds of markup, the handling of which
296 differs little between the various styles.
298 If a markup rule is not found here, `muse-html-markup-strings' is
299 searched."
300 :type '(alist :key-type symbol :value-type string)
301 :group 'muse-html)
303 (defcustom muse-html-markup-tags
304 '(("class" t t muse-html-class-tag))
305 "A list of tag specifications, for specially marking up HTML."
306 :type '(repeat (list (string :tag "Markup tag")
307 (boolean :tag "Expect closing tag" :value t)
308 (boolean :tag "Parse attributes" :value nil)
309 function))
310 :group 'muse-html)
312 (defcustom muse-html-markup-specials
313 '((?\" . "&quot;")
314 (?\< . "&lt;")
315 (?\> . "&gt;")
316 (?\& . "&amp;"))
317 "A table of characters which must be represented specially."
318 :type '(alist :key-type character :value-type string)
319 :group 'muse-html)
321 (defcustom muse-html-meta-http-equiv "Content-Type"
322 "The http-equiv attribute used for the HTML <meta> tag."
323 :type 'string
324 :group 'muse-html)
326 (defcustom muse-html-meta-content-type "text/html"
327 "The content type used for the HTML <meta> tag.
328 If you are striving for XHTML 1.1 compliance, you may want to
329 change this to \"application/xhtml+xml\"."
330 :type 'string
331 :group 'muse-html)
333 (defcustom muse-html-meta-content-encoding (if (featurep 'mule)
334 'detect
335 "iso-8859-1")
336 "The charset to append to the HTML <meta> tag.
337 If set to the symbol 'detect, use `muse-html-encoding-map' to try
338 and determine the HTML charset from emacs's coding. If set to a
339 string, this string will be used to force a particular charset"
340 :type '(choice string symbol)
341 :group 'muse-html)
343 (defcustom muse-html-charset-default "iso-8859-1"
344 "The default HTML meta charset to use if no translation is found in
345 `muse-html-encoding-map'."
346 :type 'string
347 :group 'muse-html)
349 (defcustom muse-html-encoding-default 'iso-8859-1
350 "The default Emacs buffer encoding to use in published files.
351 This will be used if no special characters are found."
352 :type 'symbol
353 :group 'muse-html)
355 (defcustom muse-html-encoding-map
356 '((iso-8859-1 . "iso-8859-1")
357 (iso-2022-jp . "iso-2022-jp")
358 (utf-8 . "utf-8")
359 (japanese-iso-8bit . "euc-jp")
360 (chinese-big5 . "big5")
361 (mule-utf-8 . "utf-8")
362 (chinese-iso-8bit . "gb2312")
363 (chinese-gbk . "gbk"))
364 "An alist mapping emacs coding systems to appropriate HTML charsets.
365 Use the base name of the coding system (i.e. without the -unix)."
366 :type '(alist :key-type coding-system :value-type string)
367 :group 'muse-html)
369 (defun muse-html-transform-content-type (content-type)
370 "Using `muse-html-encoding-map', try and resolve an emacs coding
371 system to an associated HTML coding system. If no match is found,
372 `muse-html-charset-default' is used instead."
373 (let ((match (and (fboundp 'coding-system-base)
374 (assoc (coding-system-base content-type)
375 muse-html-encoding-map))))
376 (if match
377 (cdr match)
378 muse-html-charset-default)))
380 (defun muse-html-insert-anchor (anchor)
381 "Insert an anchor, either around the word at point, or within a tag."
382 (skip-chars-forward muse-regexp-space)
383 (if (looking-at "<\\([^ />]+\\)>")
384 (let ((tag (match-string 1)))
385 (goto-char (match-end 0))
386 (insert "<a name=\"" anchor "\" id=\"" anchor "\">")
387 (when muse-html-anchor-on-word
388 (or (and (search-forward (format "</%s>" tag)
389 (muse-line-end-position) t)
390 (goto-char (match-beginning 0)))
391 (forward-word 1)))
392 (insert "</a>"))
393 (insert "<a name=\"" anchor "\" id=\"" anchor "\">")
394 (when muse-html-anchor-on-word
395 (forward-word 1))
396 (insert "</a>\n")))
398 (defun muse-html-markup-paragraph ()
399 (let ((end (copy-marker (match-end 0) t)))
400 (goto-char (match-beginning 0))
401 (when (save-excursion
402 (save-match-data
403 (and (re-search-backward "<\\(/?\\)p[ >]" nil t)
404 (not (string-equal (match-string 1) "/")))))
405 (insert "</p>"))
406 (goto-char end))
407 (cond
408 ((eobp)
409 (unless (bolp)
410 (insert "\n")))
411 ((eq (char-after) ?\<)
412 (cond
413 ((looking-at "<\\(em\\|strong\\|code\\|span\\)[ >]")
414 (insert "<p>"))
415 ((looking-at "<a ")
416 (if (looking-at "<a[^>]+><img")
417 (insert "<p class=\"image-link\">")
418 (insert "<p>")))
419 ((looking-at "<img[ >]")
420 (insert "<p class=\"image-link\">"))))
421 ((muse-looking-back "\\(</h[1-4]>\\|<hr>\\)\n\n")
422 (insert "<p class=\"first\">"))
423 ((muse-looking-back "<\\(blockquote\\|center\\)>\n")
424 (insert "<p class=\"quoted\">"))
426 (insert "<p>"))))
428 (defun muse-html-markup-anchor ()
429 (save-match-data
430 (muse-html-insert-anchor (match-string 1))) "")
432 (defun muse-html-escape-string (str &rest ignored)
433 "Convert to character entities any non-alphanumeric characters
434 outside a few punctuation symbols, that risk being misinterpreted
435 if not escaped."
436 (when str
437 (let (pos code len ch)
438 (save-match-data
439 (while (setq pos (string-match (concat "[^-"
440 muse-regexp-alnum
441 "/:._=@\\?~#]\"<>&;")
442 str pos))
443 (setq ch (aref str pos)
444 code (concat "&#"
445 (int-to-string
446 (cond ((fboundp 'char-to-ucs)
447 (char-to-ucs ch))
448 ((fboundp 'char-to-int)
449 (char-to-int ch))
450 (t ch)))
451 ";")
452 len (length code)
453 str (concat (substring str 0 pos)
454 code
455 (when (< pos (length str))
456 (substring str (1+ pos) nil)))
457 pos (+ len pos)))
458 str))))
460 (defun muse-html-markup-footnote ()
461 (if (/= (muse-line-beginning-position) (match-beginning 0))
462 "<sup><a name=\"fnr.\\1\" href=\"#fn.\\1\">\\1</a></sup>"
463 (prog1
464 "<p class=\"footnote\"><a name=\"fn.\\1\" href=\"#fnr.\\1\">\\1.</a>"
465 (save-excursion
466 (save-match-data
467 (let* ((beg (goto-char (match-end 0)))
468 (end (and (search-forward "\n\n" nil t)
469 (prog1
470 (copy-marker (match-beginning 0))
471 (goto-char beg)))))
472 (while (re-search-forward (concat "^["
473 muse-regexp-blank
474 "]+\\([^\n]\\)")
475 end t)
476 (replace-match "\\1" t))))))))
478 (defun muse-html-markup-table ()
479 (let* ((str (prog1
480 (match-string 1)
481 (delete-region (match-beginning 0) (match-end 0))))
482 (fields (split-string str "\\s-*|+\\s-*"))
483 (type (and (string-match "\\s-*\\(|+\\)\\s-*" str)
484 (length (match-string 1 str))))
485 (part (cond ((= type 1) "tbody")
486 ((= type 2) "thead")
487 ((= type 3) "tfoot")))
488 (col (cond ((= type 1) "td")
489 ((= type 2) "th")
490 ((= type 3) "td"))))
491 (insert "<table " muse-html-table-attributes ">\n"
492 " <" part ">\n"
493 " <tr>\n")
494 (dolist (field fields)
495 (insert " <" col ">" field "</" col ">\n"))
496 (insert " </tr>\n"
497 " </" part ">\n"
498 "</table>\n")))
500 ;; Handling of tags for HTML
502 (defun muse-html-insert-contents (depth)
503 (let ((max-depth (or depth 2))
504 (index 1)
505 base contents l)
506 (save-excursion
507 (goto-char (point-min))
508 (search-forward "Page published by Emacs Muse begins here" nil t)
509 (catch 'done
510 (while (re-search-forward "^<h\\([0-9]+\\)>\\(.+?\\)</h\\1>" nil t)
511 (unless (get-text-property (point) 'read-only)
512 (setq l (1- (string-to-number (match-string 1))))
513 (if (null base)
514 (setq base l)
515 (if (< l base)
516 (throw 'done t)))
517 (when (<= l max-depth)
518 (setq contents (cons (cons l (muse-match-string-no-properties 2))
519 contents))
520 (goto-char (match-beginning 2))
521 (muse-html-insert-anchor (concat "sec" (int-to-string index)))
522 (setq index (1+ index)))))))
523 (setq index 1 contents (reverse contents))
524 (let ((depth 1) (sub-open 0) (p (point)))
525 (insert "<dl class=\"contents\">\n")
526 (while contents
527 (insert "<dt class=\"contents\">\n")
528 (insert "<a href=\"#sec" (int-to-string index) "\">"
529 (muse-publish-strip-tags (cdar contents))
530 "</a>\n")
531 (setq index (1+ index))
532 (insert "</dt>\n")
533 (setq depth (caar contents)
534 contents (cdr contents))
535 (if contents
536 (cond
537 ((< (caar contents) depth)
538 (let ((idx (caar contents)))
539 (while (< idx depth)
540 (insert "</dl>\n</dd>\n")
541 (setq sub-open (1- sub-open)
542 idx (1+ idx)))))
543 ((> (caar contents) depth) ; can't jump more than one ahead
544 (insert "<dd>\n<dl class=\"contents\">\n")
545 (setq sub-open (1+ sub-open))))))
546 (while (> sub-open 0)
547 (insert "</dl>\n</dd>\n")
548 (setq sub-open (1- sub-open)))
549 (insert "</dl>\n")
550 (muse-publish-mark-read-only p (point)))))
552 (defun muse-html-class-tag (beg end attrs)
553 (goto-char beg)
554 (insert "<span class=\"" (cdr (assoc "name" attrs)) "\">")
555 (goto-char end)
556 (insert "</span>"))
558 ;; Register the Muse HTML Publisher
560 (defun muse-html-browse-file (file)
561 (browse-url (concat "file:" file)))
563 (defun muse-html-encoding ()
564 (if (stringp muse-html-meta-content-encoding)
565 muse-html-meta-content-encoding
566 (muse-html-transform-content-type
567 (or (and (boundp 'buffer-file-coding-system)
568 buffer-file-coding-system)
569 muse-html-encoding-default))))
571 (defun muse-html-prepare-buffer ()
572 (set (make-local-variable 'muse-publish-url-transforms)
573 (cons 'muse-html-escape-string muse-publish-url-transforms))
574 (make-local-variable 'muse-html-meta-http-equiv)
575 (set (make-local-variable 'muse-html-meta-content-type)
576 (concat muse-html-meta-content-type "; charset="
577 (muse-html-encoding))))
579 (defun muse-html-fixup-tables ()
580 "Sort table parts."
581 (goto-char (point-min))
582 (let (last)
583 (while (re-search-forward "^<table[^>]*>$" nil t)
584 (unless (get-text-property (point) 'read-only)
585 (forward-line 1)
586 (save-restriction
587 (let ((beg (point)))
588 (narrow-to-region beg (and (re-search-forward "^</table>$"
589 nil t)
590 (match-beginning 0))))
591 (goto-char (point-min))
592 (let ((inhibit-read-only t))
593 (sort-subr nil
594 (function
595 (lambda ()
596 (if (re-search-forward
597 "^\\s-*<t\\(head\\|body\\|foot\\)>$" nil t)
598 (goto-char (match-beginning 0))
599 (goto-char (point-max)))))
600 (function
601 (lambda ()
602 (if (re-search-forward
603 "^\\s-*</t\\(head\\|body\\|foot\\)>$" nil t)
604 (goto-char (match-end 0))
605 (goto-char (point-max)))))
606 (function
607 (lambda ()
608 (looking-at "\\s-*<t\\(head\\|body\\|foot\\)>")
609 (cond ((string= (match-string 1) "head") 1)
610 ((string= (match-string 1) "foot") 2)
611 (t 3)))))))))))
613 (defun muse-html-finalize-buffer ()
614 (when muse-publish-generate-contents
615 (goto-char (car muse-publish-generate-contents))
616 (muse-html-insert-contents (cdr muse-publish-generate-contents)))
617 (when (and (boundp 'buffer-file-coding-system)
618 (memq buffer-file-coding-system '(no-conversion undecided-unix)))
619 ;; make it agree with the default charset
620 (setq buffer-file-coding-system muse-html-encoding-default)))
622 (unless (assoc "html" muse-publishing-styles)
623 (muse-define-style "html"
624 :suffix 'muse-html-extension
625 :regexps 'muse-html-markup-regexps
626 :functions 'muse-html-markup-functions
627 :strings 'muse-html-markup-strings
628 :tags 'muse-html-markup-tags
629 :specials 'muse-html-markup-specials
630 :before 'muse-html-prepare-buffer
631 :before-end 'muse-html-fixup-tables
632 :after 'muse-html-finalize-buffer
633 :header 'muse-html-header
634 :footer 'muse-html-footer
635 :browser 'muse-html-browse-file)
637 (muse-derive-style "xhtml" "html"
638 :strings 'muse-xhtml-markup-strings
639 :header 'muse-xhtml-header
640 :footer 'muse-xhtml-footer))
642 (provide 'muse-html)
644 ;;; muse-html.el ends here