emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* how to both :body-only t and :table-of-contents t
@ 2011-09-21 19:40 G. Jay Kerns
  2011-09-23  7:51 ` Jan Böcker
  0 siblings, 1 reply; 3+ messages in thread
From: G. Jay Kerns @ 2011-09-21 19:40 UTC (permalink / raw)
  To: emacs-orgmode

Dear Org Mode list,

First: congratulations on Org mode; it is truly dynamite.

I am publishing a project to HTML for the purposes of Jekyll
post-processing.  For this, I need to set :body-only t so I can put
the YAML frontmatter at the top of my file.  However, I would also
like to have the TOC exported (only), right after the <body> tag,
which it correctly does whenever :body-only isn't t.

In other words, it looks like I am obliged to :body-only t which cuts
out header/footer/TOC or I can NOT do :body-only t which will give me
the TOC plus a bunch of extra stuff.

My question:  is it possible to do what I want?  Is there some sort of
YAML {{ page.toc }} that I'm missing somewhere, or is there some
combination of publishing options that I've missed that will export an
org file to an HTML file that looks like this:

---
layout: default
title: whatever
---

<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#sec-1">blah blah blah </a></li>
<li><a href="#sec-2">blah blah blah </a></li>
</ul>
</div>
</div>

Rest of exported content here....?

Thanks for any advice, and again, THANK YOU to the Org Mode team.

Best,
Jay

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: how to both :body-only t and :table-of-contents t
  2011-09-21 19:40 how to both :body-only t and :table-of-contents t G. Jay Kerns
@ 2011-09-23  7:51 ` Jan Böcker
  2011-09-23 11:32   ` G. Jay Kerns
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Böcker @ 2011-09-23  7:51 UTC (permalink / raw)
  To: G. Jay Kerns; +Cc: emacs-orgmode

On 09/21/2011 09:40 PM, G. Jay Kerns wrote:
> In other words, it looks like I am obliged to :body-only t which cuts
> out header/footer/TOC or I can NOT do :body-only t which will give me
> the TOC plus a bunch of extra stuff.
>
> My question:  is it possible to do what I want?  Is there some sort of
> YAML {{ page.toc }} that I'm missing somewhere, or is there some
> combination of publishing options that I've missed that will export an
> org file to an HTML file that looks like this:


Hi Jay,

I faced the same problem about a year ago.
See this thread in the mailing list archive:

http://thread.gmane.org/gmane.emacs.orgmode/24227

The HTML exporter will refuse to include a TOC if body-only is t; the
atom exporter and a "send HTML messages with Wanderlust" hack relied on
that behaviour, which is why this was not changed in the official Org
repository.

You can either apply the one-line patch I included in the linked thread
or ask Ian Barton about his solution using jQuery he mentioned at the
end of that thread.

HTH,
  Jan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: how to both :body-only t and :table-of-contents t
  2011-09-23  7:51 ` Jan Böcker
@ 2011-09-23 11:32   ` G. Jay Kerns
  0 siblings, 0 replies; 3+ messages in thread
From: G. Jay Kerns @ 2011-09-23 11:32 UTC (permalink / raw)
  To: Jan Böcker; +Cc: emacs-orgmode

Dear Jan

On Fri, Sep 23, 2011 at 3:51 AM, Jan Böcker <jan.boecker@jboecker.de> wrote:

>
> Hi Jay,
>
> I faced the same problem about a year ago.
> See this thread in the mailing list archive:
>
> http://thread.gmane.org/gmane.emacs.orgmode/24227
>
> The HTML exporter will refuse to include a TOC if body-only is t; the
> atom exporter and a "send HTML messages with Wanderlust" hack relied on
> that behaviour, which is why this was not changed in the official Org
> repository.
>
> You can either apply the one-line patch I included in the linked thread
> or ask Ian Barton about his solution using jQuery he mentioned at the
> end of that thread.
>
> HTH,
>  Jan
>

Thanks; I was afraid it was going to be something like that, and am
appreciative that I don't need to reinvent this particular wheel.  My
previous workaround was to export once with TOC, copy-paste the TOC
bit to the org-file in a #+BEGIN_HTML block, then export again with
:body-only t.  But each run takes a couple of hours (another question
for another day), which is a pain, and not convenient should the
document structure change.

I noticed in the thread that Carsten mentioned writing a "hook" that
strips the other stuff.  Don't have much experience writing hooks, but
there should be a way to write a custom publishing function just like
the current one which strips everything but the TOC.  I'll use your
patch while I continue thinking about it.

Thanks again.
Jay

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-23 11:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-21 19:40 how to both :body-only t and :table-of-contents t G. Jay Kerns
2011-09-23  7:51 ` Jan Böcker
2011-09-23 11:32   ` G. Jay Kerns

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).