emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Baum <maabaum@gmail.com>
To: Sean O'Halpin <sean.ohalpin@gmail.com>
Cc: Sebastien Vauban <wxhgmqzgwmuf@spammotel.com>, emacs-orgmode@gnu.org
Subject: Re: How to pass a block of text to a code block as data?
Date: Mon, 11 Feb 2013 16:49:11 -0500	[thread overview]
Message-ID: <CA+G3xFgKiGfOJUtkYVtSNjXuAU2JodHhsQGT2pSYqXjQcXy4vA@mail.gmail.com> (raw)
In-Reply-To: <CAOXM+eWpMtt90xfa67iNrvTa_NdR=PS61mZwyfobyKFOLosn4Q@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4768 bytes --]

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 <maabaum@gmail.com>

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

[-- Attachment #2: Type: text/html, Size: 5433 bytes --]

  reply	other threads:[~2013-02-11 21:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-08 17:06 How to pass a block of text to a code block as data? Michael Baum
2013-02-08 20:17 ` Sebastien Vauban
2013-02-09  2:59   ` Michael Baum
2013-02-09 18:49     ` Sean O'Halpin
2013-02-11 21:49       ` Michael Baum [this message]
2013-02-11 22:07         ` Eric Schulte

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=CA+G3xFgKiGfOJUtkYVtSNjXuAU2JodHhsQGT2pSYqXjQcXy4vA@mail.gmail.com \
    --to=maabaum@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=sean.ohalpin@gmail.com \
    --cc=wxhgmqzgwmuf@spammotel.com \
    /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).