* Export each top level heading to separate file
@ 2014-01-04 22:29 Ista Zahn
2014-01-04 22:45 ` Charles Millar
0 siblings, 1 reply; 11+ messages in thread
From: Ista Zahn @ 2014-01-04 22:29 UTC (permalink / raw)
To: emacs-orgmode Mailinglist
Hi all,
I'm looking for a way to export each top-level heading to a separate
markdown file. Ideally I would like to have the exported files named
according to the heading. For example I would like this org file
-----------------------------------
* Section one
Section one text
* Section two
** Section two a
Section two text
* Section three
Section three text
-----------------------------------
To generate three files:
--- Section one.md ---
Section one text
-----------------------------------
--- Section two.md---
## Section two a
Section two text
-----------------------------------
--- Section three.md -
# Section three
Section three text
-----------------------------------
I suspect that the publishing framework might support this, but I've
thus far avoided it because it looks pretty complicated to set up.
Before I dive in I'd like to know if the publishing framework is the
correct place to look for this functionality or if there is an easier
way to do it.
Thanks,
Ista
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Export each top level heading to separate file
2014-01-04 22:29 Export each top level heading to separate file Ista Zahn
@ 2014-01-04 22:45 ` Charles Millar
2014-01-04 23:41 ` Alan L Tyree
0 siblings, 1 reply; 11+ messages in thread
From: Charles Millar @ 2014-01-04 22:45 UTC (permalink / raw)
To: emacs-orgmode
Ista and all,
On 1/4/2014 5:29 PM, Ista Zahn wrote:
> Hi all,
>
> I'm looking for a way to export each top-level heading to a separate
> markdown file. Ideally I would like to have the exported files named
> according to the heading. For example I would like this org file
>
> -----------------------------------
> * Section one
> Section one text
> * Section two
> ** Section two a
> Section two text
> * Section three
> Section three text
> -----------------------------------
>
> To generate three files:
>
> --- Section one.md ---
> Section one text
>
> -----------------------------------
>
> --- Section two.md---
> ## Section two a
>
> Section two text
>
> -----------------------------------
>
> --- Section three.md -
> # Section three
>
> Section three text
>
> -----------------------------------
>
> I suspect that the publishing framework might support this, but I've
> thus far avoided it because it looks pretty complicated to set up.
> Before I dive in I'd like to know if the publishing framework is the
> correct place to look for this functionality or if there is an easier
> way to do it.
>
>
I have a similar question regarding LaTeX export. How to export a
heading (any heading, regardless of level) within a file to heading.tex
instead of file.tex? So far the only solution I have cobbled together is
to C-x C-f 'file.tex" and then C-x C-w "heading.tex" . I then typeset
heading.tex using TeXworks. Perhaps I should note that my exported
heading is tagged so that the heading is ignored.
Charlie Millar
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Export each top level heading to separate file
2014-01-04 22:45 ` Charles Millar
@ 2014-01-04 23:41 ` Alan L Tyree
2014-01-05 0:36 ` Ista Zahn
2014-01-05 18:34 ` Charles Millar
0 siblings, 2 replies; 11+ messages in thread
From: Alan L Tyree @ 2014-01-04 23:41 UTC (permalink / raw)
To: emacs-orgmode
On 05/01/14 09:45, Charles Millar wrote:
> Ista and all,
>
> On 1/4/2014 5:29 PM, Ista Zahn wrote:
>> Hi all,
>>
>> I'm looking for a way to export each top-level heading to a separate
>> markdown file. Ideally I would like to have the exported files named
>> according to the heading. For example I would like this org file
>>
>> -----------------------------------
>> * Section one
>> Section one text
>> * Section two
>> ** Section two a
>> Section two text
>> * Section three
>> Section three text
>> -----------------------------------
>>
>> To generate three files:
>>
>> --- Section one.md ---
>> Section one text
>>
>> -----------------------------------
>>
>> --- Section two.md---
>> ## Section two a
>>
>> Section two text
>>
>> -----------------------------------
>>
>> --- Section three.md -
>> # Section three
>>
>> Section three text
>>
>> -----------------------------------
>>
>> I suspect that the publishing framework might support this, but I've
>> thus far avoided it because it looks pretty complicated to set up.
>> Before I dive in I'd like to know if the publishing framework is the
>> correct place to look for this functionality or if there is an easier
>> way to do it.
>>
>>
>
> I have a similar question regarding LaTeX export. How to export a
> heading (any heading, regardless of level) within a file to
> heading.tex instead of file.tex? So far the only solution I have
> cobbled together is to C-x C-f 'file.tex" and then C-x C-w
> "heading.tex" . I then typeset heading.tex using TeXworks. Perhaps I
> should note that my exported heading is tagged so that the heading is
> ignored.
>
> Charlie Millar
>
> ---
> This email is free from viruses and malware because avast! Antivirus
> protection is active.
> http://www.avast.com
>
>
>
Use properties to set the export file name -- example:
:PROPERTIES:
:EXPORT_TITLE: Internet banking fraud
:EXPORT_FILE_NAME: internet-fraud
:EXPORT_AUTHOR: Alan L Tyree
:Citation: (2011) 22 JBFLP 214
:EXPORT_OPTIONS: num:nil toc:nil
:END:
If I understood your question properly.
Cheers,
Alan
--
Alan L Tyree http://www2.austlii.edu.au/~alan
Tel: 04 2748 6206 sip:typhoon@iptel.org
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Export each top level heading to separate file
2014-01-04 23:41 ` Alan L Tyree
@ 2014-01-05 0:36 ` Ista Zahn
2014-01-05 2:44 ` Alan L Tyree
2014-01-05 13:40 ` John Kitchin
2014-01-05 18:34 ` Charles Millar
1 sibling, 2 replies; 11+ messages in thread
From: Ista Zahn @ 2014-01-05 0:36 UTC (permalink / raw)
To: Alan L Tyree; +Cc: emacs-orgmode Mailinglist
On Sat, Jan 4, 2014 at 6:41 PM, Alan L Tyree <alantyree@gmail.com> wrote:
> On 05/01/14 09:45, Charles Millar wrote:
>>
>> Ista and all,
>>
>> On 1/4/2014 5:29 PM, Ista Zahn wrote:
>>>
>>> Hi all,
>>>
>>> I'm looking for a way to export each top-level heading to a separate
>>> markdown file. Ideally I would like to have the exported files named
>>> according to the heading. For example I would like this org file
>>>
>>> -----------------------------------
>>> * Section one
>>> Section one text
>>> * Section two
>>> ** Section two a
>>> Section two text
>>> * Section three
>>> Section three text
>>> -----------------------------------
>>>
>>> To generate three files:
>>>
>>> --- Section one.md ---
>>> Section one text
>>>
>>> -----------------------------------
>>>
>>> --- Section two.md---
>>> ## Section two a
>>>
>>> Section two text
>>>
>>> -----------------------------------
>>>
>>> --- Section three.md -
>>> # Section three
>>>
>>> Section three text
>>>
>>> -----------------------------------
>>>
>>> I suspect that the publishing framework might support this, but I've
>>> thus far avoided it because it looks pretty complicated to set up.
>>> Before I dive in I'd like to know if the publishing framework is the
>>> correct place to look for this functionality or if there is an easier
>>> way to do it.
>>>
>>>
>>
>> I have a similar question regarding LaTeX export. How to export a heading
>> (any heading, regardless of level) within a file to heading.tex instead of
>> file.tex? So far the only solution I have cobbled together is to C-x C-f
>> 'file.tex" and then C-x C-w "heading.tex" . I then typeset heading.tex
>> using TeXworks. Perhaps I should note that my exported heading is tagged so
>> that the heading is ignored.
>>
>> Charlie Millar
>>
>> ---
>> This email is free from viruses and malware because avast! Antivirus
>> protection is active.
>> http://www.avast.com
>>
>>
>>
> Use properties to set the export file name -- example:
> :PROPERTIES:
> :EXPORT_TITLE: Internet banking fraud
> :EXPORT_FILE_NAME: internet-fraud
> :EXPORT_AUTHOR: Alan L Tyree
> :Citation: (2011) 22 JBFLP 214
> :EXPORT_OPTIONS: num:nil toc:nil
> :END:
Thanks, gets me half the way there. Setting properties as you
described and exporting each sub-tree works properly. Now how can I do
this for all the top-level headings in a file?
Best,
Ista
>
> If I understood your question properly.
>
> Cheers,
> Alan
>
>
>
> --
> Alan L Tyree http://www2.austlii.edu.au/~alan
> Tel: 04 2748 6206 sip:typhoon@iptel.org
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Export each top level heading to separate file
2014-01-05 0:36 ` Ista Zahn
@ 2014-01-05 2:44 ` Alan L Tyree
2014-01-05 13:40 ` John Kitchin
1 sibling, 0 replies; 11+ messages in thread
From: Alan L Tyree @ 2014-01-05 2:44 UTC (permalink / raw)
To: Ista Zahn; +Cc: emacs-orgmode Mailinglist
Ista Zahn writes:
> On Sat, Jan 4, 2014 at 6:41 PM, Alan L Tyree <alantyree@gmail.com> wrote:
>> On 05/01/14 09:45, Charles Millar wrote:
>>>
>>> Ista and all,
>>>
>>> On 1/4/2014 5:29 PM, Ista Zahn wrote:
>>>>
>>>> Hi all,
>>>>
>>>> I'm looking for a way to export each top-level heading to a separate
>>>> markdown file. Ideally I would like to have the exported files named
>>>> according to the heading. For example I would like this org file
>>>>
>>>> -----------------------------------
>>>> * Section one
>>>> Section one text
>>>> * Section two
>>>> ** Section two a
>>>> Section two text
>>>> * Section three
>>>> Section three text
>>>> -----------------------------------
>>>>
>>>> To generate three files:
>>>>
>>>> --- Section one.md ---
>>>> Section one text
>>>>
>>>> -----------------------------------
>>>>
>>>> --- Section two.md---
>>>> ## Section two a
>>>>
>>>> Section two text
>>>>
>>>> -----------------------------------
>>>>
>>>> --- Section three.md -
>>>> # Section three
>>>>
>>>> Section three text
>>>>
>>>> -----------------------------------
>>>>
>>>> I suspect that the publishing framework might support this, but I've
>>>> thus far avoided it because it looks pretty complicated to set up.
>>>> Before I dive in I'd like to know if the publishing framework is the
>>>> correct place to look for this functionality or if there is an easier
>>>> way to do it.
>>>>
>>>>
>>>
>>> I have a similar question regarding LaTeX export. How to export a heading
>>> (any heading, regardless of level) within a file to heading.tex instead of
>>> file.tex? So far the only solution I have cobbled together is to C-x C-f
>>> 'file.tex" and then C-x C-w "heading.tex" . I then typeset heading.tex
>>> using TeXworks. Perhaps I should note that my exported heading is tagged so
>>> that the heading is ignored.
>>>
>>> Charlie Millar
>>>
>>> ---
>>> This email is free from viruses and malware because avast! Antivirus
>>> protection is active.
>>> http://www.avast.com
>>>
>>>
>>>
>> Use properties to set the export file name -- example:
>> :PROPERTIES:
>> :EXPORT_TITLE: Internet banking fraud
>> :EXPORT_FILE_NAME: internet-fraud
>> :EXPORT_AUTHOR: Alan L Tyree
>> :Citation: (2011) 22 JBFLP 214
>> :EXPORT_OPTIONS: num:nil toc:nil
>> :END:
>
> Thanks, gets me half the way there. Setting properties as you
> described and exporting each sub-tree works properly. Now how can I do
> this for all the top-level headings in a file?
Sorry, that's beyond my pay grade :-). I would also be interested in
knowing the answer.
Cheers,
Alan
>
> Best,
> Ista
>
>>
>> If I understood your question properly.
>>
>> Cheers,
>> Alan
>>
>>
>>
>> --
>> Alan L Tyree http://www2.austlii.edu.au/~alan
>> Tel: 04 2748 6206 sip:typhoon@iptel.org
>>
>>
--
Alan L Tyree http://www2.austlii.edu.au/~alan
Tel: 04 2748 6206 sip:172385@iptel.org
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Export each top level heading to separate file
2014-01-05 0:36 ` Ista Zahn
2014-01-05 2:44 ` Alan L Tyree
@ 2014-01-05 13:40 ` John Kitchin
2014-01-05 19:49 ` Ista Zahn
1 sibling, 1 reply; 11+ messages in thread
From: John Kitchin @ 2014-01-05 13:40 UTC (permalink / raw)
To: Ista Zahn; +Cc: emacs-orgmode Mailinglist, Alan L Tyree
[-- Attachment #1: Type: text/plain, Size: 3406 bytes --]
Try this:
(org-map-entries
(lambda ()
(let ((level (nth 1 (org-heading-components)))
(title (nth 4 (org-heading-components))))
(if (= level 1)
(org-entry-put (point) ":EXPORT_FILE_NAME:" title))))
nil nil)
It seems to do what you want.
John
-----------------------------------
John Kitchin
Associate Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu
On Sat, Jan 4, 2014 at 7:36 PM, Ista Zahn <istazahn@gmail.com> wrote:
> On Sat, Jan 4, 2014 at 6:41 PM, Alan L Tyree <alantyree@gmail.com> wrote:
> > On 05/01/14 09:45, Charles Millar wrote:
> >>
> >> Ista and all,
> >>
> >> On 1/4/2014 5:29 PM, Ista Zahn wrote:
> >>>
> >>> Hi all,
> >>>
> >>> I'm looking for a way to export each top-level heading to a separate
> >>> markdown file. Ideally I would like to have the exported files named
> >>> according to the heading. For example I would like this org file
> >>>
> >>> -----------------------------------
> >>> * Section one
> >>> Section one text
> >>> * Section two
> >>> ** Section two a
> >>> Section two text
> >>> * Section three
> >>> Section three text
> >>> -----------------------------------
> >>>
> >>> To generate three files:
> >>>
> >>> --- Section one.md ---
> >>> Section one text
> >>>
> >>> -----------------------------------
> >>>
> >>> --- Section two.md---
> >>> ## Section two a
> >>>
> >>> Section two text
> >>>
> >>> -----------------------------------
> >>>
> >>> --- Section three.md -
> >>> # Section three
> >>>
> >>> Section three text
> >>>
> >>> -----------------------------------
> >>>
> >>> I suspect that the publishing framework might support this, but I've
> >>> thus far avoided it because it looks pretty complicated to set up.
> >>> Before I dive in I'd like to know if the publishing framework is the
> >>> correct place to look for this functionality or if there is an easier
> >>> way to do it.
> >>>
> >>>
> >>
> >> I have a similar question regarding LaTeX export. How to export a
> heading
> >> (any heading, regardless of level) within a file to heading.tex instead
> of
> >> file.tex? So far the only solution I have cobbled together is to C-x C-f
> >> 'file.tex" and then C-x C-w "heading.tex" . I then typeset heading.tex
> >> using TeXworks. Perhaps I should note that my exported heading is
> tagged so
> >> that the heading is ignored.
> >>
> >> Charlie Millar
> >>
> >> ---
> >> This email is free from viruses and malware because avast! Antivirus
> >> protection is active.
> >> http://www.avast.com
> >>
> >>
> >>
> > Use properties to set the export file name -- example:
> > :PROPERTIES:
> > :EXPORT_TITLE: Internet banking fraud
> > :EXPORT_FILE_NAME: internet-fraud
> > :EXPORT_AUTHOR: Alan L Tyree
> > :Citation: (2011) 22 JBFLP 214
> > :EXPORT_OPTIONS: num:nil toc:nil
> > :END:
>
> Thanks, gets me half the way there. Setting properties as you
> described and exporting each sub-tree works properly. Now how can I do
> this for all the top-level headings in a file?
>
> Best,
> Ista
>
> >
> > If I understood your question properly.
> >
> > Cheers,
> > Alan
> >
> >
> >
> > --
> > Alan L Tyree http://www2.austlii.edu.au/~alan
> > Tel: 04 2748 6206 sip:typhoon@iptel.org
> >
> >
>
>
[-- Attachment #2: Type: text/html, Size: 5206 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Export each top level heading to separate file
2014-01-04 23:41 ` Alan L Tyree
2014-01-05 0:36 ` Ista Zahn
@ 2014-01-05 18:34 ` Charles Millar
1 sibling, 0 replies; 11+ messages in thread
From: Charles Millar @ 2014-01-05 18:34 UTC (permalink / raw)
To: Alan L Tyree, emacs-orgmode
Alan,
On 1/4/2014 6:41 PM, Alan L Tyree wrote:
> Use properties to set the export file name -- example:
> :PROPERTIES:
> :EXPORT_TITLE: Internet banking fraud
> :EXPORT_FILE_NAME: internet-fraud
> :EXPORT_AUTHOR: Alan L Tyree
> :Citation: (2011) 22 JBFLP 214
> :EXPORT_OPTIONS: num:nil toc:nil
> :END:
>
> If I understood your question properly.
>
> Cheers,
> Alan
Thank you. Using C-c C-e C-s l o now exports to a pdf file no problem.
Charlie Millar
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Export each top level heading to separate file
2014-01-05 13:40 ` John Kitchin
@ 2014-01-05 19:49 ` Ista Zahn
2014-01-05 21:56 ` John Kitchin
0 siblings, 1 reply; 11+ messages in thread
From: Ista Zahn @ 2014-01-05 19:49 UTC (permalink / raw)
To: John Kitchin; +Cc: emacs-orgmode Mailinglist, Alan L Tyree
On Sun, Jan 5, 2014 at 8:40 AM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> Try this:
>
>
> (org-map-entries
> (lambda ()
> (let ((level (nth 1 (org-heading-components)))
> (title (nth 4 (org-heading-components))))
> (if (= level 1)
> (org-entry-put (point) ":EXPORT_FILE_NAME:" title))))
> nil nil)
>
> It seems to do what you want.
Dear John,
Thank you thank you! Using your code as I template I managed to write
a function that does what I wanted:
(defun my-exp-headings-to-markdown ()
"Export each top-level heading to markdown."
(interactive)
(org-map-entries
(lambda ()
(let ((level (nth 1 (org-heading-components)))
(title (nth 4 (org-heading-components))))
(if (= level 1)
(org-entry-put (point) "EXPORT_FILE_NAME" title))
(if (= level 1)
(org-md-export-to-markdown nil 1 nil))))
nil nil))
Note that I had to remove the ":" from the second argument to
"org-entry-put" to get it working properly on my system. Not sure if
that was a bug in your original example or not.
Best,
Ista
>
> John
>
> -----------------------------------
> John Kitchin
> Associate Professor
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> http://kitchingroup.cheme.cmu.edu
>
>
>
> On Sat, Jan 4, 2014 at 7:36 PM, Ista Zahn <istazahn@gmail.com> wrote:
>>
>> On Sat, Jan 4, 2014 at 6:41 PM, Alan L Tyree <alantyree@gmail.com> wrote:
>> > On 05/01/14 09:45, Charles Millar wrote:
>> >>
>> >> Ista and all,
>> >>
>> >> On 1/4/2014 5:29 PM, Ista Zahn wrote:
>> >>>
>> >>> Hi all,
>> >>>
>> >>> I'm looking for a way to export each top-level heading to a separate
>> >>> markdown file. Ideally I would like to have the exported files named
>> >>> according to the heading. For example I would like this org file
>> >>>
>> >>> -----------------------------------
>> >>> * Section one
>> >>> Section one text
>> >>> * Section two
>> >>> ** Section two a
>> >>> Section two text
>> >>> * Section three
>> >>> Section three text
>> >>> -----------------------------------
>> >>>
>> >>> To generate three files:
>> >>>
>> >>> --- Section one.md ---
>> >>> Section one text
>> >>>
>> >>> -----------------------------------
>> >>>
>> >>> --- Section two.md---
>> >>> ## Section two a
>> >>>
>> >>> Section two text
>> >>>
>> >>> -----------------------------------
>> >>>
>> >>> --- Section three.md -
>> >>> # Section three
>> >>>
>> >>> Section three text
>> >>>
>> >>> -----------------------------------
>> >>>
>> >>> I suspect that the publishing framework might support this, but I've
>> >>> thus far avoided it because it looks pretty complicated to set up.
>> >>> Before I dive in I'd like to know if the publishing framework is the
>> >>> correct place to look for this functionality or if there is an easier
>> >>> way to do it.
>> >>>
>> >>>
>> >>
>> >> I have a similar question regarding LaTeX export. How to export a
>> >> heading
>> >> (any heading, regardless of level) within a file to heading.tex instead
>> >> of
>> >> file.tex? So far the only solution I have cobbled together is to C-x
>> >> C-f
>> >> 'file.tex" and then C-x C-w "heading.tex" . I then typeset heading.tex
>> >> using TeXworks. Perhaps I should note that my exported heading is
>> >> tagged so
>> >> that the heading is ignored.
>> >>
>> >> Charlie Millar
>> >>
>> >> ---
>> >> This email is free from viruses and malware because avast! Antivirus
>> >> protection is active.
>> >> http://www.avast.com
>> >>
>> >>
>> >>
>> > Use properties to set the export file name -- example:
>> > :PROPERTIES:
>> > :EXPORT_TITLE: Internet banking fraud
>> > :EXPORT_FILE_NAME: internet-fraud
>> > :EXPORT_AUTHOR: Alan L Tyree
>> > :Citation: (2011) 22 JBFLP 214
>> > :EXPORT_OPTIONS: num:nil toc:nil
>> > :END:
>>
>> Thanks, gets me half the way there. Setting properties as you
>> described and exporting each sub-tree works properly. Now how can I do
>> this for all the top-level headings in a file?
>>
>> Best,
>> Ista
>>
>> >
>> > If I understood your question properly.
>> >
>> > Cheers,
>> > Alan
>> >
>> >
>> >
>> > --
>> > Alan L Tyree http://www2.austlii.edu.au/~alan
>> > Tel: 04 2748 6206 sip:typhoon@iptel.org
>> >
>> >
>>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Export each top level heading to separate file
2014-01-05 19:49 ` Ista Zahn
@ 2014-01-05 21:56 ` John Kitchin
2014-01-06 0:55 ` Ista Zahn
0 siblings, 1 reply; 11+ messages in thread
From: John Kitchin @ 2014-01-05 21:56 UTC (permalink / raw)
To: Ista Zahn; +Cc: emacs-orgmode Mailinglist, Alan L Tyree
[-- Attachment #1: Type: text/plain, Size: 5621 bytes --]
hmm.. I don't know if it was a bug, I ran the code on my system before
sending it, and it worked for me ;) I am glad you figured it out on your
system.
you could avoid the double if statements like this:
(defun my-exp-headings-to-markdown ()
"Export each top-level heading to markdown."
(interactive)
(org-map-entries
(lambda ()
(let ((level (nth 1 (org-heading-components)))
(title (nth 4 (org-heading-components))))
(when (= level 1)
(org-entry-put (point) "EXPORT_FILE_NAME" title)
(org-md-export-to-markdown nil 1 nil)))))
nil nil))
The when macro is like an if macro, with no else body.
John
-----------------------------------
John Kitchin
Associate Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu
On Sun, Jan 5, 2014 at 2:49 PM, Ista Zahn <istazahn@gmail.com> wrote:
> On Sun, Jan 5, 2014 at 8:40 AM, John Kitchin <jkitchin@andrew.cmu.edu>
> wrote:
> > Try this:
> >
> >
> > (org-map-entries
> > (lambda ()
> > (let ((level (nth 1 (org-heading-components)))
> > (title (nth 4 (org-heading-components))))
> > (if (= level 1)
> > (org-entry-put (point) ":EXPORT_FILE_NAME:"
> title))))
> > nil nil)
> >
> > It seems to do what you want.
>
> Dear John,
>
> Thank you thank you! Using your code as I template I managed to write
> a function that does what I wanted:
>
> (defun my-exp-headings-to-markdown ()
> "Export each top-level heading to markdown."
> (interactive)
> (org-map-entries
> (lambda ()
> (let ((level (nth 1 (org-heading-components)))
> (title (nth 4 (org-heading-components))))
> (if (= level 1)
> (org-entry-put (point) "EXPORT_FILE_NAME" title))
> (if (= level 1)
> (org-md-export-to-markdown nil 1 nil))))
> nil nil))
>
> Note that I had to remove the ":" from the second argument to
> "org-entry-put" to get it working properly on my system. Not sure if
> that was a bug in your original example or not.
>
> Best,
> Ista
>
> >
> > John
> >
> > -----------------------------------
> > John Kitchin
> > Associate Professor
> > Doherty Hall A207F
> > Department of Chemical Engineering
> > Carnegie Mellon University
> > Pittsburgh, PA 15213
> > 412-268-7803
> > http://kitchingroup.cheme.cmu.edu
> >
> >
> >
> > On Sat, Jan 4, 2014 at 7:36 PM, Ista Zahn <istazahn@gmail.com> wrote:
> >>
> >> On Sat, Jan 4, 2014 at 6:41 PM, Alan L Tyree <alantyree@gmail.com>
> wrote:
> >> > On 05/01/14 09:45, Charles Millar wrote:
> >> >>
> >> >> Ista and all,
> >> >>
> >> >> On 1/4/2014 5:29 PM, Ista Zahn wrote:
> >> >>>
> >> >>> Hi all,
> >> >>>
> >> >>> I'm looking for a way to export each top-level heading to a separate
> >> >>> markdown file. Ideally I would like to have the exported files named
> >> >>> according to the heading. For example I would like this org file
> >> >>>
> >> >>> -----------------------------------
> >> >>> * Section one
> >> >>> Section one text
> >> >>> * Section two
> >> >>> ** Section two a
> >> >>> Section two text
> >> >>> * Section three
> >> >>> Section three text
> >> >>> -----------------------------------
> >> >>>
> >> >>> To generate three files:
> >> >>>
> >> >>> --- Section one.md ---
> >> >>> Section one text
> >> >>>
> >> >>> -----------------------------------
> >> >>>
> >> >>> --- Section two.md---
> >> >>> ## Section two a
> >> >>>
> >> >>> Section two text
> >> >>>
> >> >>> -----------------------------------
> >> >>>
> >> >>> --- Section three.md -
> >> >>> # Section three
> >> >>>
> >> >>> Section three text
> >> >>>
> >> >>> -----------------------------------
> >> >>>
> >> >>> I suspect that the publishing framework might support this, but I've
> >> >>> thus far avoided it because it looks pretty complicated to set up.
> >> >>> Before I dive in I'd like to know if the publishing framework is the
> >> >>> correct place to look for this functionality or if there is an
> easier
> >> >>> way to do it.
> >> >>>
> >> >>>
> >> >>
> >> >> I have a similar question regarding LaTeX export. How to export a
> >> >> heading
> >> >> (any heading, regardless of level) within a file to heading.tex
> instead
> >> >> of
> >> >> file.tex? So far the only solution I have cobbled together is to C-x
> >> >> C-f
> >> >> 'file.tex" and then C-x C-w "heading.tex" . I then typeset
> heading.tex
> >> >> using TeXworks. Perhaps I should note that my exported heading is
> >> >> tagged so
> >> >> that the heading is ignored.
> >> >>
> >> >> Charlie Millar
> >> >>
> >> >> ---
> >> >> This email is free from viruses and malware because avast! Antivirus
> >> >> protection is active.
> >> >> http://www.avast.com
> >> >>
> >> >>
> >> >>
> >> > Use properties to set the export file name -- example:
> >> > :PROPERTIES:
> >> > :EXPORT_TITLE: Internet banking fraud
> >> > :EXPORT_FILE_NAME: internet-fraud
> >> > :EXPORT_AUTHOR: Alan L Tyree
> >> > :Citation: (2011) 22 JBFLP 214
> >> > :EXPORT_OPTIONS: num:nil toc:nil
> >> > :END:
> >>
> >> Thanks, gets me half the way there. Setting properties as you
> >> described and exporting each sub-tree works properly. Now how can I do
> >> this for all the top-level headings in a file?
> >>
> >> Best,
> >> Ista
> >>
> >> >
> >> > If I understood your question properly.
> >> >
> >> > Cheers,
> >> > Alan
> >> >
> >> >
> >> >
> >> > --
> >> > Alan L Tyree http://www2.austlii.edu.au/~alan
> >> > Tel: 04 2748 6206 sip:typhoon@iptel.org
> >> >
> >> >
> >>
> >
>
[-- Attachment #2: Type: text/html, Size: 8634 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Export each top level heading to separate file
2014-01-05 21:56 ` John Kitchin
@ 2014-01-06 0:55 ` Ista Zahn
0 siblings, 0 replies; 11+ messages in thread
From: Ista Zahn @ 2014-01-06 0:55 UTC (permalink / raw)
To: John Kitchin; +Cc: emacs-orgmode Mailinglist, Alan L Tyree
On Sun, Jan 5, 2014 at 4:56 PM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> hmm.. I don't know if it was a bug, I ran the code on my system before
> sending it, and it worked for me ;)
Your original code ran for me as well, but it inserted
'::EXPORT_FILE_NAME::' where it should be just ':EXPORT_FILE_NAME:'
I am glad you figured it out on your
> system.
>
> you could avoid the double if statements like this:
>
>
> (defun my-exp-headings-to-markdown ()
> "Export each top-level heading to markdown."
> (interactive)
> (org-map-entries
> (lambda ()
> (let ((level (nth 1 (org-heading-components)))
> (title (nth 4 (org-heading-components))))
> (when (= level 1)
> (org-entry-put (point) "EXPORT_FILE_NAME" title)
> (org-md-export-to-markdown nil 1 nil)))))
> nil nil))
Great, thanks!
Best,
Ista
>
>
> The when macro is like an if macro, with no else body.
>
> John
>
> -----------------------------------
> John Kitchin
> Associate Professor
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> http://kitchingroup.cheme.cmu.edu
>
>
>
> On Sun, Jan 5, 2014 at 2:49 PM, Ista Zahn <istazahn@gmail.com> wrote:
>>
>> On Sun, Jan 5, 2014 at 8:40 AM, John Kitchin <jkitchin@andrew.cmu.edu>
>> wrote:
>> > Try this:
>> >
>> >
>> > (org-map-entries
>> > (lambda ()
>> > (let ((level (nth 1 (org-heading-components)))
>> > (title (nth 4 (org-heading-components))))
>> > (if (= level 1)
>> > (org-entry-put (point) ":EXPORT_FILE_NAME:"
>> > title))))
>> > nil nil)
>> >
>> > It seems to do what you want.
>>
>> Dear John,
>>
>> Thank you thank you! Using your code as I template I managed to write
>> a function that does what I wanted:
>>
>> (defun my-exp-headings-to-markdown ()
>> "Export each top-level heading to markdown."
>> (interactive)
>> (org-map-entries
>> (lambda ()
>> (let ((level (nth 1 (org-heading-components)))
>> (title (nth 4 (org-heading-components))))
>> (if (= level 1)
>> (org-entry-put (point) "EXPORT_FILE_NAME" title))
>> (if (= level 1)
>> (org-md-export-to-markdown nil 1 nil))))
>> nil nil))
>>
>> Note that I had to remove the ":" from the second argument to
>> "org-entry-put" to get it working properly on my system. Not sure if
>> that was a bug in your original example or not.
>>
>> Best,
>> Ista
>>
>> >
>> > John
>> >
>> > -----------------------------------
>> > John Kitchin
>> > Associate Professor
>> > Doherty Hall A207F
>> > Department of Chemical Engineering
>> > Carnegie Mellon University
>> > Pittsburgh, PA 15213
>> > 412-268-7803
>> > http://kitchingroup.cheme.cmu.edu
>> >
>> >
>> >
>> > On Sat, Jan 4, 2014 at 7:36 PM, Ista Zahn <istazahn@gmail.com> wrote:
>> >>
>> >> On Sat, Jan 4, 2014 at 6:41 PM, Alan L Tyree <alantyree@gmail.com>
>> >> wrote:
>> >> > On 05/01/14 09:45, Charles Millar wrote:
>> >> >>
>> >> >> Ista and all,
>> >> >>
>> >> >> On 1/4/2014 5:29 PM, Ista Zahn wrote:
>> >> >>>
>> >> >>> Hi all,
>> >> >>>
>> >> >>> I'm looking for a way to export each top-level heading to a
>> >> >>> separate
>> >> >>> markdown file. Ideally I would like to have the exported files
>> >> >>> named
>> >> >>> according to the heading. For example I would like this org file
>> >> >>>
>> >> >>> -----------------------------------
>> >> >>> * Section one
>> >> >>> Section one text
>> >> >>> * Section two
>> >> >>> ** Section two a
>> >> >>> Section two text
>> >> >>> * Section three
>> >> >>> Section three text
>> >> >>> -----------------------------------
>> >> >>>
>> >> >>> To generate three files:
>> >> >>>
>> >> >>> --- Section one.md ---
>> >> >>> Section one text
>> >> >>>
>> >> >>> -----------------------------------
>> >> >>>
>> >> >>> --- Section two.md---
>> >> >>> ## Section two a
>> >> >>>
>> >> >>> Section two text
>> >> >>>
>> >> >>> -----------------------------------
>> >> >>>
>> >> >>> --- Section three.md -
>> >> >>> # Section three
>> >> >>>
>> >> >>> Section three text
>> >> >>>
>> >> >>> -----------------------------------
>> >> >>>
>> >> >>> I suspect that the publishing framework might support this, but
>> >> >>> I've
>> >> >>> thus far avoided it because it looks pretty complicated to set up.
>> >> >>> Before I dive in I'd like to know if the publishing framework is
>> >> >>> the
>> >> >>> correct place to look for this functionality or if there is an
>> >> >>> easier
>> >> >>> way to do it.
>> >> >>>
>> >> >>>
>> >> >>
>> >> >> I have a similar question regarding LaTeX export. How to export a
>> >> >> heading
>> >> >> (any heading, regardless of level) within a file to heading.tex
>> >> >> instead
>> >> >> of
>> >> >> file.tex? So far the only solution I have cobbled together is to C-x
>> >> >> C-f
>> >> >> 'file.tex" and then C-x C-w "heading.tex" . I then typeset
>> >> >> heading.tex
>> >> >> using TeXworks. Perhaps I should note that my exported heading is
>> >> >> tagged so
>> >> >> that the heading is ignored.
>> >> >>
>> >> >> Charlie Millar
>> >> >>
>> >> >> ---
>> >> >> This email is free from viruses and malware because avast! Antivirus
>> >> >> protection is active.
>> >> >> http://www.avast.com
>> >> >>
>> >> >>
>> >> >>
>> >> > Use properties to set the export file name -- example:
>> >> > :PROPERTIES:
>> >> > :EXPORT_TITLE: Internet banking fraud
>> >> > :EXPORT_FILE_NAME: internet-fraud
>> >> > :EXPORT_AUTHOR: Alan L Tyree
>> >> > :Citation: (2011) 22 JBFLP 214
>> >> > :EXPORT_OPTIONS: num:nil toc:nil
>> >> > :END:
>> >>
>> >> Thanks, gets me half the way there. Setting properties as you
>> >> described and exporting each sub-tree works properly. Now how can I do
>> >> this for all the top-level headings in a file?
>> >>
>> >> Best,
>> >> Ista
>> >>
>> >> >
>> >> > If I understood your question properly.
>> >> >
>> >> > Cheers,
>> >> > Alan
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Alan L Tyree http://www2.austlii.edu.au/~alan
>> >> > Tel: 04 2748 6206 sip:typhoon@iptel.org
>> >> >
>> >> >
>> >>
>> >
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Export each top level heading to separate file
@ 2014-01-06 1:51 Marvin Doyley
0 siblings, 0 replies; 11+ messages in thread
From: Marvin Doyley @ 2014-01-06 1:51 UTC (permalink / raw)
To: emacs-orgmode
This may help, but I can’t take the credit. Someone in this forum wrote this for me several years ago.
Cheers,
M
;; turn header into file
(defun turn-headline-into-org-mode-link ()
"Replace word at point by an Org mode link."
(interactive)
(when (org-at-heading-p)
(let ((hl-text (nth 4 (org-heading-components))))
(unless (or (null hl-text)
(org-string-match-p "^[ \t]*:[^:]+:$" hl-text))
(beginning-of-line)
(search-forward hl-text (point-at-eol))
(replace-string
hl-text
(format "[[file:%s.org][%s]]"
(org-link-escape hl-text)
(org-link-escape hl-text '((?\] . "%5D") (?\[ . "%5B"))))
nil (- (point) (length hl-text)) (point))))))
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-01-06 1:51 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-04 22:29 Export each top level heading to separate file Ista Zahn
2014-01-04 22:45 ` Charles Millar
2014-01-04 23:41 ` Alan L Tyree
2014-01-05 0:36 ` Ista Zahn
2014-01-05 2:44 ` Alan L Tyree
2014-01-05 13:40 ` John Kitchin
2014-01-05 19:49 ` Ista Zahn
2014-01-05 21:56 ` John Kitchin
2014-01-06 0:55 ` Ista Zahn
2014-01-05 18:34 ` Charles Millar
-- strict thread matches above, loose matches on Subject: below --
2014-01-06 1:51 Marvin Doyley
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).