* Extract toc from org file [not found] <100cb12a-b3f1-739a-84f1-847f5e86a8bc@housseini.me> @ 2022-09-26 11:53 ` reza 2022-09-26 15:21 ` Max Nikulin ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: reza @ 2022-09-26 11:53 UTC (permalink / raw) To: emacs-orgmode@gnu.org [-- Attachment #1: Type: text/plain, Size: 223 bytes --] Hi list Is there a way to extract a toc from an org file e.g: #+INCLUDE: myfile.org :toc only I want to assemble the toc's from several files into one file and there seems to be no easy way to do this. Best, Reza [-- Attachment #2: OpenPGP_0xC375C6AF05125C52.asc --] [-- Type: application/pgp-keys, Size: 15557 bytes --] [-- Attachment #3: OpenPGP_signature --] [-- Type: application/pgp-signature, Size: 499 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Extract toc from org file 2022-09-26 11:53 ` Extract toc from org file reza @ 2022-09-26 15:21 ` Max Nikulin 2022-09-26 16:02 ` Max Nikulin 2022-09-26 15:39 ` Juan Manuel Macías 2022-09-27 1:28 ` Ihor Radchenko 2 siblings, 1 reply; 11+ messages in thread From: Max Nikulin @ 2022-09-26 15:21 UTC (permalink / raw) To: emacs-orgmode On 26/09/2022 18:53, reza wrote: > > Is there a way to extract a toc from an org file e.g: > > #+INCLUDE: myfile.org :toc only > > I want to assemble the toc's from several files into one file and there > seems to be no easy way to do this. Likely `org-element-map' allows to extract headings. There are should be some example in the mail list archive and at worg (hacks, perhaps in FAQ). ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Extract toc from org file 2022-09-26 15:21 ` Max Nikulin @ 2022-09-26 16:02 ` Max Nikulin [not found] ` <bb5ed7b1-e281-39b1-d7e7-659a5317ad98@housseini.me> 0 siblings, 1 reply; 11+ messages in thread From: Max Nikulin @ 2022-09-26 16:02 UTC (permalink / raw) To: emacs-orgmode On 26/09/2022 22:21, Max Nikulin wrote: > On 26/09/2022 18:53, reza wrote: >> >> Is there a way to extract a toc from an org file e.g: >> >> #+INCLUDE: myfile.org :toc only >> >> I want to assemble the toc's from several files into one file and there >> seems to be no easy way to do this. > > Likely `org-element-map' allows to extract headings. There are should be > some example in the mail list archive and at worg (hacks, perhaps in FAQ). See also info "(org) Using the Mapping API" https://orgmode.org/manual/Using-the-Mapping-API.html for `org-map-entries'. ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <bb5ed7b1-e281-39b1-d7e7-659a5317ad98@housseini.me>]
* Re: Extract toc from org file [not found] ` <bb5ed7b1-e281-39b1-d7e7-659a5317ad98@housseini.me> @ 2022-09-27 6:57 ` reza 0 siblings, 0 replies; 11+ messages in thread From: reza @ 2022-09-27 6:57 UTC (permalink / raw) To: emacs-orgmode@gnu.org [-- Attachment #1: Type: text/plain, Size: 449 bytes --] >> Likely `org-element-map' allows to extract headings. There are should >> be some example in the mail list archive and at worg (hacks, perhaps >> in FAQ). > > See also info "(org) Using the Mapping API" > https://orgmode.org/manual/Using-the-Mapping-API.html > for `org-map-entries'. Thanks for the suggestion, but these look like really low level functions which involve a lot of coding. Will try if I can figure out something. Best, Reza [-- Attachment #2: OpenPGP_0xC375C6AF05125C52.asc --] [-- Type: application/pgp-keys, Size: 15557 bytes --] [-- Attachment #3: OpenPGP_signature --] [-- Type: application/pgp-signature, Size: 499 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Extract toc from org file 2022-09-26 11:53 ` Extract toc from org file reza 2022-09-26 15:21 ` Max Nikulin @ 2022-09-26 15:39 ` Juan Manuel Macías [not found] ` <a5365480-d7b7-5015-7eb1-34e9bc215abf@housseini.me> 2022-09-27 1:28 ` Ihor Radchenko 2 siblings, 1 reply; 11+ messages in thread From: Juan Manuel Macías @ 2022-09-26 15:39 UTC (permalink / raw) To: reza; +Cc: orgmode reza writes: > Is there a way to extract a toc from an org file e.g: > > #+INCLUDE: myfile.org :toc only > > I want to assemble the toc's from several files into one file and there > seems to be no easy way to do this. Maybe the org-make-toc package can help you with what you're looking for: https://github.com/alphapapa/org-make-toc You can choose a heading on every document to contain a TOC. And then link each heading via org-transclusion: https://github.com/nobiot/org-transclusion Best regards, Juan Manuel -- -- ------------------------------------------------------ Juan Manuel Macías https://juanmanuelmacias.com https://lunotipia.juanmanuelmacias.com https://gnutas.juanmanuelmacias.com ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <a5365480-d7b7-5015-7eb1-34e9bc215abf@housseini.me>]
* Re: Extract toc from org file [not found] ` <a5365480-d7b7-5015-7eb1-34e9bc215abf@housseini.me> @ 2022-09-27 6:54 ` reza 0 siblings, 0 replies; 11+ messages in thread From: reza @ 2022-09-27 6:54 UTC (permalink / raw) To: emacs-orgmode@gnu.org [-- Attachment #1: Type: text/plain, Size: 400 bytes --] > Maybe the org-make-toc package can help you with what you're looking for: > > https://github.com/alphapapa/org-make-toc > > You can choose a heading on every document to contain a TOC. And then link each heading via org-transclusion: > > https://github.com/nobiot/org-transclusion Thanks for the suggestion, will try it out, but looks like a lot of manual bookkeeping is involved. [-- Attachment #2: OpenPGP_0xC375C6AF05125C52.asc --] [-- Type: application/pgp-keys, Size: 15557 bytes --] [-- Attachment #3: OpenPGP_signature --] [-- Type: application/pgp-signature, Size: 499 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Extract toc from org file 2022-09-26 11:53 ` Extract toc from org file reza 2022-09-26 15:21 ` Max Nikulin 2022-09-26 15:39 ` Juan Manuel Macías @ 2022-09-27 1:28 ` Ihor Radchenko [not found] ` <fa280d29-36db-8f94-c360-92366ebbeb64@housseini.me> 2 siblings, 1 reply; 11+ messages in thread From: Ihor Radchenko @ 2022-09-27 1:28 UTC (permalink / raw) To: reza; +Cc: emacs-orgmode@gnu.org reza <reza@housseini.me> writes: > Hi list > > Is there a way to extract a toc from an org file e.g: > > #+INCLUDE: myfile.org :toc only > > I want to assemble the toc's from several files into one file and there > seems to be no easy way to do this. I presume that you are attempting to export multiple org files at the same time. Such functionality is covered by Org publish. Org publish allows generating a sitemap, which is another word for TOC in a multifile export. See 14.1.7 Generating a sitemap section of Org manual. If you are exporting a single Org file that is using contents of multiple #+include'd files, you can use the normal TOC generation as described in 13.3 Table of Contents section of the Org manual. Hope it helps. -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92 ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <fa280d29-36db-8f94-c360-92366ebbeb64@housseini.me>]
* Re: Extract toc from org file [not found] ` <fa280d29-36db-8f94-c360-92366ebbeb64@housseini.me> @ 2022-09-27 6:51 ` reza 2022-09-27 7:08 ` Ihor Radchenko 0 siblings, 1 reply; 11+ messages in thread From: reza @ 2022-09-27 6:51 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-orgmode@gnu.org [-- Attachment #1: Type: text/plain, Size: 774 bytes --] > I presume that you are attempting to export multiple org files at the > same time. Yes. > Such functionality is covered by Org publish. > Org publish allows generating a sitemap, which is another word for TOC > in a multifile export. See 14.1.7 Generating a sitemap section of Org > manual. I'm using org publish, but the sitemap does only collect the titles from org files but I want the complete toc of each file and as far as I undesrand this is not possible with sitemap? > If you are exporting a single Org file that is using contents of > multiple #+include'd files, you can use the normal TOC generation as > described in 13.3 Table of Contents section of the Org manual. But this forces all the content into a single file, no? Thanks for the suggestions! [-- Attachment #2: OpenPGP_0xC375C6AF05125C52.asc --] [-- Type: application/pgp-keys, Size: 15557 bytes --] [-- Attachment #3: OpenPGP_signature --] [-- Type: application/pgp-signature, Size: 499 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Extract toc from org file 2022-09-27 6:51 ` reza @ 2022-09-27 7:08 ` Ihor Radchenko [not found] ` <0ce13d8e-aea6-64af-86e5-da4f88be5d9c@housseini.me> 0 siblings, 1 reply; 11+ messages in thread From: Ihor Radchenko @ 2022-09-27 7:08 UTC (permalink / raw) To: reza; +Cc: emacs-orgmode@gnu.org reza <reza@housseini.me> writes: > I'm using org publish, but the sitemap does only collect the titles from > org files but I want the complete toc of each file and as far as I > undesrand this is not possible with sitemap? You just need a custom :sitemap-function. The default `org-publish-sitemap-default' flattens the hierarchy. From the manual: ‘:sitemap-function’ Plug-in function to use for generation of the sitemap. It is called with two arguments: the title of the site-map and a representation of the files and directories involved in the project as a nested list, which can further be transformed using ‘org-list-to-generic’, ‘org-list-to-subtree’ and alike. Default value generates a plain list of links to all files in the project. You may create a function similar to `org-publish-sitemap-default' but using `org-list-to-subtree' instead of `org-list-to-org' >> If you are exporting a single Org file that is using contents of >> multiple #+include'd files, you can use the normal TOC generation as >> described in 13.3 Table of Contents section of the Org manual. > > But this forces all the content into a single file, no? Yes, it will. It is indeed not something you want in your use case. -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92 ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <0ce13d8e-aea6-64af-86e5-da4f88be5d9c@housseini.me>]
* Re: Extract toc from org file [not found] ` <0ce13d8e-aea6-64af-86e5-da4f88be5d9c@housseini.me> @ 2022-09-27 8:19 ` reza 2022-09-27 12:47 ` Ihor Radchenko 0 siblings, 1 reply; 11+ messages in thread From: reza @ 2022-09-27 8:19 UTC (permalink / raw) To: emacs-orgmode@gnu.org [-- Attachment #1: Type: text/plain, Size: 1028 bytes --] > You just need a custom :sitemap-function. > The default `org-publish-sitemap-default' flattens the hierarchy. > > From the manual: > > ‘:sitemap-function’ > Plug-in function to use for generation of the sitemap. It is > called with two arguments: the title of the site-map and a > representation of the files and directories involved in the project > as a nested list, which can further be transformed using > ‘org-list-to-generic’, ‘org-list-to-subtree’ and alike. Default > value generates a plain list of links to all files in the project. > > You may create a function similar to `org-publish-sitemap-default' but > using `org-list-to-subtree' instead of `org-list-to-org' Thanks for the pointers, but I can't figure out how to get from there to a toc? As I understand, `list' is a list of files from my project and `org-list-to-subtree' does add stars to this list. But how do I get all sections and subsections from my file to appear here? [-- Attachment #2: OpenPGP_0xC375C6AF05125C52.asc --] [-- Type: application/pgp-keys, Size: 15557 bytes --] [-- Attachment #3: OpenPGP_signature --] [-- Type: application/pgp-signature, Size: 499 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Extract toc from org file 2022-09-27 8:19 ` reza @ 2022-09-27 12:47 ` Ihor Radchenko 0 siblings, 0 replies; 11+ messages in thread From: Ihor Radchenko @ 2022-09-27 12:47 UTC (permalink / raw) To: reza; +Cc: emacs-orgmode@gnu.org reza <reza@housseini.me> writes: >> You may create a function similar to `org-publish-sitemap-default' but > >> using `org-list-to-subtree' instead of `org-list-to-org' > > Thanks for the pointers, but I can't figure out how to get from there to > a toc? As I understand, `list' is a list of files from my project and > `org-list-to-subtree' does add stars to this list. But how do I get all > sections and subsections from my file to appear here? Hmm. You are right. Currently, only links to files inside published project are in the sitemap. Adding TOC cross-links will not be trivial. One way could be publishing TOC in individual files and later moving those TOCs into sitemap. But, say, in html the TOC entries are internal html links... So things are going to be tricky. Or you may reuse the code for site index (org-publish-collect-index and org-publish-index-generate-theindex) but to collect your TOC entries. If you manage to get something useful about this problem, please let us know. This kind of feature sounds like something we could add to ox-publish. -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92 ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2022-09-27 14:39 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <100cb12a-b3f1-739a-84f1-847f5e86a8bc@housseini.me> 2022-09-26 11:53 ` Extract toc from org file reza 2022-09-26 15:21 ` Max Nikulin 2022-09-26 16:02 ` Max Nikulin [not found] ` <bb5ed7b1-e281-39b1-d7e7-659a5317ad98@housseini.me> 2022-09-27 6:57 ` reza 2022-09-26 15:39 ` Juan Manuel Macías [not found] ` <a5365480-d7b7-5015-7eb1-34e9bc215abf@housseini.me> 2022-09-27 6:54 ` reza 2022-09-27 1:28 ` Ihor Radchenko [not found] ` <fa280d29-36db-8f94-c360-92366ebbeb64@housseini.me> 2022-09-27 6:51 ` reza 2022-09-27 7:08 ` Ihor Radchenko [not found] ` <0ce13d8e-aea6-64af-86e5-da4f88be5d9c@housseini.me> 2022-09-27 8:19 ` reza 2022-09-27 12:47 ` Ihor Radchenko
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.