emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] [PATCH] HTML export: Start the first exported headline at head


From: Bernt Hansen
Subject: [Orgmode] [PATCH] HTML export: Start the first exported headline at heading level 2
Date: Tue, 29 Jun 2010 14:06:16 -0400

* lisp/org-exp.el (org-export):
* lisp/org-html.el (org-export-html-toplevel-to-export):
(org-html-level-start):

Adjust exported heading levels so the first heading is <h2>.
This allows narrow to subtree to be used when exporting part
of a file so you get reasonable heading levels in the resulting
HTML.
---
This patch seems to fix this issue so that the first export heading is <h2> in 
HTML.
So far this has had very limited tested.  Please report back if you have any 
problems
with it.

This patch is available at git://git.norang.ca/org-mode.git html-export

-Bernt


 lisp/org-exp.el  |    1 +
 lisp/org-html.el |   10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 54afdac..7a04cce 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -848,6 +848,7 @@ value of `org-export-run-in-background'."
   (interactive "P")
   (let* ((bg (org-xor (equal arg '(16)) org-export-run-in-background))
         subtree-p
+        org-export-html-toplevel-to-export
         (help "[t]   insert the export option template
 \[v]   limit export to visible part of outline tree
 \[1]   only export the current subtree
diff --git a/lisp/org-html.el b/lisp/org-html.el
index 4a6ded4..ef71305 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -253,6 +253,12 @@ document title."
   :group 'org-export-html
   :type 'string)
 
+(defvar org-export-html-toplevel-to-export nil
+  "The first heading level found to export.  For full file export
+this will normally be level 1 but when you narrow to subtree this
+matches the first heading level we find to export.  This controls
+the heading levels in the resulting HTML export.")
+
 (defcustom org-export-html-link-org-files-as-html t
   "Non-nil means make file links to `file.org' point to `file.html'.
 When org-mode is exporting an org-mode file to HTML, links to
@@ -2232,7 +2238,9 @@ When TITLE is nil, just close all open levels."
        (aset org-levels-open (1- level) t)
        (setq snumber (org-section-number level)
              snu (replace-regexp-in-string "\\." "_" snumber))
-       (setq level (+ level org-export-html-toplevel-hlevel -1))
+       (unless org-export-html-toplevel-to-export
+         (setq org-export-html-toplevel-to-export level))
+       (setq level (+ (- level org-export-html-toplevel-to-export) 
org-export-html-toplevel-hlevel))
        (if (and org-export-with-section-numbers (not body-only))
            (setq title (concat
                         (format "<span class=\"section-number-%d\">%s</span>"
-- 
1.7.1.575.gf526




reply via email to

[Prev in Thread] Current Thread [Next in Thread]