From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jacob Gerlach Subject: Export code and results in one environment Date: Fri, 22 May 2015 02:54:21 +0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d0421a997ef09880516a2c6f3 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yvd6N-0003OE-Qv for emacs-orgmode@gnu.org; Thu, 21 May 2015 22:54:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yvd6M-0000KG-RZ for emacs-orgmode@gnu.org; Thu, 21 May 2015 22:54:23 -0400 Received: from mail-ie0-x229.google.com ([2607:f8b0:4001:c03::229]:36105) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yvd6M-0000K6-Ms for emacs-orgmode@gnu.org; Thu, 21 May 2015 22:54:22 -0400 Received: by iepj10 with SMTP id j10so22395048iep.3 for ; Thu, 21 May 2015 19:54:21 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org-mode --f46d0421a997ef09880516a2c6f3 Content-Type: text/plain; charset=UTF-8 Hello, I'd like to export a source block and it's results together in one latex environment. I came up with a solution using the final filter below. Is there a better way? Thanks, Jake #+BEGIN_SRC emacs-lisp :exports none :results silent (defun combine-verb-final-filter (s backend info) (when (eq backend 'latex) (replace-regexp-in-string "\\\\end{verbatim}\n*\\\\begin{verbatim}" "" s nil t))) (add-to-list 'org-export-filter-final-output-functions 'combine-verb-final-filter) #+END_SRC Works, given: -------------------------------------- #+BEGIN_SRC sh :exports both echo "Hello" #+END_SRC #+RESULTS: : Hello -------------------------------------- Produces (desired effect): -------------------------------------- \begin{verbatim} echo "Hello" Hello \end{verbatim} -------------------------------------- --f46d0421a997ef09880516a2c6f3 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello,

I'd like to export a source = block and it's results together in one latex environment. I came up wit= h a solution using the final filter below.

Is ther= e a better way?

Thanks,
Jake
<= br>
=C2=A0 #+BEGIN_SRC emacs-lisp :exports none :results sil= ent
=C2=A0 =C2=A0 (defun combine-verb-final-filter (s backend inf= o)
=C2=A0 =C2=A0 =C2=A0 (when (eq backend 'latex)
= =C2=A0 =C2=A0 =C2=A0 (replace-regexp-in-string "\\\\end{verbatim}\n*\\= \\begin{verbatim}"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &quo= t;"=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 s nil t)))
=C2=A0 =C2=A0 (add-to-list 'org-export-filter-final-output-fun= ctions 'combine-verb-final-filter)
=C2=A0 #+END_SRC

Works, given:
------------------------= --------------
#+BEGIN_SRC sh :exports both
echo "= Hello"
#+END_SRC

#+RESULTS:
: Hello
--------------------------------------
Produces (desired effect):
-------------------------------------= -
\begin{verbatim}
echo "Hello"

Hello
\end{verbatim}
-----------= ---------------------------
--f46d0421a997ef09880516a2c6f3--