emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Babel: filtering code to produce another block
@ 2017-09-13  8:34 Jarmo Hurri
  0 siblings, 0 replies; only message in thread
From: Jarmo Hurri @ 2017-09-13  8:34 UTC (permalink / raw)
  To: emacs-orgmode


Greetings.

This question can again be described shortly and in more detail.

1. Short form: what would be a convenient way to filter the source
   code in a Babel source code block so that the output would be the
   source code in another block?

2. Then the long form. I need to emulate the very basics of one
   programming language, namely Processing

   https://processing.org/

   with another, namely Asymptote

   http://asymptote.sourceforge.net/

   This is to be done within Org. I need to do this to illustrate on
   paper the visual output of simple, static (no animation) Processing
   programs.

   Making this work roughly isn't too difficult, because these two
   languages have very similar syntaxes. For example, provided that a
   function rect() has been implemented in Asymptote, the following
   code is legit in both Processing and Asymptote:

   #+name: pic
   #+BEGIN_SRC asymptote
     size (800, 600);
     for (int i = 0; i < 10; i += 2)
       rect (i * 10, i * 20, 30, 10);
   #+END_SRC

   After this block has been defined I can show it as "Processing
   code" and draw a picture with Asymptote, using noweb if need be. It
   is also easy to use transforms so that the coordinate systems of
   the two languages match. Furthermore, typedef can be used to align
   some variable type differences.

   However, my current issue is dealing with 'final' in Asymptote. The
   following is not legit Asymptote code:
   #+BEGIN_SRC asymptote
     size (800, 600);
     final int S = 20;
     rect (100, 100, S, S);
   #+END_SRC
   
   It would be legit if the word 'final' were simply removed. Which
   brings me to the question: what would be an easy way to filter this
   block to produce another block? The header arguments of the two
   blocks would be different from each other.

Thanks in advance,

Jarmo

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-09-13  8:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-13  8:34 Babel: filtering code to produce another block Jarmo Hurri

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).