1

This question already has an answer here:

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
#+END_SRC

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.

Thanks.

marked as duplicate by Scott Weldon, Drew, erikstokes, zck, Community Feb 24 '16 at 15:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4

Try:

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

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

0

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'
#+END_SRC

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