]> code.delx.au - gnu-emacs/blobdiff - lisp/org/org-html.el
2009-11-20 Carsten Dominik <carsten.dominik@gmail.com>
[gnu-emacs] / lisp / org / org-html.el
index a92fa998adb4ca1d8a775c833892ba9ae78f53b8..d59f16a0c7f55fcb1057142b0230d35f68939902 100644 (file)
@@ -6,7 +6,7 @@
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
-;; Version: 6.30c
+;; Version: 6.33x
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -229,7 +229,7 @@ CSS classes, then this prefic can be very useful."
   :type 'string)
 
 (defcustom org-export-html-home/up-format
-  "<div style=\"text-align:right;font-size:70%%;white-space:nowrap;\">
+  "<div id=\"org-div-home-and-up\" style=\"text-align:right;font-size:70%%;white-space:nowrap;\">
  <a accesskey=\"h\" href=\"%s\"> UP </a>
  |
  <a accesskey=\"H\" href=\"%s\"> HOME </a>
@@ -419,6 +419,9 @@ This may also be a function, building and inserting the postamble.")
 (defvar org-export-html-after-blockquotes-hook nil
   "Hook run during HTML export, after blockquote, verse, center are done.")
 
+(defvar org-export-html-final-hook nil
+  "Hook run during HTML export, after blockquote, verse, center are done.")
+
 ;;; HTML export
 
 (defun org-export-html-preprocess (parameters)
@@ -504,7 +507,7 @@ in a window.  A non-interactive call will only return the buffer."
     (setq buffer "*Org HTML Export*"))
   (let ((transient-mark-mode t) (zmacs-regions t)
        ext-plist rtn)
-    (setq ext-plist (plist-put ext-plist :ignore-subree-p t))
+    (setq ext-plist (plist-put ext-plist :ignore-subtree-p t))
     (goto-char end)
     (set-mark (point)) ;; to activate the region
     (goto-char beg)
@@ -544,7 +547,7 @@ PUB-DIR is set, use this as the publishing directory."
        (org-set-local 'buffer-file-name
                       (with-current-buffer (buffer-base-buffer)
                         buffer-file-name))
-      (error "Need a file name to be able to export.")))
+      (error "Need a file name to be able to export")))
 
   (message "Exporting...")
   (setq-default org-todo-line-regexp org-todo-line-regexp)
@@ -572,7 +575,7 @@ PUB-DIR is set, use this as the publishing directory."
         (rbeg (and region-p (region-beginning)))
         (rend (and region-p (region-end)))
         (subtree-p
-         (if (plist-get opt-plist :ignore-subree-p)
+         (if (plist-get opt-plist :ignore-subtree-p)
              nil
            (when region-p
              (save-excursion
@@ -750,7 +753,6 @@ PUB-DIR is set, use this as the publishing directory."
 <html xmlns=\"http://www.w3.org/1999/xhtml\"
 lang=\"%s\" xml:lang=\"%s\">
 <head>
-%s
 <title>%s</title>
 <meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>
 <meta name=\"generator\" content=\"Org-mode\"/>
@@ -762,6 +764,7 @@ lang=\"%s\" xml:lang=\"%s\">
 </head>
 <body>
 <div id=\"content\">
+%s
 "
                 (format
                  (or (and (stringp org-export-html-xml-declaration)
@@ -772,17 +775,17 @@ lang=\"%s\" xml:lang=\"%s\">
                      "")
                  (or charset "iso-8859-1"))
                 language language
+                (org-html-expand title)
+                (or charset "iso-8859-1")
+                date author description keywords
+                style
                 (if (or link-up link-home)
                     (concat
                      (format org-export-html-home/up-format
                              (or link-up link-home)
                              (or link-home link-up))
                      "\n")
-                  "")
-                (org-html-expand title)
-                (or charset "iso-8859-1")
-                date author description keywords
-                style))
+                  "")))
 
         (org-export-html-insert-plist-item opt-plist :preamble opt-plist)
 
@@ -969,9 +972,12 @@ lang=\"%s\" xml:lang=\"%s\">
                (setq line (concat line "\\\\")))))
 
          ;; make targets to anchors
+         (setq start 0)
          (while (string-match
-                 "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line)
+                 "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line start)
            (cond
+            ((get-text-property (match-beginning 1) 'org-protected line)
+             (setq start (match-end 1)))
             ((match-end 2)
              (setq line (replace-match
                          (format
@@ -982,16 +988,18 @@ lang=\"%s\" xml:lang=\"%s\">
             ((and org-export-with-toc (equal (string-to-char line) ?*))
              ;; FIXME: NOT DEPENDENT on TOC?????????????????????
              (setq line (replace-match
-                         (concat "@<span class=\"target\">" (match-string 1 line) "@</span> ")
-;                        (concat "@<i>" (match-string 1 line) "@</i> ")
+                         (concat "@<span class=\"target\">"
+                                 (match-string 1 line) "@</span> ")
+                         ;; (concat "@<i>" (match-string 1 line) "@</i> ")
                          t t line)))
             (t
              (setq line (replace-match
                          (concat "@<a name=\""
                                  (org-solidify-link-text (match-string 1 line))
-                                 "\" class=\"target\">" (match-string 1 line) "@</a> ")
+                                 "\" class=\"target\">" (match-string 1 line)
+                                 "@</a> ")
                          t t line)))))
-
+           
          (setq line (org-html-handle-time-stamps line))
 
          ;; replace "&" by "&amp;", "<" and ">" by "&lt;" and "&gt;"
@@ -1461,6 +1469,7 @@ lang=\"%s\" xml:lang=\"%s\">
          (delete-region beg end)
          (insert (format "<span style=\"visibility:hidden;\">%s</span>"
                          (make-string n ?x)))))
+      (run-hooks 'org-export-html-final-hook)
       (or to-buffer (save-buffer))
       (goto-char (point-min))
       (or (org-export-push-to-kill-ring "HTML")
@@ -1501,17 +1510,22 @@ lang=\"%s\" xml:lang=\"%s\">
       (let* ((caption (org-find-text-property-in-string 'org-caption src))
             (attr (org-find-text-property-in-string 'org-attributes src))
             (label (org-find-text-property-in-string 'org-label src)))
-       (format "%s<div %sclass=\"figure\">
-<p><img src=\"%s\"%s /></p>%s
-</div>%s"
-               (if org-par-open "</p>\n" "")
-               (if label (format "id=\"%s\" " label) "")
+       (concat
+       (if caption
+           (format "%s<div %sclass=\"figure\">
+<p>"
+                   (if org-par-open "</p>\n" "")
+                   (if label (format "id=\"%s\" " label) "")))
+       (format "<img src=\"%s\"%s />"
                src
                (if (string-match "\\<alt=" (or attr ""))
                    (concat " " attr )
-                 (concat " " attr " alt=\"" src "\""))
-               (if caption (concat "\n<p>" caption "</p>") "")
-               (if org-par-open "\n<p>" ""))))))
+                 (concat " " attr " alt=\"" src "\"")))
+       (if caption
+           (format "</p>%s
+</div>%s"
+               (concat "\n<p>" caption "</p>")
+               (if org-par-open "\n<p>" ""))))))))
 
 (defun org-export-html-get-bibliography ()
   "Find bibliography, cut it out and return it."
@@ -1637,7 +1651,7 @@ lang=\"%s\" xml:lang=\"%s\">
     (unless splice (push "</table>\n" html))
     (setq html (nreverse html))
     (unless splice
-      ;; Put in col tags with the alignment (unfortuntely often ignored...)
+      ;; Put in col tags with the alignment (unfortunately often ignored...)
       (unless (car org-table-colgroup-info)
        (setq org-table-colgroup-info
              (cons :start (cdr org-table-colgroup-info))))