From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xebar Saram Subject: Re: export and split orgmode headers into separate md files? Date: Wed, 15 Jan 2020 08:47:56 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000006360f2059c2df51e" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:60114) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irj1n-0001Tt-Nf for emacs-orgmode@gnu.org; Wed, 15 Jan 2020 08:48:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irj1m-0004QC-7J for emacs-orgmode@gnu.org; Wed, 15 Jan 2020 08:48:11 -0500 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]:43174) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1irj1l-0004PD-VF for emacs-orgmode@gnu.org; Wed, 15 Jan 2020 08:48:10 -0500 Received: by mail-lf1-x135.google.com with SMTP id 9so12748111lfq.10 for ; Wed, 15 Jan 2020 05:48:09 -0800 (PST) In-Reply-To: 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-mx.org@gnu.org Sender: "Emacs-orgmode" To: Diego Zamboni Cc: org mode --0000000000006360f2059c2df51e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thx Deigo for the detailed answer! Really appreciate it! i think though it=E2=80=99s a bit over my head as i have limited lisp knowl= edge :) Does this export to standard markdown files or leanpub format? Honestly at this stage im willing to export to any flavor of markdown but basic or MMD would work best. Any tips on how i can adjust the code for that? if not can i just run your code to get a different markdown format? What the main function you run after evaluating the code in emacs? i apologize in advance for the silly questions :) thx again Z On Sun, Jan 12, 2020 at 7:20 AM Diego Zamboni wrote: > 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 > =3Dorg-map-entries=3D to loop over the entire buffer [2]. The function yo= u call > can then check whether the current entry is a header at the level you wan= t > [3] and then export it to the corresponding file. The title can be used t= o > 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 expo= rt. > > 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-9e817a56d1= 44 > - 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-bo= ok.el#L185-L186 > [3] > https://github.com/zzamboni/ox-leanpub/blob/book-and-markua/ox-leanpub-bo= ok.el#L125 > [4] > https://github.com/zzamboni/ox-leanpub/blob/book-and-markua/ox-leanpub-bo= ok.el#L131-L135 > [5] > https://github.com/zzamboni/ox-leanpub/blob/book-and-markua/ox-leanpub-bo= ok.el#L170-L174 > > > On Sun, Jan 12, 2020 at 4:54 AM Xebar Saram 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 fi= les >> (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 >> > --0000000000006360f2059c2df51e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thx Deigo for the detailed answer!=C2=A0Really appreciate = it!

i think though it=E2=80=99s a bit over my head as i have l= imited lisp knowledge :)

Does this export to stand= ard markdown files or leanpub format? Honestly at this stage im willing to = export to any flavor of markdown but basic or MMD would work best. Any tips= on how i can adjust the code for that?
if not can i just run you= r code to get a different markdown format?=C2=A0What the main function you = run after evaluating the code in emacs?
i apologize in advance fo= r the silly questions :)

thx again

<= /div>
Z

On Sun, Jan 12, 2020 at 7:20 AM Diego Zamboni <diego@zzamboni.org> wrote:
<= div dir=3D"ltr">Hi Z,

I do something similar in my ox-le= anpub-book module [1], which=C2=A0exports each top-level heading to a diffe= rent file. The general idea is to use =3Dorg-map-entries=3D to loop over th= e entire buffer [2]. The function you call can then check whether the curre= nt entry is a header at the level you want [3] and then export it to the co= rresponding file. The title can be used to deduct the filename [4].

I found that I had to mark the entire subtree before call= ing the export function [5], otherwise the headline was not getting include= d in the export.

I based my code originally on thi= s blog post, which might be a simpler starting point:=C2=A0https://medium.com/@lakshminp/publishing-a-book-using-org-mo= de-9e817a56d144 - this code does not select the entire subtree before e= xporting, which means only the contents of the section is exported, but not= the headline itself.

Hope this helps!
-= -Diego


=

On Sun, Jan 12, 2020= at 4:54 AM Xebar Saram <zeltakc@gmail.com> wrote:
Hi all

For wor= k 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=C2= =A0the header name as file name//first header in the md file).
Ha= s anyone done anything remotely=C2=A0similar?=C2=A0Or if not can someone po= int me=C2=A0in the right direction on how to even start dealing with this?<= /div>

thx a=C2=A0lot in advance any tips would=C2=A0be v= ery much appreciated

kind regards

Z
--0000000000006360f2059c2df51e--