jgm / pandoc

Universal markup converter
https://pandoc.org
Other
33.3k stars 3.31k forks source link

org-mode "Exporting code blocks" rules #2167

Closed fommil closed 9 years ago

fommil commented 9 years ago

As briefly discussed on the mailing list, pandoc currently doesn't support hiding of org-mode source code blocks when a RESULTS section exists. Some background here:

http://orgmode.org/manual/Exporting-code-blocks.html#Exporting-code-blocks

some SRC blocks in org-mode default to the results only mode (e.g. ditaa like in the following)

#+BEGIN_SRC ditaa :file images/architecture.png
                                                      +---------+
                                 /----------------\   |Lucene{s}|
                                 |Search          +---+---------+
                                 +----------------+   |  H2 {s} |
         SWANK                   |Source Resolver |   +---------+
          |                      +----------------+
 +-----+  :  +--------------+    |Doc Server      |   +--------+
 |Emacs|<--->|   Project    +----+----------------+   | JVM{io}|
 +-----+  |  +---+----------+ |  |Debug Manager   +---+--------+
          :      |        ^   :  +----------------+
          |  +---+----+   |   |  |Analyzer        +---+-----------+
          |  |File{io}|   |   |  \----------------/   |scalac     |
          |  |Watchers|   |   |                       +-----------+
          |  +--------+   |   |  /----------\         |Refactoring|
          |    ^          |   +--+Formatting|         +-----------+
          |    |          |      \----------/
          +----|-=--------|-=------------------------------------
      +-----+  |   +------++
      |Files+--+   |.ensime|
      +-----+      +-------+
#+END_SRC

#+RESULTS:
[[file:images/architecture.png]]

but I'd be happy enough if the source block could be ignored with an explicit section like this (which is consistent, although redundant, in stock org-mode)

#+HEADERS: :exports results
tarleb commented 9 years ago

I'll try to fix this over the weekend. Please ping me on Sunday afternoon if nothing has happened yet.

fommil commented 9 years ago

@rorygraves this will help us with our talk

tarleb commented 9 years ago

Hi Sam,

Implementing full #+HEADERS support would be very involved, which is why I cleaned up some existing code instead.

The code in PR #2170 allows to specify the export preferences directly in the opening code block line. The PR fixes a bug which forced unnecessary restrictions on the #+RESULTS block. The following should work as expected:

#+BEGIN_SRC ditaa :file images/architecture.png :exports results
…
#+END_SRC

#+RESULTS:
[[file:images/architecture.png]]

Is this an acceptable workaround for your use cases?

fommil commented 9 years ago

@tarleb cool! That sounds like it'll be fine as a workaround.

fommil commented 9 years ago

awesome, I got your branch built (I rebased against master) and this is working... thank you so much!

tarleb commented 9 years ago

Great! :smiley: The patches already made their way into the upstream master, my separate branch thus became reduncant. The new features will probably be part of the upcoming Pandoc 1.14 release. Good luck with your presentation!

fommil commented 9 years ago

fantastic stuff, I didn't realise they were merged already