[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Possible to use src block to generate org headlines for export?
From: |
Matt Lundin |
Subject: |
Re: [O] Possible to use src block to generate org headlines for export? |
Date: |
Wed, 23 Jul 2014 10:17:36 -0500 |
User-agent: |
Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) |
Hi Brett,
Brett Viren <address@hidden> writes:
> Matt Lundin <address@hidden> writes:
>
>> Let's hope the real blog (when I get around to publishing it) is more
>> interesting than the example above. ;)
>
> Maybe it would be more convenient to add the "meta-ness" you want as
> part of a new exporter process?
To change the "meta" wrappers for code block results, we would have to
modify org babel (ob-core.el). Right now, the only wrapper that org
babel uses to contain the results of *raw* org output is a :RESULTS:
drawer. However, headlines wrapped in a drawer is something that
org-element, by definition, cannot recognize. For the same reason, no
custom export backend is going to be able to recognize this element.
But I've discovered to my delight all this is moot.
The *best and simplest solution* for automatically generating org
headlines for export is...
...never to execute the source block by hand in org source file. That
way, the results will appear only in the *temporary* copy of the buffer
is parsed for export and one does need to worry about demarcating the
output with a :RESULTS: drawer...
--8<---------------cut here---------------start------------->8---
#+BEGIN_SRC perl :exports results :results output org raw
[code to generate org source]
#+END_SRC
--8<---------------cut here---------------end--------------->8---
The above works perfectly so long I as resist the temptation to hit C-c
C-c.[fn:1]
And that can be solved easily by adding the following line to the top of
the file:
--8<---------------cut here---------------start------------->8---
# -*- org-babel-no-eval-on-ctrl-c-ctrl-c: t; -*-
--8<---------------cut here---------------end--------------->8---
Isn't emacs wonderful?
In short, it is much easier than I assumed to use babel blocks (and any
language one wants) to generate org headlines destined for publishing.
This is amazing! The applications are endless. E.g., I will use this to
generate a blog summary when publishing my website. I'll post a tutorial
sometime soon. Suffice it to say, one can easily use babel blocks to
generate content on a web page, thus implementing the functionality of a
static site generator like Jekyll, docpad, octopress, etc. (but with
infinitely more flexibility).
Best,
Matt
Footnotes:
[fn:1] If one really needs to see the headlines in the original org
buffer, a hook can be used to remove the :RESULTS: drawer.
--8<---------------cut here---------------start------------->8---
(defun my-remove-stray-results-drawer (backend)
(when (eq backend 'html)
(while (re-search-forward "^\\s-*:RESULTS:\\s-*\n" nil t)
(replace-match ""))))
(add-hook 'org-export-before-parsing-hook 'my-remove-results-drawer)
--8<---------------cut here---------------end--------------->8---
- [O] Possible to use src block to generate org headlines for export?, Matt Lundin, 2014/07/22
- Re: [O] Possible to use src block to generate org headlines for export?, Nick Dokos, 2014/07/22
- Re: [O] Possible to use src block to generate org headlines for export?, Matt Lundin, 2014/07/22
- Re: [O] Possible to use src block to generate org headlines for export?, Matt Lundin, 2014/07/22
- Re: [O] Possible to use src block to generate org headlines for export?, Brett Viren, 2014/07/23
- Re: [O] Possible to use src block to generate org headlines for export?,
Matt Lundin <=
- Re: [O] Possible to use src block to generate org headlines for export?, Charles Berry, 2014/07/23
- Re: [O] Possible to use src block to generate org headlines for export?, Matt Lundin, 2014/07/23
- Re: [O] Possible to use src block to generate org headlines for export?, Nick Dokos, 2014/07/23
- Re: [O] Possible to use src block to generate org headlines for export?, Andreas Leha, 2014/07/24
- Re: [O] Possible to use src block to generate org headlines for export?, Nicolas Goaziou, 2014/07/25
- Re: [O] Possible to use src block to generate org headlines for export?, Andreas Leha, 2014/07/25
- Re: [O] Possible to use src block to generate org headlines for export?, Nicolas Goaziou, 2014/07/25
- Re: [O] Possible to use src block to generate org headlines for export?, Andreas Leha, 2014/07/25
- Re: [O] Possible to use src block to generate org headlines for export?, Thorsten Jolitz, 2014/07/25
- Re: [O] Possible to use src block to generate org headlines for export?, Nicolas Goaziou, 2014/07/25