emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Juan Manuel Macías" <maciaschain@posteo.net>
To: Galaxy Being <borgauf@gmail.com>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: Format babel code block for export?
Date: Wed, 02 Jun 2021 09:42:37 +0000	[thread overview]
Message-ID: <87o8co61rm.fsf@posteo.net> (raw)
In-Reply-To: <CAFAhFSVk6=7pJy0xk1V2ERcTpAUDaQ9OVKUcRn8OKZEbKisPAg@mail.gmail.com> (Galaxy Being's message of "Tue, 1 Jun 2021 21:03:47 -0500")

Hi Lawrence,

You can use multiple blocks and noweb reference syntax
(https://orgmode.org/manual/Noweb-Reference-Syntax.html):

#+NAME:block1
#+begin_src haskell :results silent :exports none
:{
#+end_src

#+NAME:block2
#+begin_src haskell :results silent :exports none
maximum'' :: (Ord a) => [a] -> a
maximum'' = foldl1 (\x acc -> if x > acc then x else acc)
#+end_src

#+NAME:block3
#+begin_src haskell :results silent :exports none
:}
#+end_src

# for export

#+begin_src haskell :noweb yes :exports code
<<block2>>
#+end_src

# for evaluation

#+begin_src haskell :noweb yes :results silent :exports none
<<block1>>
<<block2>>
<<block3>>
#+end_src

Best regards,

Juan Manuel

Galaxy Being <borgauf@gmail.com> writes:

> I have this
>
> #+begin_src haskell :results silent :exports code
> :{
> maximum'' :: (Ord a) => [a] -> a
> maximum'' = foldl1 (\x acc -> if x > acc then x else acc)
> :}
> #+end_src
>
> but on export to HTML (or LaTex) I'd like to suppress the :{ and :} to
> just show the code
>
> maximum'' :: (Ord a) => [a] -> a
> maximum'' = foldl1 (\x acc -> if x > acc then x else acc)
>
> Also, this
>
> #+begin_src haskell :results verbatim :exports both
> maximum'' [1,3,5,2,4]
> #+end_src
>
> I'd like to export the code part with a > REPL prompt included, e.g.,
>
>> maximum'' [1,3,5,2,4]
>
> I once saw some similar tricks, but I've searched and searched and
> can't find them again. There's probably other html export formatting
> I'd like too, but if anyone can point me to that mystery doc I'd
> appreciate it.
>
> ⨽
> Lawrence Bottorff
> Grand Marais, MN, USA
> borgauf@gmail.com
>


      reply	other threads:[~2021-06-02  9:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02  2:03 Format babel code block for export? Galaxy Being
2021-06-02  9:42 ` Juan Manuel Macías [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o8co61rm.fsf@posteo.net \
    --to=maciaschain@posteo.net \
    --cc=borgauf@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).