From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gary Oberbrunner Subject: Re: Is it possible to repeat a block of org-mode text on export, maybe with replacement? Date: Thu, 21 Nov 2013 18:23:20 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c20afcf1e10104ebb82e9f Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vjdas-0002TV-28 for emacs-orgmode@gnu.org; Thu, 21 Nov 2013 18:23:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vjdak-0008Mu-5k for emacs-orgmode@gnu.org; Thu, 21 Nov 2013 18:23:30 -0500 Received: from mail-oa0-f51.google.com ([209.85.219.51]:52904) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vjdaj-0008Mq-Vq for emacs-orgmode@gnu.org; Thu, 21 Nov 2013 18:23:22 -0500 Received: by mail-oa0-f51.google.com with SMTP id i7so547893oag.24 for ; Thu, 21 Nov 2013 15:23:21 -0800 (PST) In-Reply-To: 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: "Thomas S. Dye" Cc: Orgmode Mailing List --001a11c20afcf1e10104ebb82e9f Content-Type: text/plain; charset=ISO-8859-1 Thanks everyone! Much appreciated. I think I can get what I want by fiddling with these. Thomas, I'm not sure why but yours comes out with weird indentation which makes the first line not part of the list. Eric, yours doesn't seem to create a proper numbered list at all, but is otherwise just what I'm looking for. Thorsten, yours comes out looking great but having to Emacs-stringize the text is, well, you know... Again thanks all for your helpful suggestions! On Tue, Nov 19, 2013 at 12:19 PM, Thomas S. Dye wrote: > Hi Gary, > > I came up with this, which uses example blocks. > > #+name: example > #+begin_example > 1. this is the first line > 2. this is the second line with %VARIANT% as the value > 3. this is the third line > #+end_example > > #+name: repeated-text > #+header: :results raw > #+header: :var x="" > #+header: :var eg=example > #+begin_src emacs-lisp > (let ((result)) > (setf result (replace-regexp-in-string "%VARIANT%" x eg t)) > result) > #+end_src > > #+call: repeated-text(x="foo") :results raw > > #+results: > 1. this is the first line > 2. this is the second line with foo as the value > 3. this is the third line > > #+call: repeated-text(x="bar") :results raw > #+results: > 1. this is the first line > 2. this is the second line with bar as the value > 3. this is the third line > > #+call: repeated-text(x="baz") :results raw > > #+results: > 1. this is the first line > 2. this is the second line with baz as the value > 3. this is the third line > > All the best, > Tom > > Gary Oberbrunner writes: > > > I don't know if this is beyond the capabilities of org-mode or not. I'd > > like to have a block of text repeated multiple times with slight > > variations. For the sake of the example, a numbered list: > > > > 1. this is the first line > > 1. this is the second line with %VARIANT% as the value > > 1. this is the third line > > > > When exported, say as ASCII, I'd like this: > > > > 1. this is the first line > > 2. this is the second line with foo as the value > > 3. this is the third line > > > > 1. this is the first line > > 2. this is the second line with bar as the value > > 3. this is the third line > > > > 1. this is the first line > > 2. this is the second line with baz as the value > > 3. this is the third line > > > > I'm not sure how to go about this; I assume I'd use org-babel with source > > blocks that contain org-mode text or elisp or something. > > > > Of course if the right answer is I should write a python script to > generate > > my org-mode text, well, that's OK too. :-) > > > > -- > > Gary > > I don't know if this is beyond the capabilities of org-mode or not. I'd > > like to have a block of text repeated multiple times with slight > > variations. For the sake of the example, a numbered list: > > > > 1. this is the first line > > 1. this is the second line with %VARIANT% as the value > > 1. this is the third line > > > > When exported, say as ASCII, I'd like this: > > > > 1. this is the first line > > 2. this is the second line with foo as the value > > 3. this is the third line > > > > 1. this is the first line > > 2. this is the second line with bar as the value > > 3. this is the third line > > > > 1. this is the first line > > 2. this is the second line with baz as the value > > 3. this is the third line > > > > I'm not sure how to go about this; I assume I'd use org-babel with > > source blocks that contain org-mode text or elisp or something. > > > > Of course if the right answer is I should write a python script to > > generate my org-mode text, well, that's OK too. :-) > > -- > Thomas S. Dye > http://www.tsdye.com > -- Gary --001a11c20afcf1e10104ebb82e9f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Thanks everyone! =A0Much appreciated. I think I can get wh= at I want by fiddling with these. =A0Thomas, I'm not sure why but yours= comes out with weird indentation which makes the first line not part of th= e list. =A0Eric, yours doesn't seem to create a proper numbered list at= all, but is otherwise just what I'm looking for. =A0Thorsten, yours co= mes out looking great but having to Emacs-stringize the text is, well, you = know...

Again thanks all for your helpful suggestions!


On Tue, Nov 19,= 2013 at 12:19 PM, Thomas S. Dye <tsd@tsdye.com> wrote:
Hi Gary,

I came up with this, which uses example blocks.

#+name: example
#+begin_example
=A01. this is the first line
=A02. this is the second line with %VARIANT% as the value
=A03. this is the third line
#+end_example

#+name: repeated-text
#+header: :results raw
#+header: :var x=3D""
#+header: :var eg=3Dexample
#+begin_src emacs-lisp
=A0 (let ((result))
=A0 =A0 (setf result (replace-regexp-in-string "%VARIANT%" x eg t= ))
=A0 =A0 result)
#+end_src

#+call: repeated-text(x=3D"foo") :results raw

#+results:
1. this is the first line
=A02. this is the second line with foo as the value
=A03. this is the third line

#+call: repeated-text(x=3D"bar") :results raw
#+results:
1. this is the first line
=A02. this is the second line with bar as the value
=A03. this is the third line

#+call: repeated-text(x=3D"baz") :results raw

#+results:
1. this is the first line
=A02. this is the second line with baz as the value
=A03. this is the third line

All the best,
Tom

Gary Oberbrunner <garyo@oberbru= nner.com> writes:

> I don't know if this is beyond the capabilities of org-mode or not= . =A0I'd
> like to have a block of text repeated multiple times with slight
> variations. =A0For the sake of the example, a numbered list:
>
> 1. this is the first line
> 1. this is the second line with %VARIANT% as the value
> 1. this is the third line
>
> When exported, say as ASCII, I'd like this:
>
> 1. this is the first line
> 2. this is the second line with foo as the value
> 3. this is the third line
>
> 1. this is the first line
> 2. this is the second line with bar as the value
> 3. this is the third line
>
> 1. this is the first line
> 2. this is the second line with baz as the value
> 3. this is the third line
>
> I'm not sure how to go about this; I assume I'd use org-babel = with source
> blocks that contain org-mode text or elisp or something.
>
> Of course if the right answer is I should write a python script to gen= erate
> my org-mode text, well, that's OK too. :-)
>
> --
> Gary
> I don't know if this is beyond the capabilities of org-mode or not= . I'd
> like to have a block of text repeated multiple times with slight
> variations. For the sake of the example, a numbered list:
>
> 1. this is the first line
> 1. this is the second line with %VARIANT% as the value
> 1. this is the third line
>
> When exported, say as ASCII, I'd like this:
>
> 1. this is the first line
> 2. this is the second line with foo as the value
> 3. this is the third line
>
> 1. this is the first line
> 2. this is the second line with bar as the value
> 3. this is the third line
>
> 1. this is the first line
> 2. this is the second line with baz as the value
> 3. this is the third line
>
> I'm not sure how to go about this; I assume I'd use org-babel = with
> source blocks that contain org-mode text or elisp or something.
>
> Of course if the right answer is I should write a python script to
> generate my org-mode text, well, that's OK too. :-)

--
Thomas S. Dye http://www.tsdye.com=



-- Gary --001a11c20afcf1e10104ebb82e9f--