* Generate a table of contents without exporting
@ 2014-03-31 21:38 RG Williams
2014-03-31 22:32 ` Thorsten Jolitz
2014-04-01 21:03 ` Charles Berry
0 siblings, 2 replies; 7+ messages in thread
From: RG Williams @ 2014-03-31 21:38 UTC (permalink / raw)
To: emacs-orgmode
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?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Generate a table of contents without exporting
2014-03-31 21:38 Generate a table of contents without exporting RG Williams
@ 2014-03-31 22:32 ` Thorsten Jolitz
2014-04-01 0:33 ` RG Williams
2014-04-01 21:03 ` Charles Berry
1 sibling, 1 reply; 7+ messages in thread
From: Thorsten Jolitz @ 2014-03-31 22:32 UTC (permalink / raw)
To: emacs-orgmode
RG Williams <rgwills@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?
Calling
,--------------------------
| M-x org-org-export-as-org
`--------------------------
on this org buffer
#+begin_src org
#+OPTIONS: toc:2
* A
** A1
** A2
* B
** B1
** B2
#+end_src
yields this
,---------------------------------
| # Created 2014-04-01 Di 00:28
| #+TITLE: tmp<7>
| #+AUTHOR: Thorsten Jolitz
| #+OPTIONS: toc:2
|
| * A
| ** A1
| ** A2
|
| * B
| ** B1
| ** B2
|
| # Emacs 24.3.1 (Org mode 8.2.5h)
`---------------------------------
so unfortunately exporting with toc does not seem to be implemented in
ox-org.el, but maybe you'll get better advice.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Generate a table of contents without exporting
2014-03-31 21:38 Generate a table of contents without exporting RG Williams
2014-03-31 22:32 ` Thorsten Jolitz
@ 2014-04-01 21:03 ` Charles Berry
2014-04-01 21:52 ` Nick Dokos
2014-04-02 15:03 ` RG Williams
1 sibling, 2 replies; 7+ messages in thread
From: Charles Berry @ 2014-04-01 21:03 UTC (permalink / raw)
To: emacs-orgmode
RG Williams <rgwills <at> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Generate a table of contents without exporting
2014-04-01 21:03 ` Charles Berry
@ 2014-04-01 21:52 ` Nick Dokos
2014-04-02 15:05 ` RG Williams
2014-04-02 15:03 ` RG Williams
1 sibling, 1 reply; 7+ messages in thread
From: Nick Dokos @ 2014-04-01 21:52 UTC (permalink / raw)
To: emacs-orgmode
Charles Berry <ccberry@ucsd.edu> writes:
> RG Williams <rgwills <at> 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.
>
>
> #+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
>
>
Another more manual way: export to text and cut-and-paste the TOC into
a noexport top-level section.
Nick
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Generate a table of contents without exporting
2014-04-01 21:03 ` Charles Berry
2014-04-01 21:52 ` Nick Dokos
@ 2014-04-02 15:03 ` RG Williams
1 sibling, 0 replies; 7+ messages in thread
From: RG Williams @ 2014-04-02 15:03 UTC (permalink / raw)
To: emacs-orgmode
Charles Berry <ccberry <at> ucsd.edu> writes:
> #+NAME: Table_of_Contents
> #+BEGIN_SRC emacs-lisp :wrap example
>...
> #+END_SRC
>
> HTH,
> Chuck
Thank you, Charles! That works really well :)
RG
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-04-03 13:45 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-31 21:38 Generate a table of contents without exporting RG Williams
2014-03-31 22:32 ` Thorsten Jolitz
2014-04-01 0:33 ` RG Williams
2014-04-01 21:03 ` Charles Berry
2014-04-01 21:52 ` Nick Dokos
2014-04-02 15:05 ` RG Williams
2014-04-02 15:03 ` RG Williams
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).