emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Is it possible to repeat a block of org-mode text on export, may


From: Eric Schulte
Subject: Re: [O] 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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Gary Oberbrunner <address@hidden> 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.

#+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
exports to the following ASCII

           __________________________________________________

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

reply via email to

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