From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernt Hansen Subject: [PATCH] HTML export: Start the first exported headline at heading level 2 Date: Tue, 29 Jun 2010 14:06:16 -0400 Message-ID: <1277834776-16534-1-git-send-email-bernt@norang.ca> References: <4C2A28D0.5010200@online.de> Return-path: Received: from [140.186.70.92] (port=37006 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTfCY-0003zE-AQ for emacs-orgmode@gnu.org; Tue, 29 Jun 2010 14:06:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OTfCW-0001KK-Sb for emacs-orgmode@gnu.org; Tue, 29 Jun 2010 14:06:30 -0400 Received: from mho-01-ewr.mailhop.org ([204.13.248.71]:57151) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OTfCW-0001KE-Qz for emacs-orgmode@gnu.org; Tue, 29 Jun 2010 14:06:28 -0400 Received: from cpe000102d0fe75-cm0012256ecbde.cpe.net.cable.rogers.com ([99.239.148.180] helo=mail.norang.ca) by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68) (envelope-from ) id 1OTfCW-000POi-8O for emacs-orgmode@gnu.org; Tue, 29 Jun 2010 18:06:28 +0000 In-Reply-To: <4C2A28D0.5010200@online.de> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: Bernt Hansen * 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

. 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

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 "%s" -- 1.7.1.575.gf526