I'm new to org-mode, so I apologize if this is a silly question, but I couldn't find the answer on my own.

I have the following block:

#+BEGIN_SRC sh :exports both :results output verbatim code
sed '/^elts/,$p' -n Heap03.hs

The goal is to use a shell script to get a block of Haskell code. Unfortunately (though unsurprisingly) the result is interpreted as shell code.

On the one hand, I'd be interested in any answer that explains how to programmatically get/generate some text and then treat it as code (for the purposes of highlighting) in an arbitrary language; on the other hand, I'm wondering if there's some additional parameter I can pass to the begin_src block to control the language of the rendered code separately from the language of the executed code.




#+BEGIN_SRC sh :exports both :results output :wrap SRC haskell
sed '/^elts/,$p' -n Heap03.hs

Assuming you have haskell setup in org-mode, that should do it.


Huh... I thought I'd tried this before and it didn't work...

Apparently, one simple solution is this:

#+BEGIN_SRC sh :exports both :results output verbatim raw
echo '#+BEGIN_SRC haskell'
sed '/^elts/,$p' -n Heap03.hs
echo '#+END_SRC'

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