From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Berry Subject: Re: Generate a table of contents without exporting Date: Tue, 1 Apr 2014 21:03:04 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WV5qI-0005m7-Dz for emacs-orgmode@gnu.org; Tue, 01 Apr 2014 17:03:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WV5qA-0002pf-RY for emacs-orgmode@gnu.org; Tue, 01 Apr 2014 17:03:34 -0400 Received: from plane.gmane.org ([80.91.229.3]:51789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WV5qA-0002pV-L3 for emacs-orgmode@gnu.org; Tue, 01 Apr 2014 17:03:26 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WV5q3-0007Ou-Hx for emacs-orgmode@gnu.org; Tue, 01 Apr 2014 23:03:19 +0200 Received: from 137.110.32.33 ([137.110.32.33]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 01 Apr 2014 23:03:19 +0200 Received: from ccberry by 137.110.32.33 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 01 Apr 2014 23:03:19 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org RG Williams gmail.com> writes: > > Hi, > I know you can generate a table of contents when exporting, but can you do > it just within org? For context, I'm uploading an .org file to github and I > don't need to export it to another format because github recognizes and > displays it just fine. It's long so a ToC would be nice. Do I just have to > write it myself? > > AFAIK, you do have to write it yourself, but org-mode provides decent tools for doing it. Here is an example. Run the src-block and a table of contents will appear near the top. Change the content and rerun the src-block and the t-o-c will change accordingly. It doesn't deal with rules for omitting headlines like COMMENT, :noexport:, etc, but if you are simply copying the .org file, maybe it is good enough. --8<---------------cut here---------------start------------->8--- #+RESULTS: Table_of_Contents * h lower H * i lower I * j lower J ** 1 one ** 2 two #+NAME: Table_of_Contents #+BEGIN_SRC emacs-lisp :wrap example (mapconcat 'identity (org-element-map (org-element-parse-buffer 'headline) 'headline (lambda (hl) (let ((lev (org-element-property :level hl)) (htitle (org-element-property :title hl))) (concat (make-string lev ? ) "- " htitle )))) "\n") #+END_SRC --8<---------------cut here---------------end--------------->8--- HTH, Chuck