emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* 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-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).