emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bernt Hansen <bernt@norang.ca>
To: emacs-orgmode@gnu.org
Cc: Bernt Hansen <bernt@norang.ca>
Subject: [PATCH] HTML export: Start the first exported headline at heading level 2
Date: Tue, 29 Jun 2010 14:06:16 -0400	[thread overview]
Message-ID: <1277834776-16534-1-git-send-email-bernt@norang.ca> (raw)
In-Reply-To: <4C2A28D0.5010200@online.de>

* 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	other threads:[~2010-06-29 18:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-29 16:34 Exporting narrowed subtrees to HTML Bernt Hansen
2010-06-29 17:09 ` Rainer Stengele
2010-06-29 18:06   ` Bernt Hansen [this message]
2010-07-01  3:20 ` Matt Lundin
2010-07-01  7:07   ` Bernt Hansen
2010-07-01  7:26     ` Carsten Dominik
2010-07-01  7:29       ` Bernt Hansen
2010-07-01  8:12         ` Rainer Stengele

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1277834776-16534-1-git-send-email-bernt@norang.ca \
    --to=bernt@norang.ca \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).