I'm writing a screenplay using Fountain mode. My org file is set up so there are multiple screenplays in a given file, for example

* Number one!
#+begin_src fountain

  Being desirous of allaying the dissensions of party strife now existing within our realm, I do hereby dissolve and abolish the Democratic and Republican parties.

* Number two!
#+begin_src fountain

  You are advised to submit without further delay, for if I bring my army into your land, I will destroy your farms, slay your people, and raze your city.

  letter is replaced


I want to run an external command to convert one of these screenplays into a pdf. Fountain mode does not have the export functionality I want. It currently has some, but it is being removed in a future release.

If I had the screenplay in a file by itself, I could run a command in bash using wrap: wrap pdf my-screenplay.fountain. But it's not in a file by itself; it's a single source block.

So I'd like to be able to run a command on this single source block.

No org feature I've looked at seems to do this cleanly, although I might be missing something. I've looked at Org export, Org tangle, and Org publish, but as far as I can tell, they only act on a file as a whole.

How can I pass the contents of a single source block to an external command? Ideally I'd also be able to get the name of the headline before the command, so I can name each exported pdf differently.


I'm not sure what you want, but if you want to export one of the headings to a PDF, you can export it by selecting the sub-heading in the export selection dialog. For example, if you have this:

* Number One

Put the cursor somewhere on or under the heading, and then C-c C-e C-s where the C-s selects sub-heading, and then choose your export format. PDF via LaTeX, or to plain text which you can then wrap, whatever that is.

The :PROPERTIES: and :EXPORT_FILE_NAME: is not required.

If you want to operate on the SRC block itself, I don't know anything about Fountain, but this works for me:

* Foo

#+NAME: f
#+BEGIN_QUOTE fountain
text here

#+BEGIN_SRC bash :var f=f
echo $f

: text here

That is, change your BEGIN_SRC fountain to BEGIN_EXAMPLE or BEGIN_QUOTE, add a #+NAME: to it, and you can then ingest your Fountain text into a Bash or Python block where you write only the contents of the Fountain source to another file. For example, instead of echo $f you could do echo $f > source.fountain and then wrap that.

| improve this answer | |
  • I'd rather not have to export to a separate file -- in that case, I might as well just be editing the file directly. For the #+BEGIN_QUOTE version, I can't seem to make it work. When I run it, I get the message "Code block produced no output.", and no output file is produced from the wrap call. Do you know of any ways to debug this? – zck Jan 29 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.