From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Is it possible to repeat a block of org-mode text on export, maybe with replacement? Date: Tue, 19 Nov 2013 09:36:29 -0700 Message-ID: <87r4ac8i2a.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VioIo-0005Ep-5H for emacs-orgmode@gnu.org; Tue, 19 Nov 2013 11:37:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VioIk-0008KN-2J for emacs-orgmode@gnu.org; Tue, 19 Nov 2013 11:37:26 -0500 Received: from mail-pb0-x22a.google.com ([2607:f8b0:400e:c01::22a]:34828) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VioIj-0008KA-QQ for emacs-orgmode@gnu.org; Tue, 19 Nov 2013 11:37:21 -0500 Received: by mail-pb0-f42.google.com with SMTP id uo5so8609696pbc.29 for ; Tue, 19 Nov 2013 08:37:20 -0800 (PST) In-Reply-To: (Gary Oberbrunner's message of "Tue, 19 Nov 2013 08:47:41 -0500") 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: Gary Oberbrunner Cc: Orgmode Mailing List --=-=-= Content-Type: text/plain 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. > The following Org-mode file. --=-=-= Content-Type: text/x-org Content-Disposition: inline; filename=repeater.org #+Title: Example demonstrating repetition of a block of text * Top When exported, say as ASCII, I'd like this: #+call: w/replacement(replacement="foo") :results list #+call: w/replacement(replacement="bar") :results list #+call: w/replacement(replacement="baz") :results list * COMMENT Support #+name: lines 1. this is the first line 2. this is the second line with %VARIANT% as the value 3. this is the third line #+name: w/replacement #+begin_src emacs-lisp :var lines=lines :var replacement="rep" :results list (mapcar (lambda (line) (replace-regexp-in-string (regexp-quote "%VARIANT%") replacement line 'fixedcase)) lines) #+end_src #+RESULTS: w/replacement - this is the first line - this is the second line with rep as the value - this is the third line --=-=-= Content-Type: text/plain exports to the following ASCII --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=repeater.txt __________________________________________________ EXAMPLE DEMONSTRATING REPETITION OF A BLOCK OF TEXT __________________________________________________ Table of Contents _________________ 1 Top 1 Top ===== When exported, say as ASCII, I'd like this: - this is the first line - this is the second line with foo as the value - this is the third line - this is the first line - this is the second line with bar as the value - this is the third line - this is the first line - this is the second line with baz as the value - this is the third line --=-=-= Content-Type: text/plain Cheers, > > Of course if the right answer is I should write a python script to generate > my org-mode text, well, that's OK too. :-) -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D --=-=-=--