From 8d25fdc7e124a3c3753afff003575bce28071d89 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Wed, 27 Jul 2011 19:23:24 +0200 Subject: [PATCH] org-html: put the title back in the content div. This is needed for the HTML file to interact correctly with org-info.js. On the long term, the title should be part of the preamble, but this requires work on org-info.js. * org-html.el (org-export-html-preamble-format): New default for the HTML preamble: don't include the title. Also improve the docstring. (org-export-html-postamble-format): Improve the docstring. (org-export-as-html): Add the title within the "content" div. This is necessary for interaction with the org-info.js script. --- lisp/org-html.el | 170 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 90 insertions(+), 80 deletions(-) diff --git a/lisp/org-html.el b/lisp/org-html.el index cb040674e..5b5202fb8 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -369,11 +369,13 @@ precedence over this variable." (string :tag "Custom formatting string") (function :tag "Function (must return a string)"))) -(defcustom org-export-html-preamble-format - '(("en" "

%t

")) +(defcustom org-export-html-preamble-format '(("en" "")) "The format for the HTML preamble. %t stands for the title. +%a stands for the author's name. +%e stands for the author's email. +%d stands for the date. If you need to use a \"%\" character, you need to escape it like that: \"%%\"." @@ -409,10 +411,10 @@ precedence over this variable." ")) "The format for the HTML postamble. -%a stands for the author. -%e stands for the email(s). +%a stands for the author's name. +%e stands for the author's email. %d stands for the date. -%c will be replaced by information about Org/Emacs. +%c will be replaced by information about Org/Emacs versions. %v will be replaced by `org-export-html-validation-link'. If you need to use a \"%\" character, you need to escape it @@ -1348,8 +1350,12 @@ lang=\"%s\" xml:lang=\"%s\"> ;; begin wrap around body (insert (format "\n
" - (or org-export-html-content-div ; <= FIXME obsolete since 7.7 - (nth 1 org-export-html-divs))))) + ;; FIXME org-export-html-content-div is obsolete since 7.7 + (or org-export-html-content-div + (nth 1 org-export-html-divs))) + ;; FIXME this should go in the preamble but is here so + ;; that org-infojs can still find it + "\n

" title "

\n")) ;; insert body (if (and org-export-with-toc (not body-only)) @@ -1362,91 +1368,95 @@ lang=\"%s\" xml:lang=\"%s\"> (push "
\n" thetoc) (push "
    \n
  • " thetoc) (setq lines - (mapcar #'(lambda (line) - (if (and (string-match org-todo-line-regexp line) - (not (get-text-property 0 'org-protected line))) - ;; This is a headline - (progn - (setq have-headings t) - (setq level (- (match-end 1) (match-beginning 1) - level-offset) - level (org-tr-level level) - txt (save-match-data - (org-html-expand - (org-export-cleanup-toc-line - (match-string 3 line)))) - todo - (or (and org-export-mark-todo-in-toc - (match-beginning 2) - (not (member (match-string 2 line) - org-done-keywords))) + (mapcar + #'(lambda (line) + (if (and (string-match org-todo-line-regexp line) + (not (get-text-property 0 'org-protected line))) + ;; This is a headline + (progn + (setq have-headings t) + (setq level (- (match-end 1) (match-beginning 1) + level-offset) + level (org-tr-level level) + txt (save-match-data + (org-html-expand + (org-export-cleanup-toc-line + (match-string 3 line)))) + todo + (or (and org-export-mark-todo-in-toc + (match-beginning 2) + (not (member (match-string 2 line) + org-done-keywords))) ; TODO, not DONE - (and org-export-mark-todo-in-toc - (= level umax-toc) - (org-search-todo-below - line lines level)))) - (if (string-match - (org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt) - (setq txt (replace-match "    \\1" t nil txt))) - (if (string-match quote-re0 txt) - (setq txt (replace-match "" t t txt))) - (setq snumber (org-section-number level)) - (if (and num (if (integerp num) - (>= num level) - num)) - (setq txt (concat snumber " " txt))) - (if (<= level (max umax umax-toc)) - (setq head-count (+ head-count 1))) - (if (<= level umax-toc) + (and org-export-mark-todo-in-toc + (= level umax-toc) + (org-search-todo-below + line lines level)))) + (if (string-match + (org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt) + (setq txt (replace-match + "    \\1" t nil txt))) + (if (string-match quote-re0 txt) + (setq txt (replace-match "" t t txt))) + (setq snumber (org-section-number level)) + (if (and num (if (integerp num) + (>= num level) + num)) + (setq txt (concat snumber " " txt))) + (if (<= level (max umax umax-toc)) + (setq head-count (+ head-count 1))) + (if (<= level umax-toc) + (progn + (if (> level org-last-level) (progn - (if (> level org-last-level) - (progn - (setq cnt (- level org-last-level)) - (while (>= (setq cnt (1- cnt)) 0) - (push "\n
      \n
    • " thetoc)) - (push "\n" thetoc))) - (if (< level org-last-level) - (progn - (setq cnt (- org-last-level level)) - (while (>= (setq cnt (1- cnt)) 0) - (push "
    • \n
    " thetoc)) - (push "\n" thetoc))) - ;; Check for targets - (while (string-match org-any-target-regexp line) - (setq line (replace-match - (concat "@" (match-string 1 line) "@ ") - t t line))) - (while (string-match "<\\(<\\)+\\|>\\(>\\)+" txt) - (setq txt (replace-match "" t t txt))) - (setq href - (replace-regexp-in-string - "\\." "-" (format "sec-%s" snumber))) - (setq href (org-solidify-link-text (or (cdr (assoc href org-export-preferred-target-alist)) href))) - (push - (format - (if todo - "
  • \n
  • %s" - "
  • \n
  • %s") - href txt) thetoc) - - (setq org-last-level level)) - ))) - line) - lines)) + (setq cnt (- level org-last-level)) + (while (>= (setq cnt (1- cnt)) 0) + (push "\n
      \n
    • " thetoc)) + (push "\n" thetoc))) + (if (< level org-last-level) + (progn + (setq cnt (- org-last-level level)) + (while (>= (setq cnt (1- cnt)) 0) + (push "
    • \n
    " thetoc)) + (push "\n" thetoc))) + ;; Check for targets + (while (string-match org-any-target-regexp line) + (setq line (replace-match + (concat "@" + (match-string 1 line) "@ ") + t t line))) + (while (string-match "<\\(<\\)+\\|>\\(>\\)+" txt) + (setq txt (replace-match "" t t txt))) + (setq href + (replace-regexp-in-string + "\\." "-" (format "sec-%s" snumber))) + (setq href (org-solidify-link-text + (or (cdr (assoc href + org-export-preferred-target-alist)) href))) + (push + (format + (if todo + "
  • \n
  • %s" + "
  • \n
  • %s") + href txt) thetoc) + + (setq org-last-level level))))) + line) + lines)) (while (> org-last-level (1- org-min-level)) (setq org-last-level (1- org-last-level)) (push "
  • \n
\n" thetoc)) (push "
\n" thetoc) (setq thetoc (if have-headings (nreverse thetoc) nil)))) - + (setq head-count 0) (org-init-section-numbers) - + (org-open-par) - + (while (setq line (pop lines) origline line) (catch 'nextline - + ;; end of quote section? (when (and inquote (string-match org-outline-regexp-bol line)) (insert "\n") -- 2.11.4.GIT