emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How to pass a block of text to a code block as data?


From: Michael Baum
Subject: Re: [O] How to pass a block of text to a code block as data?
Date: Mon, 11 Feb 2013 16:49:11 -0500

Sean, that helps too, thank you. Now that you and Sebastien have gone to all this trouble I found the part of the manual that sort of describes this, but I clearly didn't understand it before. Possible needs a more worked-out example for the slow among us, like self.

I've noticed one curious thing in trying a perl example. See first:

---------------------8<----------------------------------
#+name: wake
#+BEGIN_EXAMPLE
    riverrun, past Eve and Adam's, from swerve of shore to bend
of bay, brings us by a commodius vicus of recirculation back to
Howth Castle and Environs.
    Sir Tristram, violer d'amores, fr'over the short sea, had passen-
core rearrived from North Armorica on this side the scraggy
isthmus of Europe Minor to wielderfight his penisolate war: nor
had topsawyer's rocks by the stream Oconee exaggerated themselse
to Laurens County's gorgios while they went doublin their mumper
all the time: nor avoice from afire bellowsed mishe mishe to
#+END_EXAMPLE

#+begin_src perl :var inlines=wake :results output
  foreach $aln (split(/$/,$inlines)) {
       print $aln;
  }
#+end_src


#+results:
: riverrun, past Eve and Adam's, from swerve of shore to bend
: of bay, brings us by a commodius vicus of recirculation back to
: Howth Castle and Environs.
:     Sir Tristram, violer d'amores, fr'over the short sea, had passen-
: core rearrived from North Armorica on this side the scraggy
: isthmus of Europe Minor to wielderfight his penisolate war: nor
: had topsawyer's rocks by the stream Oconee exaggerated themselse
: to Laurens County's gorgios while they went doublin their mumper
: all the time: nor avoice from afire bellowsed mishe mishe to

---------------------8<----------------------------------

and then a more complicated block that's closer to my real task:

---------------------8<----------------------------------

#+NAME: job2
#+BEGIN_EXAMPLE
!START
!ID:7655
!DATE:02/10/2013
!CLOSE:03/15/2013
!UNTILFILLED:
!POSITION:Science Editor
!COMPANY:East Newark Times Herald News and World Defender
!BEGIN-DESCRIPTION
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

!END-DESCRIPTION
!BEGIN-SPECIAL
Duis eget lorem ac odio lobortis suscipit nec et neque. Sed at quam ut mauris scelerisque congue id eget dui. Quisque tellus lectus, tristique eu posuere in, faucibus vitae urna. Duis vitae orci purus, quis euismod augue.
!END-SPECIAL
!SALARY:16.67 per hour
!BEGIN-CONTACT
Please submit online at  http://enthnawd.org/jobs
!END-CONTACT
!END
#+END_EXAMPLE


#+begin_src perl :var inlines=job2 :results output
  foreach $aln (split(/$/,$inlines)) {
       print $aln;
  }
#+end_src

#+results:
#+begin_example
!START
!ID:7655
!DATE:02/10/2013
!CLOSE:03/15/2013
!UNTILFILLED:
!POSITION:Science Editor
!COMPANY:East Newark Times Herald News and World Defender
!BEGIN-DESCRIPTION
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

!END-DESCRIPTION
!BEGIN-SPECIAL
Duis eget lorem ac odio lobortis suscipit nec et neque. Sed at quam ut mauris scelerisque congue id eget dui. Quisque tellus lectus, tristique eu posuere in, faucibus vitae urna. Duis vitae orci purus, quis euismod augue.
!END-SPECIAL
!SALARY:16.67 per hour
!BEGIN-CONTACT
Please submit online at  http://enthnawd.org/jobs
!END-CONTACT
!END
#+end_example

---------------------8<----------------------------------

NOTICE THAT while both return the result as Example text, the first simple prepends each line with a colon, simple Example form, and the second wraps the result in an Example block without altering the lines.

Not sure why? Is this just a function of the number of lines of the text?

Michael


--
====================================
Michael Baum <address@hidden>

You should never have your best trousers on when you go out
 to fight for freedom and truth. - Ibsen
reply via email to

[Prev in Thread] Current Thread [Next in Thread]