From mboxrd@z Thu Jan 1 00:00:00 1970 From: Diego Zamboni Subject: Re: export and split orgmode headers into separate md files? Date: Mon, 20 Jan 2020 22:03:31 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000059b5a8059c98a0b2" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:45728) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iteD4-00041K-P6 for emacs-orgmode@gnu.org; Mon, 20 Jan 2020 16:03:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iteD3-00055P-1b for emacs-orgmode@gnu.org; Mon, 20 Jan 2020 16:03:46 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:42032) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iteD2-00054j-HM for emacs-orgmode@gnu.org; Mon, 20 Jan 2020 16:03:44 -0500 Received: by mail-wr1-x42c.google.com with SMTP id q6so926103wro.9 for ; Mon, 20 Jan 2020 13:03:43 -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: Xebar Saram Cc: org mode --00000000000059b5a8059c98a0b2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Z, (replying to the list) I have put together a simplified function based on the code from https://medium.com/@lakshminp/publishing-a-book-using-org-mode-9e817a56d144= , which simply exports each top-level header to a plain Markdown file. You can find it here: https://gist.github.com/zzamboni/2e6ac3c4f577249d98efb224d9d34488 I have added some commentary in the code about what it does. After evaluating the code, you just need to call M-x org-multi-file-md-export in the buffer you want to export. I hope this helps in getting you started! Cheers, --Diego On Wed, Jan 15, 2020 at 2:48 PM Xebar Saram wrote: > 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 kno= wledge :) > > Does this export to standard markdown files or leanpub format? Honestly a= t > this stage im willing to export to any flavor of markdown but basic or MM= D > 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 y= ou call >> can then check whether the current entry is a header at the level you wa= nt >> [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 exp= ort. >> >> 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-9e817a56d= 144 >> - 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-b= ook.el#L185-L186 >> [3] >> https://github.com/zzamboni/ox-leanpub/blob/book-and-markua/ox-leanpub-b= ook.el#L125 >> [4] >> https://github.com/zzamboni/ox-leanpub/blob/book-and-markua/ox-leanpub-b= ook.el#L131-L135 >> [5] >> https://github.com/zzamboni/ox-leanpub/blob/book-and-markua/ox-leanpub-b= ook.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 or= g >>> file with hundreds of headers and split each header into separate .md f= iles >>> (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 >>> >> --00000000000059b5a8059c98a0b2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Z,

(replying to the= list)

I have put together a simplified function b= ased on the code from=C2=A0https://medium.co= m/@lakshminp/publishing-a-book-using-org-mode-9e817a56d144, which simpl= y exports each top-level header to a plain Markdown file. You can find it h= ere:=C2=A0https://gist.github.com/zzamboni/2e6ac3c4f57= 7249d98efb224d9d34488

I have added some commen= tary=C2=A0in the code about what it does. After evaluating the code, you ju= st need to call M-x org-multi-file-md-export in the buffer you want to expo= rt.

I hope this helps in getting you started!

Cheers,
--Diego

On Wed, Jan 15, 2= 020 at 2:48 PM Xebar Saram <zeltakc= @gmail.com> wrote:
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 limited lisp knowledge :)

Does this expo= rt 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 bes= t. Any tips on how i can adjust the code for that?
if not can i j= ust run your code to get a different markdown format?=C2=A0What the main fu= nction 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 Zam= boni <diego@zzam= boni.org> wrote:
Hi Z,

I do = something similar in my ox-leanpub-book module [1], which=C2=A0exports each= top-level heading to a different file. The general idea is to use =3Dorg-m= ap-entries=3D 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 ded= uct the filename [4].

I found that I had to mark t= he entire subtree before calling the export function [5], otherwise the hea= dline was not getting included in the export.

I ba= sed my code originally on this blog post, which might be a simpler starting= point:=C2=A0https://medium.com/@lakshminp/p= ublishing-a-book-using-org-mode-9e817a56d144 - this code does not selec= t the entire subtree before exporting, which means only the contents of the= section is exported, but not the headline itself.

Hope this helps!
--Diego

<= div>[2] https://github.com/zzam= boni/ox-leanpub/blob/book-and-markua/ox-leanpub-book.el#L185-L186
= [4]=C2=A0https://github.com/zz= amboni/ox-leanpub/blob/book-and-markua/ox-leanpub-book.el#L131-L135


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

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=C2=A0the header name as file name//first header i= n the md file).
Has anyone done anything remotely=C2=A0similar?= =C2=A0Or if not can someone point me=C2=A0in the right direction on how to = even start dealing with this?

thx a=C2=A0lot in ad= vance any tips would=C2=A0be very much appreciated

kind regards

Z
--00000000000059b5a8059c98a0b2--