emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: Gary Oberbrunner <garyo@oberbrunner.com>
Cc: Orgmode Mailing List <emacs-orgmode@gnu.org>
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	[thread overview]
Message-ID: <87r4ac8i2a.fsf@gmail.com> (raw)
In-Reply-To: <CAFChFyg-M3f2CN7rQZOzbmcQi06jsYEPSc1kFK2Hy_FVktQ8=A@mail.gmail.com> (Gary Oberbrunner's message of "Tue, 19 Nov 2013 08:47:41 -0500")

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

Gary Oberbrunner <garyo@oberbrunner.com> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: repeater.org --]
[-- Type: text/x-org, Size: 804 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 33 bytes --]


exports to the following ASCII


[-- Attachment #4: repeater.txt --]
[-- Type: text/plain, Size: 648 bytes --]

           __________________________________________________

             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

[-- Attachment #5: Type: text/plain, Size: 198 bytes --]


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

  parent reply	other threads:[~2013-11-19 16:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19 13:47 Is it possible to repeat a block of org-mode text on export, maybe with replacement? Gary Oberbrunner
2013-11-19 16:13 ` Thorsten Jolitz
2013-11-19 16:36 ` Eric Schulte [this message]
2013-11-19 17:19 ` Thomas S. Dye
2013-11-21 23:23   ` Gary Oberbrunner

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=87r4ac8i2a.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=garyo@oberbrunner.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).