(Follow-up to Is there a way to use org-mode to render generated code?)
#+BEGIN_SRC sh :exports results :results output :wrap SRC haskell
sed '/^elts/,$p' -n Heap03.hs
#+END_SRC
lets me extract Haskell code from a file to show in org-mode's export. It's effectively a safer and more idiomatic version of the hack I came up with:
#+BEGIN_SRC sh :exports results :results output verbatim raw
echo '#+BEGIN_SRC haskell'
sed '/^elts/,$p' -n Heap03.hs
echo '#+END_SRC'
#+END_SRC
Now I want more abstraction. For example:
#+NAME: inline
#+BEGIN_SRC sh :exports none :results output verbatim raw
echo '#+BEGIN_SRC haskell'
echo "[[./$FILE][$FILE]]"
sed '/^elts/,$p' -n $FILE
echo '#+END_SRC'
#+END_SRC
#+CALL: inline(FILE="Heap01.hs")
#+CALL: inline(FILE="Heap02.hs")
The two criteria I'm trying to satisfy (and having trouble) are:
- I should have a link to the file automatically inserted above the Haskell code.
- The call should be as minimal as possible.
I haven't figured out how to get the first criterion satisfied using :wrap
, and the best I can do toward the second criterion is #+CALL: inline(FILE="Heap01.hs") :wrap SRC haskell
, which is just a bit too heavyweight for my taste.
Thanks!