From: Diego Zamboni <diego@zzamboni.org>
To: Xebar Saram <zeltakc@gmail.com>
Cc: org mode <emacs-orgmode@gnu.org>
Subject: Re: export and split orgmode headers into separate md files?
Date: Sun, 12 Jan 2020 13:19:54 +0100 [thread overview]
Message-ID: <CAGY83Ef4c6Sw40WLdibouvcWrrFLOEeJCzzb8qxZBzV-wwcfeA@mail.gmail.com> (raw)
In-Reply-To: <CAOQHXPrSqtHEuuP0hzioixCq-3yjKW9mvMWxZO+j5Vt3r-NzNg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1861 bytes --]
Hi Z,
I do something similar in my ox-leanpub-book module [1], which exports each
top-level heading to a different file. The general idea is to use
=org-map-entries= to loop over the entire buffer [2]. The function you call
can then check whether the current entry is a header at the level you want
[3] and then export it to the corresponding file. The title can be used to
deduct the filename [4].
I found that I had to mark the entire subtree before calling the export
function [5], otherwise the headline was not getting included in the export.
I based my code originally on this blog post, which might be a simpler
starting point:
https://medium.com/@lakshminp/publishing-a-book-using-org-mode-9e817a56d144
- this code does not select the entire subtree before exporting, which
means only the contents of the section is exported, but not the headline
itself.
Hope this helps!
--Diego
[1] https://github.com/zzamboni/ox-leanpub/tree/book-and-markua
[2]
https://github.com/zzamboni/ox-leanpub/blob/book-and-markua/ox-leanpub-book.el#L185-L186
[3]
https://github.com/zzamboni/ox-leanpub/blob/book-and-markua/ox-leanpub-book.el#L125
[4]
https://github.com/zzamboni/ox-leanpub/blob/book-and-markua/ox-leanpub-book.el#L131-L135
[5]
https://github.com/zzamboni/ox-leanpub/blob/book-and-markua/ox-leanpub-book.el#L170-L174
On Sun, Jan 12, 2020 at 4:54 AM Xebar Saram <zeltakc@gmail.com> wrote:
> Hi all
>
> For work specific needs at uni i have a need to take a comprehensive org
> file with hundreds of headers and split each header into separate .md files
> (with the header name as file name//first header in the md file).
> Has anyone done anything remotely similar? Or if not can someone point
> me in the right direction on how to even start dealing with this?
>
> thx a lot in advance any tips would be very much appreciated
>
> kind regards
>
> Z
>
[-- Attachment #2: Type: text/html, Size: 3218 bytes --]
next prev parent reply other threads:[~2020-01-12 12:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-12 3:54 export and split orgmode headers into separate md files? Xebar Saram
2020-01-12 12:19 ` Diego Zamboni [this message]
2020-01-15 13:47 ` Xebar Saram
2020-01-20 21:03 ` Diego Zamboni
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=CAGY83Ef4c6Sw40WLdibouvcWrrFLOEeJCzzb8qxZBzV-wwcfeA@mail.gmail.com \
--to=diego@zzamboni.org \
--cc=emacs-orgmode@gnu.org \
--cc=zeltakc@gmail.com \
/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).